Please refer to attached diagram. Consider a infinitesimal segment of the string located with the left end point at location $x$ and let the tension in the string be $T(x)$. We will assume the string is not accelerating horizontally, so we have $T(x)\cos\phi=T(x+dx)\sin\theta$. We will also assume that the string is not displaced far from equilibrium, so that both $\theta$ and $\phi$ are small such that the small angle approximation holds (ie. $\theta\approx\sin\theta\approx\tan\theta$ and same thing for $\phi$).

The net vertical force on this segment of string is $T(x+dx)\sin\theta-T(x)\sin\phi$. By the small angle approximation, this is approximately $T(x+dx)\tan\theta-T(x)\tan\phi$. But by the definition of slope, note that $\left.\frac{\partial u}{\partial x}\right|_x=\tan\phi$ and $\left.\frac{\partial u}{\partial x}\right|_{x+dx}=\tan\theta$, thus we have

\begin{equation}

T(x+dx)\left.\frac{\partial u}{\partial x}\right|_{x+dx}-T(x)\left.\frac{\partial u}{\partial x}\right|_{x}=F

\end{equation}

By newton's second law, we have $F=m\frac{\partial^2 u}{\partial t^2}$. Note that $m=\mu(x) dx$, and finally we have

\begin{equation}

T(x+dx)\left.\frac{\partial u}{\partial x}\right|_{x+dx}-T(x)\left.\frac{\partial u}{\partial x}\right|_{x}=\mu(x) \frac{\partial^2 u}{\partial t^2} dx

\end{equation}

Moving the $dx$ to the LHS we recognize the LHS as the derivative of $T(x)\frac{\partial u}{\partial x}$ at $x$ and we obtain

\begin{equation}

\frac{\partial}{\partial x}\left(T(x)\frac{\partial u}{\partial x}\right)=\mu(x)\frac{\partial^2 u}{\partial t^2}

\end{equation}