Install Apache 2
Apache2 is a centos software package, so we can directly install it using the following command:
Yum install httpd
Now configure the system to start Apache at boot
Chkconfig -- levels 235 httpd on
And start Apache
/Etc/init. d/httpd start
Now, go to http: // 192.168.0.100 in your browser and you should see the test page of apache2:
Apache 2 test webpage
Apache's default document root directory is on centos/Var/www/htmlDirectory. The configuration file is/etc/httpd/CONF/httpd. conf. Configure the directory stored in/etc/httpd/CONF. d.
4. Install PhP5
We can use the following command to install PhP5
Yum install PHP
Restart After installation
/Etc/init. d/httpd restart
Address: http://server.zol.com.cn/279/2797239.html
######################################## ##
Update centos firewall settings to enable port 80 access
The following is an example of adding port 80:
[Root @ centos httpd] #/sbin/iptables-I input-P TCP -- dport 80-J accept
Save
[Root @ centos httpd] #/etc/rc. d/init. d/iptables save
Iptables: Save the firewall rules to/etc/sysconfig/iptables: [OK]
If the above steps are not complete, it may be that the iptables file uses include call.
Generally, this path is/etc/sysconfig/iptables.
Or use VI to open the file and modify it.
[Root @ centos httpd] # vi/etc/sysconfig/iptables
# Generated by iptables-save v1.4.7 on TUE Feb 14 07:32:18 2012
* Filter
: Input accept [0: 0]
: Forward accept [0: 0]
: Output accept [7: 640]
-A input-p tcp-m tcp -- dport 10000-J accept
-A input-p tcp-m tcp -- dport 80-J accept
-A input-M state -- state related, established-J accept
-A input-p icmp-J accept
-A input-I lo-J accept
-A input-p tcp-M state -- state new-m tcp -- dport 22-J accept
-A input-J reject -- reject-with ICMP-host-prohibited
-A forward-J reject -- reject-with ICMP-host-prohibited
Commit
# Completed on TUE Feb 14 07:32:18 2012
Restart the service
[Root @ centos httpd] # service iptables restart
Iptables: clear firewall rules: [OK]
Iptables: Set the chain to policy accept: Filter [OK]
Iptables: uninstalling module: [OK]
Iptables: Application Firewall Rules: [OK]
Check whether the port is effective:
[Root @ centos httpd] #/etc/init. d/iptables status
Table: Filter
Chain input (Policy accept)
Num target prot opt source destination
1 accept TCP -- 0.0.0.0/0 0.0.0.0/0 tcp dpt: 10000
2 accept TCP -- 0.0.0.0/0 0.0.0.0/0 tcp dpt: 80
3 accept all -- 0.0.0.0/0 0.0.0.0/0 state related,
4 accept ICMP -- 0.0.0.0/0 0.0.0.0/0
5 accept all -- 0.0.0.0/0 0.0.0.0/0
6 accept TCP -- 0.0.0.0/0 0.0.0.0/0 state New TCP
7 reject all -- 0.0.0.0/0 0.0.0.0/0 reject-with IC
Chain forward (Policy accept)
Num target prot opt source destination
1 reject all -- 0.0.0.0/0 0.0.0.0/0 reject-with IC
Chain output (Policy accept)
Num target prot opt source destination