Reputation: 124
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?
Upvotes: 12
Views: 18332
Reputation: 1
<VirtualHost *:80> ServerName www.mywebsite.com DocumentRoot /home/www/public_html/ <Directory /home/www/public_html/> Options None Order deny,allow Allow from all
Note ----> here instead of "None" Used "all"
Upvotes: -1
Reputation: 11
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>
Upvotes: 1
Reputation: 6948
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.
Upvotes: 23