0

Been trying the entire day to set up a lamp server. First I did: sudo apt-get install lamp-server^ And everything seemed to work. When I visited localhost the it works!! page showed. Then I mistakenly deleted my html folder. But i replaced it by my own. But then (ofc) the it works!! site disappeared, but my server was still working. But to revert this I tried to uninstall my lamp server, following these tips: How do I remove the LAMP stack so I can start over?

But since this is an old tutorial my system couldn't find most files when I tried to remove them...

Anyhow, after that I tried to install everything again by hand: sudo apt-get install apache2, sudo apt-get install apachelib2-mod-php, sudo apt-get install mysql-server. Then did a mysql_secure_isntallation or something. And followd the instructions.

Now when I visit localhost the only thing that is outputed is

<php
    echo "hello";
?>

which is a file i put there myself (not that it outputs the entire code). Also, I cant access my mysql database, even though i put the right password.

One huge problem I made is that I followed like 10 different tutorials on this, all which seem outdated since they all mentioned php5.

I know Im out on deep water here, but I don't even know how to debug this or what to check for. What can have gone wrong? What is still working? What is my best course of action right now?

  • Please let me know if this worked out for you. If not, then I'll try some other way, and if it is so please let me know so that other viewers of this question be sure about the answer. – Siraj Alam Feb 27 '17 at 14:21
  • 3
    Possible duplicate of PHP script not executing on Apache server – muru Aug 2 '17 at 5:21
1

Edit 2017, August: You may have some difficulty in installing php5 in new Update of Ubuntu (16.04). Refer this to install php5.


I was also fully messed up. And I did this.

Completely remove apache2, mysql, php5, phpmyadmin.

  1. Completely removing PHPMyAdmin

    $ sudo apt-get remove phpmyadmin* $ sudo apt-get autoremove $ sudo apt-get autoclean $ sudo rm -rf /etc/phpmyadmin /var/lib/phpmyadmin /var/lib/phpmyadmin

  2. Completely removing php5

    $ sudo apt-get remove php5 $ sudo apt-get autoremove $ sudo apt-get autoclean $ sudo rm -rf /etc/php5 /var/lib/php5 /var/lib/php5

  3. Completely removing mysql

    $ sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-5.5 mysql-client-core-5.5
    $ sudo apt-get autoremove
    $ sudo apt-get autoclean
    $ sudo rm -rf /etc/mysql /var/lib/mysql /var/lib/mysql-files
  4. Completely removing apache2

    $ sudo apt-get remove apache2* $ sudo apt-get autoremove $ sudo apt-get autoclean $ sudo rm -rf /etc/apache2 /var/lib/apache2 /var/lib/apache2


Now Completely install all of them.

  1. apache2

$ sudo apt-get install apache2

  1. mysql

$ sudo apt-get install mysql-server

  1. php5

$ sudo apt-get install php5 libapache2-mod-php5

$ sudo apt-get install php5-mysqlnd

  1. phpmyadmin

$ sudo apt-get install phpmyadmin php-mbstring php-gettext

---------------After These Installation----------------------

Write the following line to setup phpmyadmin

Include /etc/phpmyadmin/apache.conf

At the end the of file /etc/apache2/apache2.conf


Start the apache server

$ sudo service apache2 start

Note

Some of them are interdependent. So follow the steps in given order.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.