如何使用CentOS 7.4搭建Apache网站服务

一、安装Apache服务

关于安装Apache详细配置及原理概述请参考:CentOS 7.4搭建Apache网站服务

如何使用CentOS 7.4搭建Apache网站服务
[root@centos01 ~]# mount /dev/cdrom /mnt/      <!--挂载LAMP光盘-->
[root@centos01 ~]# cp /mnt/* /usr/src/       <!--将mnt目录下的程序包拷贝到/usr/src/-->
[root@centos01 ~]# mount /dev/cdrom /mnt/     <!--切换操作系统光盘-->
[root@centos01 ~]# rm -rf /etc/yum.repos.d/CentOS-*   <!--删除系统自动yum-->
[root@centos01 ~]# tar zxvf /usr/src/httpd-2.2.17.tar.gz -C /usr/src/  <!--解压缩Apache包-->
[root@centos01 ~]# cd /usr/src/httpd-2.2.17/    <!--进入Apache目录-->
[root@centos01 httpd-2.2.17]# ./configure 
--prefix=/usr/local/httpd 
--enable-so 
--enable-rewrite 
--enable-charset-lite 
--enable-cgi          <!--配置httpd-->
[root@centos01 httpd-2.2.17]# make && make install      <!--编辑和安装httpd-->
[root@centos01 ~]# ln -s /usr/local/httpd/bin/* /usr/local/bin/     <!--优化程序执行命令-->
[root@centos01 ~]# cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd <!--生成apahce服务-->
[root@centos01 ~]# chmod +x /etc/init.d/httpd       <!--添加执行权限-->
[root@centos01 ~]# vim /etc/init.d/httpd     <!--修改Apache服务控制文件-->
#chkconfig:35 80 20 
#description:apache 
[root@centos01 ~]# chkconfig --add httpd       <!--添加为系统服务-->
[root@centos01 ~]# chkconfig --level 35 httpd on  <!--设置开机自动启动-->
[root@centos01 ~]# vim /usr/local/httpd/conf/httpd.conf    <!--修改Apache主配置文件-->
98 ServerName 192.168.100.10:80     <!--修改服务器IP地址-->
[root@centos01 ~]# systemctl start httpd     <!--启动Apache服务-->
[root@centos01 ~]# netstat -anptu | grep 80   <!--监听Apache端口号-->
tcp6       0      0 :::80                   :::*                    LISTEN      53682/httpd         

赞(0)
未经允许不得转载:主机测评网 » 如何使用CentOS 7.4搭建Apache网站服务
分享到: 更多 (0)