How to change document root in Ubuntu with Apache, Nginx, and PHP-FPM

I use ServerPilot to configure the server, so the directories and services are suffixed with "-sp". Make sure to change this if your server configuration is different.

Change values in the braces (i.e. {...}) to reflect the values on the server.

1. Update Apache

vi /etc/apache-sp/vhosts.d/{...}.conf

Edit the following line:

Define DOCUMENT_ROOT /srv/users/serverpilot/apps/{...}/public

2. Update Nginx

vi /etc/nginx-sp/vhosts.d/{...}.conf

Edit the following line:

root /srv/users/serverpilot/apps/{...}/public;

3. Update PHP-FPM

vi /etc/php{7.0}-sp/fpm-pools.d/{...}.conf

Edit the following line:

php_value[doc_root] = /srv/users/serverpilot/apps/$pool/public

4. Restart services

service apache-sp restart
service nginx-sp restart
service php{7.0}-fpm-sp restart

Paul Ryley

Read more posts by this author.

Subscribe to Paul Ryley

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!