RSS

Change www path in Apache2 Ubuntu

22 May

By: Apache Ubuntu

To create a new site:

  • Copy the default website as a starting point. sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/mysite.conf 

  • Edit the new configuration file in a text editor “sudo nano” on the command line or “gksudo gedit”, for example:gksudo gedit /etc/apache2/sites-available/mysite.conf

  • Change the DocumentRoot to point to the new location. For example, /home/user/public_html/

  • In the file: /etc/apache2/apache2.conf, change the Directory directive, replace <Directory /var/www/> to<Directory /home/user/public_html/>

  • You can also set separate logs for each site. To do this, change the ErrorLog and CustomLog directives. This is optional, but handy if you have many sites

  • Save the file

Now, we must deactivate the old site, and activate our new one. Ubuntu provides two small utilities that take care of this: a2ensite (apache2enablesite) and a2dissite (apache2disable site).

$ sudo a2dissite 000-default && sudo a2ensite mysite

Finally, we restart Apache2:

$ sudo /etc/init.d/apache2 restart

If you have not created /home/user/public_html/, you will receive an warning message

Copy from: https://help.ubuntu.com/community/ApacheMySQLPHP

Advertisements
 
Leave a comment

Posted by on May 22, 2015 in Apache2, Linux, Ubuntu

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: