-1

This question already has an answer here:

How to install LAMP server in Ubuntu 16.04 and add www document root to user's home

marked as duplicate by David Foerster, user117103, muru, Eric Carvalho, TheWanderer May 17 '16 at 23:50

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

0

Install LAMP server:

sudo apt-get install lamp-server^

Enable userdir module:

sudo a2enmod userdir

Enable PHP execution in user directory:

sudo nano /etc/apache2/mods-available/php7.conf

(if you use PHP5, it's php5.conf)

Comment this part:

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

Press Ctrl+X to save

Enable directory listing:

sudo nano /etc/apache2/apache2.conf

Add this:

<Directory /home/*/public_html/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

Press Ctrl+X to save


Restart apache:

service apache2 restart

Now put your php files in /home/yourname/public_html directory and go to
http://localhost/~yourname from your web browser.

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