I noticed that the default sites-available file (/etc/apache2/sites-available/default) contained many "directory" tags with various options.
<Directory />
, <Directory /var/www/>
, <Directory "/usr/lib/cgi-bin">
, and <Directory "/usr/share/doc/">
Do I need any of those, or can I safely remove them?
The /etc/apache2/sites-available directory holds configuration files for Apache Virtual Hosts. Virtual Hosts allow Apache to be configured for multiple sites that have separate configurations.
The difference is that virtual sites listed in the sites-enabled directory are served by Apache. In the sites-available directory there are the virtual sites that exist on your server, but people can't access them because they are not enabled yet.
On Ubuntu systems, Apache Virtual Hosts configuration files are located in /etc/apache2/sites-available directory. They can be enabled by creating symbolic links to the /etc/apache2/sites-enabled directory, which Apache read during the startup.
Don't start adjusting the default site, it will just become a mess and you won't be able to figure out what directive does what.
I would recommend you write your own virtual host configuration, this way you actually know what your site does. Here is a little bare bones configuration to get you started.
<VirtualHost *:80>
ServerName www.mywebsite.com
DocumentRoot /home/www/public_html/
<Directory /home/www/public_html/>
Options None
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
Just put it in sites-available
and then run a2ensite mywebsite
(mywebsite
being the filename of the vhost configuration), then reload the server configuration with /etc/init.d/apache2 reload
.
An explanation for all the directives I used can be found in the apache documentation (I am assuming you run version 2.2).
Oh, and of course you need to disable the default site (a2dissite default
) if the ServerName
s are conflicting.
I couldn't have said that better. I have been struggling with this too and this is right on. You can also use service apache2 restart
and service apache2 reload
instead of /etc/init.d/apache2 reload
. It does the same thing and may be easier to remember although I think some setups need the above.
Apache is a tricky setup, no doubt. I just started using Ubuntu 13.04 and they have a really great manual that will help you on the entire setup, different options, etc but again, the above is spot on.
Good luck and just keep at it. It will get easier and start to make sense.
The manual is here: https://help.ubuntu.com/13.04/serverguide/serverguide.pdf
Update: this is another one I use.
<VirtualHost xx.xxx.xxx.xx:80>
ServerAdmin [email protected]
ServerName domain.com
ServerAlias www.domain.com
DocumentRoot /var/www/domain.com/html/drupal
ErrorLog /var/www/domain.com/logs/error.log
CustomLog /var/www/domain.com/logs/access.log combined
</VirtualHost>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With