July 21, 2008
apache
No Comments
I am trying a new version of apache on Solaris. I jumped from 2.058 to 2.2.9. The httpd.conf from the old to the new was no longer valid, so i started again. Made the classic mistake of trying to do everything before testing and the whole configuration was screwed up so i started again. There was an error in the browser i had not seen before:
Forbidden
You don’t have permission to access / on this server
So i looked at all the permission files, all ok. I had another look at the httpd.conf file and found the <Directory> directive has changed to “a very restrictive set of features”. I changed “Deny from all” to “Allow from all” and it is now working.
May 28, 2008
apache
No Comments
This one took a long time, There are loads and loads of examples out there but not all of them will work for your solution depending largely on what OS and version of Apache you are using. I am using Solaris 10 U4 and Apache 2.0.58.
You only need to amend 2 files. /etc/hosts and your Apache’s httpd.conf, which in my case is /usr/local/apache2/conf/httpd.conf.
In /etc/hosts add the ip address and fqdn of the apache2 servers. So on my host anouk, which has an ip address of 192.168.0.23 i would add the following:
192.168.0.23 anouk.dynalias.com
192.168.0.23 elthamauskick.dynalias.com
Next is the httpd.conf file. Vi and shift-g to scroll to the end of the file, which is the virtualhost section. This is what i added:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /work
</VirtualHost>
<VirtualHost *:80>
Servername anouk.dynalias.com
ServerAdmin mglas72@gmail.com
DocumentRoot /work/html
DirectoryIndex index.html index.php
Redirect /index.html http://anouk.dynalias.com/mgblog
</VirtualHost>
<VirtualHost *:80>
Servername elthamauskick.dynalias.com
ServerAdmin mglas72@gmail.com
DocumentRoot /work/html/auskick
DirectoryIndex index.html index.php
</VirtualHost>
And from here you could add as many virtualhosts as you would like. Note that inside each virtualhost you can add almost any Apache directive, but directives listed in other parts of the httpd.conf will be ignored if a virtualhost is found. The top virtualhost in the above example is used to capture any requests that fall out of the two virtualhost domains, so it displays an error message contained in /work.
With all the options available you will undoubtedly require the documentation, here is the link: http://httpd.apache.org/docs/2.0/vhosts. Google, as always, is your friend. One last little tip, use the /usr/local/apache2/bin/httpd -S if you are having trouble, it will provide you with parsing info on the httpd.conf file.
May 13, 2008
apache
No Comments
To list the files in a directory with apache is very simple. All you have to do is add a directory alias to httpd.conf file. So if i want to add an alias called aliastest to directory /test i would add the following line:
alias /aliastest /test
Then i would go to my url:
http://myurl.com/aliastest
and i would see all files listed in /test directory (of course provided the permissions are set correctly). If i want to password protect it so that i can only see the files if i enter a username and password i add this to the directory section of httpd.conf;
<Directory “/test”>
Options Indexes MultiViews
AllowOverride AuthConfig
AuthName “test”
AuthType Basic
AuthUserFile /test/.htpasswd
AuthGroupFile /dev/null
require user test
Order allow,deny
Allow from all
</Directory>
Don’t forget to add a user;
# /usr/local/apache2/bin./htpasswd -c .htpasswd test
New password:
Re-type new password:
Adding password for user test
Then ensure the settings in the /Directory such as AuthUserfile is correct, restart apache and you’re good. There are many, many options for securing apache and this is very basic, so don’t go hiding sensitive information using this method.