Donnerstag, 7. Juli 2011

Apache Server

So, finally it works,

I just setup the Apachewebserver on this server. There was a little difficulty in getting the vhosts to work. So here is the HowTo in 4 Steps


We need to install the software first
zypper in apache2 php5 apache2-mod_php5

Step2 (Open firewall)

OpenSUSE has an firewall, it is enabled by default an d blocks all incoming connections. So we need to open the http/https ports to get an working apache

  1. shell> yast

  2. goto Security and Users and open Firewall

  3. goto Allowed Services

  4. add HTTP Server and HTTPS Server

  5. Next and Finish

Step3 (Changes in /etc/apache2/httpd.conf)

Here you should add a line
NameVirtualHost *:80

this will enable the vhost feature, so you can have many apache vhosts listen on the same server.

Step4 (Changes to autogenerate vhosts)

So, now just before i setup my first vhost i worked on a little script which will make it easier to generate vhost, first of all i generated an vhost_cur_template file in /etc/apache2/vhosts.d/
<VirtualHost *:80>
ServerName __SERVERNAME__
DocumentRoot /srv/www/vhosts/__SERVERNAME__
ErrorLog /var/log/apache2/__SERVERNAME__-error_log
CustomLog /var/log/apache2/__SERVERNAME__-access_log combined
HostnameLookups Off
UseCanonicalName Off
ServerSignature On
ScriptAlias /cgi-bin/ "/srv/www/vhosts/__SERVERNAME__/cgi-bin/"
<Directory "/srv/www/vhosts/__SERVERNAME__/cgi-bin">
AllowOverride None
Options +ExecCGI -Includes
Order allow,deny
Allow from all
<Directory "/srv/www/vhosts/__SERVERNAME__">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all

Then i wrote a little shell script to produce new vhosts
# exec: sh
mkdir -p /srv/www/vhosts/$1/cgi-bin/
sed "s/__SERVERNAME__/$1/g" /etc/apache2/vhosts.d/vhost_curr.template > /etc/apache2/vhosts.d/$1.conf
service apache2 reload

so, now you can gerate a new vhost just by sh for example