LAMP-stack installation : php code not running (php code displayed as such)
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.
-
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
-
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
-
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
-
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.
- apache2
$ sudo apt-get install apache2
- mysql
$ sudo apt-get install mysql-server
- php5
$ sudo apt-get install php5 libapache2-mod-php5
$ sudo apt-get install php5-mysqlnd
- 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.
Related videos on Youtube
mrfr
Updated on September 18, 2022Comments
-
mrfr over 1 year
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 visitedlocalhost
theit works!!
page showed. Then I mistakenly deleted my html folder. But i replaced it by my own. But then (ofc) theit 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 amysql_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?
-
sirajalam049 about 7 yearsPlease 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.
-
muru almost 7 yearsPossible duplicate of PHP script not executing on Apache server
-