#! /bin/bash # Run the following script as su to build a web server. # After it is done, you can edit the folder /export/home/apache/$owner to host a webpage owner=tlyoon mkdir /export/home/apache/$owner chown -R $owner:$owner /home/apache/$owner usermod -g apache $owner cd /var/www/html ln -s /export/home/apache/$owner $owner # Modify the content of /etc/httpd/conf/httpd.conf. # A modified template of /etc/httpd/conf/httpd.conf can be downloaded from http://comsics.usm.my/tlyoon/configrepo/howto/customise_centos/webserver/httpd.conf.rocks-6-1-1 # Download this template and replace the file /etc/httpd/conf/httpd.conf cd /etc/httpd/conf mv /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.orig wget http://comsics.usm.my/tlyoon/configrepo/howto/customise_centos/webserver/httpd.conf.rocks-6-1-1 mv httpd.conf.rocks-6-1-1 httpd.conf # Now, the user $owner can build his/her own webpage by modifying the content in /export/home/apache/$owner. As a trial, the sample index file index.html with a 'hello world' is first generated in http://10.1.1.1/$owner echo 'hello world, this webpage is created by user' $user >> /export/home/apache/$user/index.html service httpd restart #issue the follwing line to activate port 80 that is specified in the firewall setting in the file /etc/sysconfig/iptables iptables -I INPUT 1 -p tcp --dport 80 -j ACCEPT # open the page http://10.1.1.1/$owner to see if you see a 'hello world'.