Getting PHP to work with apache to run .php files through browser
Solution 1
I think you probably missed restarting apache2...
/etc/init.d/apache2 restart
You will have to run this command from your root account, or put sudo on the beginning of it.
For full details on installing PHP5 - use the official php5 on debian instructions HERE
Solution 2
Run below commands again and check...
sudo /etc/init.d/apache2 stop
sudo apt-get remove --purge apache2 php5
sudo apt-get remove --purge libapache2-mod-php5
sudo apt-get install php5 apache2 libapache2-mod-php5
sudo /etc/init.d/apache2 start
sudo a2enmod php5
sudo /etc/init.d/apache2 force-reload
Related videos on Youtube
dukevin
Updated on September 17, 2022Comments
-
dukevin over 1 year
I have VPS running Debian 5.0 (I think) and I would like to get it to run PHP files. I was told it needed to be configured with Apache. I tried entering the command
apt-get install apache2 php5 libapache2-mod-php5
. But there was no change. Console output: http://pastebin.com/sVMWq6mAThis is everything in my
/etc/apache2/mods-enabled
:http://img35.imageshack.us/img35/6474/modsb.jpg
My webserver can be accessed here: http://206.217.223.136/test/ In my test.php file I have the code :
<?php phpinfo(); ?>
but instead of displaying the page, it tries to download it. How can I fix this?
-
dukevin about 13 yearsLooking at the site you provided, I typed this:
vps:~# sudo a2enmod php4 ERROR: Module php4 does not exist!
-
palbakulich about 13 years@Kevin - php4 definitely won't exist, you installed php5.
-
dukevin about 13 yearsI get the same error for php5 :/
-
dukevin about 13 yearsAnd regarding your edited post, it says directory not found, perhaps I don't even have apache installed?
-
dukevin about 13 yearsAh, reinstalling just said they are at their newest version. Not sure why I don't have /etc/apache or /ect/init.d/apache2
-
palbakulich about 13 years@Kevin - a2enmod, a2dismod - enable or disable an apache2 module, you have it installed, but not enabled - What I'd try is removing php5 (apt-get remove php5 libapache2-mod-php5) then reinstall with apt-get install.
-
palbakulich about 13 years@Kevin - I hope that's not a spelling error? /ect/init.d/apache2 ???
-
dukevin about 13 yearsI can't remove php5.... here's the console output: pastebin.com/H8ZMMQq6
-
palbakulich about 13 years@Kevin - ok somehow your module for php5 dissappeared, I suggest you fix that error
-
palbakulich about 13 years@Kevin - if you have errors, most of the time a Google on them will help you solve them - ;-)
-
Shadur about 13 years@kevin @palhmbus Given the ungodly mess that occurred back [unix.stackexchange.com/questions/8455/fixing-debian-installer] I'm starting to suspect that there is something seriously screwed up about that VPS installation that's throwing out crazy error after crazy error...
-
dukevin about 13 years@palhmbus The link you provided didn't help either: pastebin.com/kDeKyAHV @Shadur :( I don't know why my vps installation is so screwed up, when my vps crashed my providers said they had to reinstall the operating system
-
dukevin about 13 years@Shadur It appeared to have successfully installed pastebin.com/KurVTqGJ
-
Shadur about 13 yearsAlso, it looks like apache is already running on port 80 but has not been started by the usual script. Try
/etc/init.d/apache2 stop
to see if it does stop correctly. -
dukevin about 13 yearsIt looks like it stopped correctly
Stopping web server: apache2.
-
palbakulich about 13 years@Kevin - on a completely unrelated note, why use PHP for a file server, doesn't ftp suit your purposes?
-
dukevin about 13 yearsI got several errors during the process, here's my full output: pastebin.com/2hmbC1Su
-
palbakulich about 13 years@Kevin - your VPS is causing problems, either it isn't a very reliable VPS setup / company, I'd start from scratch with a complete reinstall of the VPS, I recommend you don't install debian (maybe their debian images are bad), try a ubuntu server, at least it would be simpler to get up. ;-)
-
dukevin about 13 years:( I have lots of work saved on that vps
-
Yash Kumar Verma almost 7 yearsi have my php7 installed and it's not showing up .php files (running)