CentOS 7 编译安装httpd-2.4.17

来源:互联网 发布:p2p网络借款平台 编辑:程序博客网 时间:2024/06/05 08:14

环境说明

VMware 12 中 CentOS 7 x64 4cpu 2G内存
环境中已经安装了《CentOS 7 编译安装 MySQL-5.7.9》《CentOS 7 编译安装PHP7》

配置防火墙和开放端口

参考CentOS 7 编译安装 MySQL-5.7.9》中的 “配置防火墙和开放端口”

编译安装httpd所需依赖

下载
apr-1.5.2.tar.gz
apr-util-1.5.4.tar.gz
httpd-2.4.17.tar.gz
pcre-8.38.tar.gz
上传到/root/目录

######编译安装apr-1.5.2.tar.gz[root@localhost ~]# tar zxf apr-1.5.2.tar.gz && cd apr-1.5.2[root@localhost apr-1.5.2]# yum install gcc libtools -y[root@localhost apr-1.5.2]# ./configure --prefix=/usr/local/apr[root@localhost apr-1.5.2]# make && make install[root@localhost apr-1.5.2]# cd .. && rm -rf ../apr-1.5.2*######编译安装apr-util-1.5.4.tar.gz[root@localhost ~]# tar zxf apr-util-1.5.4.tar.gz && cd apr-util-1.5.4[root@localhost apr-util-1.5.4]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/[root@localhost apr-util-1.5.4]# make && make install[root@localhost apr-util-1.5.4]# cd .. && rm -rf apr-util-1.5.4*######编译安装pcre-8.38.tar.gz[root@localhost ~]# tar zxf pcre-8.38.tar.gz && cd pcre-8.38[root@localhost pcre-8.38]# ./configure --prefix=/usr/local/pcre[root@localhost pcre-8.38]# make && make install[root@localhost pcre-8.38]# cd .. && rm -rf pcre-8.38*

编译安装httpd-2.4.17

[root@localhost ~]# tar zxf httpd-2.4.17.tar.gz && cd httpd-2.4.17[root@localhost httpd-2.4.17]# ./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre[root@localhost httpd-2.4.17]# make && make install[root@localhost httpd-2.4.17]# cd .. && rm -rf httpd-2.4.17*

配置Apache

设置Apache开机启动,添加Apache到Linux服务

[root@localhost init.d]# vi /usr/local/apache/conf/httpd.conf1.搜索ServerName www.example.com:80 去掉前面的注释2.修改DocumentRoot到/home/htdocs,以及这一行下面的一句中的<Directory到/home/htdocs这个是www的根目录设置[root@localhost apache]# cp /usr/local/apache/bin/apachectl /etc/init.d/httpd[root@localhost init.d]# vi httpd 在第一行下添加如下两行文字# Comments to support chkconfig on RedHat Linux# chkconfig: 2345 90 90# description:http server注册该服务 [root@localhost init.d]# chkconfig --add httpd  #所有开机模式下自启动[root@localhost init.d]# chkconfig httpd on  #345开机模式下自启动

运行Apache

[root@localhost init.d]# service httpd start######查看运行状态[root@localhost init.d]# ps -aux | grep httpd在主机浏览器输入linux的ip出现It works!

参考网址

http://linux.it.net.cn/CentOS/server/webserver/2015/0320/14007.html

1 0
原创粉丝点击