|
12 years ago 7 |
Hi2all, today I read a nice tutorial by @mysoomro, and I want to take you a few words, how start your web-project in home directory.
The default directory for files of a site is in /var/www. To access this directory, we need rights of root. To create a website, for example, /home/user/www/ perform the following steps:
1. Make a copy of the standard config file site (/etc/apache2/sites-available/default) and rename it to (/etc/apache2/sites-available/mysite).
sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/mysite
2. Open a new config file in a text editor nano.
sudo nano /etc/apache2/sites-available/mysite
3. Change the DocumentRoot setting in the new location site.
/home/user/www/
4. Change the parameter Directory, replacing <Directory /var/www/> on <Directory /home/user/www/>. So, you you get something like:
<VirtualHost *:80>ServerAdmin webmaster@localhostDocumentRoot /home/stleon/www<Directory />Options FollowSymLinksAllowOverride None</Directory><Directory /home/stleon/www/>Options Indexes FollowSymLinks MultiViewsAllowOverride NoneOrder allow,denyallow from all</Directory>ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/<Directory "/usr/lib/cgi-bin">AllowOverride NoneOptions +ExecCGI -MultiViews +SymLinksIfOwnerMatchOrder allow,denyAllow from all</Directory>ErrorLog ${APACHE_LOG_DIR}/error.log# Possible values include: debug, info, notice, warn, error, crit,# alert, emerg.LogLevel warnCustomLog ${APACHE_LOG_DIR}/access.log combinedAlias /doc/ "/usr/share/doc/"<Directory "/usr/share/doc/">Options Indexes MultiViews FollowSymLinksAllowOverride NoneOrder deny,allowDeny from allAllow from 127.0.0.0/255.0.0.0 ::1/128</Directory></VirtualHost>
Save the file.
5. Now you have to deactivate the old site (default) and add a new (mysite).
sudo a2dissite default && sudo a2ensite mysite
6. Restart Apache2:
sudo /etc/init.d/apache2 restart
7. Then open with gedit /etc/apache2/envvars:
sudo gedit /etc/apache2/envvars
8. Find export APACHE_RUN_USER=www-data and export APACHE_RUN_GROUP=www-data. Replace it to
9. Restart Apache2:
sudo /etc/init.d/apache2 restart
I hope this tutorial has been useful to you
great tut but what if i want to add another site keeping the current site @ /var/www/ (and use say another port aswell as my other site on the standard port 80 how can i achieve this without loosing my original default apache2 site? or perhaps even having it goto localhost.site2 instead of localhost 1 out of these 2 options would be amazing is it possible to do this at all? (on the same a[ache server)?
I like this tutorial. Just got a error when i wanted to restart apache:
* Restarting web server apache2 ... waiting /var/lock/apache2 already exists but is not a directory owned by ciaobello.
Please fix manually. Aborting.
I fixt it manually with:
sudo chown -R ciaobello:ciaobello /var/lock/apache2
I prefer to keep my sites out of my home directory but this would work if you want to keep your sites in your home.