Dear Wiki user, You have subscribed to a wiki page or wiki category on "Httpd Wiki" for change notification.
The following page has been changed by ChrisPepper: http://wiki.apache.org/httpd/ApacheVirtualHostMysql The comment on the change is: Lots of minor cleanup ------------------------------------------------------------------------------ == Introduction == - Here you'll find an example on how to do name based virtual hosting using mod_perl and mysql. + Here you'll find an example of how to do name-based virtual hosting using mod_perl and mysql. - This works for my needs but most likely you will have to change a lot to get it to do what you want. + This works for my needs but most likely you will have to change parts to get what you want. - Everything covered here is fairly advance and I'm under the assumption you know your way around Apache, MySQL and Perl. + Everything covered here is fairly advanced and I'll assume you know your way around Apache, MySQL and Perl. I tried to make it as portable as possible. - It should work with minimum changes on any linux system and with few more on windows aswel (tested) + It should work with a minimum changes on any Linux system, and with more on Windows as well. - '''note: if you experience problems you can try to contact me on #apache (ask for sjorge)''' + '''Note: If you experience problems you can try to contact me on #apache (ask for sjorge)''' == Requirements == 1. perl @@ -17, +17 @@ 1. mod_perl 2. mod_dav / mod_dav_fs 3. mod_authn_dbd - 4. libphp5 (can be left out - changes to the files are needed) + 4. libphp5 (can be left out -- changes to the files are needed) - 3. MySQL server (other database server will work if there is are DBI an DBD drivers available - changes to the files are needed) + 3. MySQL server (another database server will work if there are DBI and DBD drivers available -- changes to the files are needed) == General Setup == @@ -43, +43 @@ || ''$name''/httpdocs || document root|| == Setting up the database == - First we need a database to place our hosts. + First we need a database to hold our host configuration. - Use the mysql client or phpMyAdmin or similar to create the database. + Use the MySQL client, or phpMyAdmin, or some other means, to create the database. You can get the database template [http://wiki.apache.org/httpd/ApacheVirtualHostMysql/database here] You also need to create a user with access to that database. @@ -54, +54 @@ * more information on the database will follow later == Configuring httpd == - '''note: replace /srv/httpd with your own !ServerRoot!!''' + '''Note: Replace /srv/httpd with your own !ServerRoot!!''' - Download all .conf and .tmpl files provided in the '''General Setup''' section and save them in the correct location. + Download all .conf and .tmpl files provided in the '''General Setup''' section and save them in the correct locations. Edit httpd.conf and change: * ServerRoot @@ -69, +69 @@ * db user * db pass - * host http_tmpl path (full path!!) + * host http_tmpl path (full path!) - * host dav_tmpl path (full path!!) + * host dav_tmpl path (full path!) - * host path (full path!!) + * host path (full path!) Edit http.tmpl and webdav.tmpl and change: * all /srv/httpd occurrences to your ServerRoot - You should be good to go. Feel free to make more changes to the templates and or the configuration files + You should be good to go. Feel free to make more changes to the templates and configuration files - == Adding a hosts == + == Adding a host == - Use the mysql client or phpMyAdmin or similar to access the database. + Use the MySQL client or phpMyAdmin, or another means, to access the database. === adding host entry === {{{ INSERT INTO hosts VALUES(null, 'localhost', 1, 0, 0, 0, 0); }}} - || value || description || + || '''value''' || '''description''' || - || null || auto increment host id || + || null || auto-increment host ID || || 'localhost' || host name || || 1 || enable (0 to disable the host) || || 0 || disable webdav (1 to enable) || || 0 || disable cgi (1 to enable) || - || 0 || disable server side included (1 to enable) || + || 0 || disable Server Side Includes (1 to enable) || || 0 || disable php (1 to enable) || - (Re)start apache and the new vhosts will be available (you need to provide the -DDAV flag to enable webdav on the server) + (Re)start httpd and the new vhosts will be available (you need to provide the -DDAV flag to enable webdav on the server) - '''note: The directories for this vhost will be created automatically when apache is (re)started!''' + '''Note: The directories for this vhost will be created automatically when apache is (re)started!''' + - '''note: Removal isn't automatic, if you remove a host + aliases + users + configuration the files will remain) + '''Note: Removal isn't automatic, if you remove a host + aliases + users + configuration the files will remain) + - '''note: I recommend adding localhost as your first vhost. All request with and unknown host header will go to this host.''' + '''Note: I recommend adding localhost as your first vhost. All request with and unknown host header will go to this host.''' === adding users (require/optional) === Only require when you enable webdav for a host. {{{ INSERT INTO users VALUES(null, 1, 'user', 'apache-encrypted-password', 'dav'); }}} - || value || description || + || '''value''' || '''description''' || || null || auto increment user id || || 1 || host id user belongs too (check hosts table to get it) || || 'user' || user name ||
