Howto add a Webproject to your Apache Web-Server

02:28 PM by Christian Koch

Filed under apache, Commands

Last modified Saturday September 22nd, 2012

Learn howto add a simple Webproject to your Apache Webserver on SuSE Linux.

Goto your Apache configuration folder:

cd /etc/apache2/vhosts.d

Insert a new configuration file, for example mysite.conf. The file has to have the extension conf!

touch myproject.conf

Insert the following content to the file:

<VirtualHost *:80>
    ServerAdmin admin@mysite.tld
    ServerName www.mysite.tld

    DocumentRoot /srv/www/mysite

    ErrorLog /var/log/apache2/mysite-error_log
    CustomLog /var/log/apache2/mysite-access_log combined

    HostnameLookups Off

    UseCanonicalName Off

    ServerSignature Off

    <IfModule mod_userdir.c>
	UserDir public_html
	Include /etc/apache2/mod_userdir.conf

    <Directory "/srv/www/mysite">
        Options FollowSymlinks
        AllowOverride All
        Order allow,deny
        Allow from all

Change the lines containing www.mysite.tld to your prefered domain name and edit the paths to your project “/srv/www/mysite” to the paths were your projects will be. Also change the names of the error and access log files.

If you want to make your project password protected insert following lines to the Directroy Tag:

<Directory "/srv/www/mysite/htdocs">
	AuthType Basic
	AuthName "Testing-/Dev-System"
	AuthUserFile /srv/www/mysite/.htpasswd
	AuthGroupFile /dev/null
	require valid-user

AuthName will show the specified message in the user browsers popup that requests the user and password. AuthUserFile is the absolut path to your password file, usualy a file named .htpasswd.

Create the .htpasswd File with User test and password tester:

cd /srv/www/mysite/
htpasswd2 -c .htpasswd test
New password: *****
Re-type new password: *****
Adding password for user test

If you want to add more users do as follows:

htpasswd2 .htpasswd newuser

As you can see, you do not use the -c parameter anymore which tells the comand to create the file.



Related Articles

                                                        1 Comment

                                                        1. Anonymous

                                                          Thanks a ton for using time to write “Howto add a Webproject to your Apache Web-Server | codeterrorizer.

                                                          Friday February 15th, 2013 - 01:56 PM – Reply

                                                        Leave a Comment