Equation of motion of a photon in a given metric I have this metric:
$$ds^2=-dt^2+e^tdx^2$$
and I want to find the equation of motion (of x). for that i thought I have two options:


*

*using E.L. with the Lagrangian: $L=-\dot t ^2+e^t\dot x ^2 $.

*using the fact that for a photon $ds^2=0$ to get: $0=-dt^2+e^tdx^2$ and then: 
$dt=\pm e^{t/2} dx$.
The problem is that (1) gives me $x=ae^{-t}+b$ and (2) gives me $x=ae^{-t/2} +b$.
 A: If your solution is not a null geodesic then it is wrong for a massless particle.
The reason you go astray is that Lagrangian you give in (1) is incorrect for massless particles. The general action for a particle (massive or massless) is:
$$ S = -\frac{1}{2} \int \mathrm{d}\xi\ \left( \sigma(\xi) \left(\frac{\mathrm{d}X}{\mathrm{d}\xi}\right)^2 + \frac{m^2}{\sigma(\xi)}\right), $$
where $\xi$ is an arbitrary worldline parameter and $\sigma(\xi)$ an auxiliary variable that must be eliminated by its equation of motion. Also note the notation
$$ \left(\frac{\mathrm{d}X}{\mathrm{d}\xi}\right)^2\equiv \pm g_{\mu\nu} \frac{\mathrm{d}X^\mu}{\mathrm{d}\xi}\frac{\mathrm{d}X^\nu}{\mathrm{d}\xi}, $$
modulo your metric sign convention (I haven't checked which one is right for your convention). Check that for $m\neq 0$ this action reduces to the usual action for a massive particle. For the massless case however, you get
$$ S = -\frac{1}{2} \int \mathrm{d}\xi\  \sigma(\xi) \left(\frac{\mathrm{d}X}{\mathrm{d}\xi}\right)^2. $$
The equation of motion for $\sigma$ gives the constraint
$$ \left(\frac{\mathrm{d}X}{\mathrm{d}\xi}\right)^2 = 0, $$
for a null geodesic. This is necessary and consistent for massless particles, as you know.
The equation of motion for $X^\mu$ is (EDIT: Oops, I forgot a term here. Note that $g_{\mu\nu}$ depends on $X$ so a term involving $\partial_\rho g_{\mu\nu}$ comes into the variation. Try working it out for yourself. I'll fix the following equations up later):
$$ \frac{\mathrm{d}}{\mathrm{d}\xi}\left(\sigma g_{\mu\nu}\frac{\mathrm{d}X^{\mu}}{\mathrm{d}\xi}\right)=0, $$
but you can change the parameter $\xi\to\lambda$ so that $\sigma \frac{\mathrm{d}}{\mathrm{d}\xi} = \frac{\mathrm{d}}{\mathrm{d}\lambda}$, so the equation of motion simplifies to
$$ \frac{\mathrm{d}}{\mathrm{d}\lambda}\left(g_{\mu\nu}\frac{\mathrm{d}X^{\mu}}{\mathrm{d}\lambda}\right)=0, $$
which you should be able to solve to get something satisfying the null constraint.
A: I) Well, in 1+1 dimensions the light-cone (based at some point) is just two intersecting curves, which are precisely determined by the condition
$$\tag{1} g_{\mu\nu}\dot{x}^{\mu}\dot{x}^{\nu}~=~0,$$
and an initial condition cf. OP's second method. However, this eq. (1) will not determine light-like geodesics in higher dimensions. 
II) OP's first method, namely to vary the Lagrangian 
$$\tag{2}  L~:=~ g_{\mu\nu}(x)\dot{x}^{\mu}\dot{x}^{\nu} $$
is in principle also correct. It is a nice exercise to show that Euler-Lagrange equations are the geodesic equation. However, it seems that OP mistakenly identifies the parameter $\lambda$ of the geodesic with the $x^0$-coordinate. These are two different things! In 1+1 dimensions, we have two coordinates $x^0$ and $x^1$. There are two Euler-Lagrange equations. The complete solution for $\lambda\mapsto x^0(\lambda)$ and $\lambda\mapsto x^1(\lambda)$ will be all geodesics: time-like, light-like and space-like.
Since we are only interested in light-like geodesics, we would also have to impose eq. (1) in the Euler-Lagrange method. 
III) If one makes a coordinate transformation 
$$\tag{3} u~=~\exp(-\frac{x^0}{2})\quad\text{and}\quad v~=~\frac{x^1}{2}, $$
then OP's metric becomes
$$\tag{4} \frac{4}{u^2}(-du^2+dv^2)$$
which is e.g. also considered in this Phys.SE post (up to an overall constant factor). Obviously, the light-like geodesics are of the form 
$$\tag{5} v-v_0~=~ \pm (u-u_0). $$  
A: There is an elegant way of doing this using symmetries.
Notice that this metric is space translation invariant, so it has a killing vector $\partial_x$.  There is a corresponding conserved quantity $c_x$ along geodesics $x^\mu(\lambda)$ given by
\begin{align}
  c_x = g_{\mu\nu}\dot x^\mu(\partial_x)^\nu = e^t\dot x
\end{align}
Where an overdot denotes differentiation with respect to affine parameter.  On the other hand, the fact that the desired geodesic is a (null) photon geodesic along which $ds^2 = 0$ gives
\begin{align}
  0=-\dot t^2 + e^t\dot x^2
\end{align}
This forms a set of coupled differential equations that is not actually that hard to solve.  Hint: Try solving the first equation for $\dot x$, and then plugging it into the second equation.
