This guide is one section of a larger guide to installing a cent 6.x server in virtual box for development purposes with different applications. The top level guide with links to all of the sections is here: https://gist.github.com/ryanguill/5149058 Some instructions in this guide may assume a configuration from other parts of the guide.
#Install httpd
Instructions taken from here: http://www.ehowstuff.com/how-to-install-httpd-on-centos-6-3/
# yum install httpd httpd-devel
# vi /etc/sysconfig/iptables
Add the following lines before the first line that says REJECT - CHANGE THE IPADDRESS MASK as necessary for your network
# http
-A INPUT -s 192.168.0.0/24 -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
Restart iptables
# service iptables restart
Create the web root in the /data partition
# mkdir /data/www/
# sudo chmod 777 /data/www/
# sudo chown apache:apache /data/www/
Lets edit the configuration file
# vi /etc/httpd/conf/httpd.conf
Find the line that is commented out:
#ServerName www.example.com:80
Change it to (substitute your server name)
ServerName cent6-tmpl.local:80
Find the line that says:
DocumentRoot "/var/www/html"
Change it to
DocumentRoot "/data/www"
Find:
<Directory "/var/www/html">
Change it to:
<Directory "/data/www">
Save and get out
Start the service:
# service httpd start
Create a test index.html file
# echo '<html><body><h1>Hello World!</h1></body></html>' >> /data/www/index.html
Make the service start on boot
# chkconfig --level 234 httpd on
try to hit the web server by IP address outside of the virtual machine to test.
If you want to try it from the VM, you can use lynx
# yum install lynx
# lynx http://localhost/
You should be done and good to go. If you ever need to restart httpd
# service httpd restart
Or
# service httpd graceful
If you make changes to the httpd.conf file and the service wont start, use the configtest option
# service httpd configtest