How to setup a LAMP server with mod_vhost_alias capability.
This document tell you how to setup a webserver so that all you need to do is upload to a ftp folder and tada you have a new subdomain. Read on!
Install MySQL
1. prefereably install using yum or up2date. If they fail then follow directions on http://dev.mysql.com/doc/refman/5.0/en/quick-install.html
Build Apache
1. wget http://download.nextag.com/apache/httpd/httpd-2.2.3.tar.gz 2. tar -zxf httpd-2.2.3.tar.gz 3. cd httpd-2.2.3 4. configure the build using following options ./configure "--prefix=/usr/local/apache" "--enable-so" "--enable-vhost-alias" "--enable-ssl=shared" "--enable-cgi=shared" "--enable-negotiation=shared" "--enable-setenvif=shared" "--enable-asis=shared" "--enable-alias=shared" "--enable-include=shared" "--enable-mime=shared" "--enable-status=shared" "--enable-actions=shared" "--enable-env=shared" "--enable-log_config=shared" "--enable-access=shared" "--enable-userdir=shared" "--enable-dir=shared" "--enable-auth=shared" "--enable-autoindex=shared" "--enable-imap=shared" "--enable-rewrite=shared" "--enable-suexec" "--with-perl=/usr/bin/perl" "$@" 5. make | grep -i error 6. make install 7. /usr/local/apache/bin/apachectl configtest 8. /usr/local/apache/bin/apachectl start
Integrate PHP
1. wget http://in2.php.net/get/php-5.1.6.tar.gz/from/in.php.net/mirror 2. tar -zxf php-5.1.6.tar.gz 3. cd php-5.1.6 4. Configure the build using following command ./configure --prefix=/apache --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/apache/conf --enable-libxml --disable-ipv6 --disable-cgi --with-mysql --with-zlib=/usr --with-zlib-dir=/usr --without-mhash --without-java 5. make | grep -i error 6. make install 7. Edit /usr/local/apache/conf/httpd.conf and add following lines at relevant sections LoadModule php5_module modules/libphp5.so AddHandler php5-script php # Add index.php to your DirectoryIndex line: DirectoryIndex index.php index.html AddType text/html php # PHP Syntax Coloring AddType application/x-httpd-php-source phps 8. /usr/local/apache/bin/apachectl configtest 9. /usr/local/apache/bin/apachectl start
Configure mod_vhost_alias
1. Add a user for the vhosts which will be used for running the server and uploading content. useradd vhost passwd vhost 2. If it exists, uncomment the Load module line for the vhost_alias module LoadModule vhost_alias_module libexec/httpd/mod_vhost_alias.so 3. If it exists, uncomment the AddModule one too: AddModule mod_vhost_alias.c 4. add the User and Group directives (add these outside of User vhost Group vhost 5. Look for the following section: < Directory /> Options FollowSymLinks AllowOverride All Order deny,allow Deny from all < /Directory > change it to look as under: < Directory /> Options FollowSymLinks AllowOverride All Order deny,allow Allow from all < /Directory > 6. Now add this snippet at the end of the file: VirtualDocumentRoot /home/vhost/%2+/%1 VirtualScriptAlias /home/vhost/%2+/%1/cgi-bin 7. Add content to the /home/vhost directory i... ftp to the server using username and password created in step 1 ii... create a folder with the domain name as name eg. /home/vhost/yourdomain.com iii... upload a site for example www.yourdomain.com in the folder www under the folder for domain will mean you upload content to /home/vhost/yourdomain.com/www 8. /usr/local/apache/bin/apachectl configtest 9. /usr/local/apache/bin/apachectl start If you don't see any errors, everything should be working. At this point, you should be able to add folders like /home/vhost/com-co.info/example and access those as http://example.com-co.info