一、httpd的简介
httpd就是静态的apache服务器,其中一半用来作为静态页面的服务器,其中tomcat也可以作为静态服务器,但是在静态服务器性能上没有apache好,tomcat只是作为一个servlet容器的性能比较好,一半在使用tomcat的时候可以用httpd+tomcat或者Nginx+tomcat的方式来进行web服务器的搭建。
二、httpd的安装和配置(使用yum源进行安装)
1)httpd的安装
yum install httpd-devel
2)httpd的配置
vi /etc/httpd/conf/httpd.conf
#配置httpd的配置,搜索ServerName 把www.example.com:80改为localhost:80
ServerName localhost:80
3)开启端口的防火墙
#将80端口添加到防火墙中,打开80端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
#重新启动防火墙
firewall-cmd --reload
4)httpd开机启动
systemctl enable httpd.service
5)启动服务、关闭服务、查看服务进程
#开启httpd服务
systemctl start httpd.service
#关闭httpd服务
systemctl stop httpd.service
#重新启动httpd服务
systemctl restart httpd.service
#查看httpd启动的进程
ps aux | grep httpd
-------------------------------------------------------------------------------------------
root 10940 0.0 0.4 221928 4944 ? Ss Jul18 0:02 /usr/sbin/httpd -DFOREGROUND
apache 10941 0.0 0.3 222064 3720 ? S Jul18 0:00 /usr/sbin/httpd -DFOREGROUND
apache 10942 0.0 0.3 222064 3720 ? S Jul18 0:00 /usr/sbin/httpd -DFOREGROUND
apache 10943 0.0 0.3 222064 3716 ? S Jul18 0:00 /usr/sbin/httpd -DFOREGROUND
apache 10944 0.0 0.3 222064 3724 ? S Jul18 0:00 /usr/sbin/httpd -DFOREGROUND
apache 10945 0.0 0.3 222064 3716 ? S Jul18 0:00 /usr/sbin/httpd -DFOREGROUND
apache 11020 0.0 0.3 221928 3204 ? S Jul18 0:00 /usr/sbin/httpd -DFOREGROUND
apache 11021 0.0 0.3 221928 3204 ? S Jul18 0:00 /usr/sbin/httpd -DFOREGROUND
apache 11022 0.0 0.2 221928 2960 ? S Jul18 0:00 /usr/sbin/httpd -DFOREGROUND
root 13181 0.0 0.0 112664 968 pts/0 S+ 11:56 0:00 grep --color=auto httpd
-------------------------------------------------------------------------------------------
6)访问http://192.168.18.201/ 就可以打开httpd的界面
三、httpd的安装和配置(使用)