2

I followed this tutorial to install lamp: https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu

At step 4: See PHP on your Server, I was told to do the following:

First create a new file:

> sudo nano /var/www/info.php

Add in the following line:

<?php
phpinfo();
?>

Then,I should see a page with lots of information, when I type in localhost/info.php

But the page is just white. No error message.

If I type in localhost/index, then the Apache2 Ubuntu default page loads.

Later, I moved info.php to /var/www/html but the page is still white.

At this point, I'm clueless. Any suggestions to fix this problem?

2
  • would you please update the outputs for which php & whereis php?
    – AzkerM
    Oct 23, 2016 at 10:47
  • @AzkerM which php: /usr/bin/php whereis php: php: /usr/bin/php7.0 /usr/bin/php /usr/lib/php /etc/php /usr/share/php7.0-json /usr/share/php7.0-xml /usr/share/php7.0-readline /usr/share/php7.0-mcrypt /usr/share/php7.0-opcache /usr/share/php7.0-mbstring /usr/share/php7.0-gd /usr/share/php /usr/share/php7.0-common /usr/share/php7.0-mysql /opt/lampp/bin/php /usr/share/man/man1/php.1.gz Oct 23, 2016 at 11:43

1 Answer 1

0

First of all, I would rather create a public_html folder in user's home directory

mkdir public_html

By default, PHP scripts in user directories are disabled. In other words you need to enable them. With your instructions, you seem to have php5 installed. To enable PHP scripts in user directories, edit /etc/apache2/mods-available/php5.conf file as root.

In my case I did

sudo vim /etc/apache2/mods-available/php5.conf

When that file is open, comment out the following lines (instructions inside the file too)

<IfModule mod_userdir.c>
    <Directory /home/*/public_html>
        php_admin_value engine Off
    </Directory>
</IfModule>

and save it. Make sure userdir is enabled with

sudo a2enmod userdir

Move that info.php file to your public_html folder. Restart apache2 with

sudo service apache2 restart

Go to http://localhost/~yourusername/info.php and it should work perfectly.

6
  • I tried to follow your steps: I couldn't install php5 so instead I just used the last version. Then, I went to /etc/apche2/mods-available/php7.o.conf and commented the section out (by putting #before the lines). And did sudo a2enmod userdir and apache2 restart. It says: Not found . The requested URL /sandro/public_html/info.php was not found on this server. (Apache/2.4.18) Oct 23, 2016 at 11:57
  • @Metaphysiker If you already installed libapache2-mod-php , try running sudo a2enmod php7.0, otherwise run sudo apt-get install libapache2-mod-php and then the first mentioned command. After this try restarting apache2 once again and tell me what is the outcome
    – jiipeezz
    Oct 23, 2016 at 12:31
  • sudo a2enmod php7.0: ob for apache2.service failed because the control process exited with error code. See "systemctl status apache2.service" and "journalctl -xe" for details. And now, I cant restart the apache 2 now Oct 23, 2016 at 12:35
  • That's weird because I started everything over and followed steps above and my info.php script works perfectly on apache2 server. Can you reach localhost/~username/ and see if your info.php is there, or what does it say if you try that?
    – jiipeezz
    Oct 23, 2016 at 13:16
  • Thanks for your help! It turns out, that I didnt properly installed lamp. Shame one me. Oct 23, 2016 at 13:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .