When the installation process is finished, Unix/Linux users should automatically stop the Apache service from running as the root user. As the root user, stop the Apache service with the command:
/etc/init.d/apache2 stop
Create a new user and group with the command:
groupadd apache
useradd -c "Apache" -g apache -p passwd1 apache
And then edit the /etc/apache2/envvars file and change the following two lines to cause Apache to run as the new user:
export APACHE_RUN_USER=apache
export APACHE_RUN_GROUP=apache
Apache sets the default document root as /var/www/html. You can leave this alone and change the ownership to the new Apache user, or you can create a new directory for the new document root. If you create a new directory, you have a few more commands to run.
Create a new configuration file in /etch/apache2/sites-available with the command:
cp /etc/apache2/sites-available/default /etc/apache2/sites-available/your_site
Then open the your_site configuration file in any text editor. You will need to change the DocumentRoot directive under the <VirtualHost *:80> section to reflect your new document root.
Disable the default site with the command:
a2dissite default
Enable the new site with the command:
a2ensite your_site
Restart the Apache service with the command:
/etc/init.d/apache2 restart