源码编译安装apache httpd-2.4.51
安装环境:centos7
一、下载apache前,需先下载编译工具,使用如下命令:
yum install gcc gcc-c++ -y
注意:下载gcc gcc-c++ 需在yum网络源中下载,不能使用yum本地源,否则不能下载成功
二、下载源码包
注:如果已经有源码包的压缩包,可直接从Windows桌面拖入Linux终端设备的/usr/local/src目录下,然后在此目录下解压。
1、下载编译apr-1.7.0
下载地址:https://downloads.apache.org/apr/apr-1.7.0.tar.gz
注:当前目录为/usr/local/apr-1.7.0
# wget https://downloads.apache.org/apr/apr-1.7.0.tar.gz
# tar -xvf apr-1.7.0
# ./configure --prefix=/usr/local/apr
# make && make install
2、下载编译apr-util-1.6.1
下载地址:https://downloads.apache.org/apr/apr-util-1.6.1.tar.gz
注:当前目录为/usr/local/apr-util-1.6.1
# wget https://downloads.apache.org/apr/apr-util-1.6.1.tar.gz
# tar -xvf apr-util-1.6.1
# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
# make && make install
注:如果在执行完make && make install后出现如下错误
需执行以下命令 ,下载xml:
# yum install expat-devel -y
3、下载编译pcre-8.44
下载地址:ftp://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz
注:当前目录为/usr/local/pcre-8.44
# wget ftp://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz
# tar -xvf pcre-8.44
# ./configure --prefix=/usr/local/pcre
# make && make install
4、下载编译apache httpd-2.4.51
下载地址:http://archive.apache.org/dist/httpd/httpd-2.4.51.tar.gz
# wget http://archive.apache.org/dist/httpd/httpd-2.4.51.tar.gz
# tar -xvf httpd-2.4.51
# ./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre
# make && make install
三、开启服务
切换当前目录为/usr/local/apache/bin下
[root@localhost bin]# ./apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to s uppress this message
[root@localhost bin]# ip
ip ipcmk iprdump iptables
ip6tables ipcrm iprinit iptables-restore
ip6tables-restore ipcs iprsos iptables-save
ip6tables-save iprconfig iprupdate iptables-xml
ipcalc iprdbg ipset
[root@localhost bin]# iptables -F
[root@localhost bin]# ps -ef | grep httpd
root 59989 1 0 16:57 ? 00:00:00 /usr/local/apache/bin/httpd -k start
daemon 59990 59989 0 16:57 ? 00:00:00 /usr/local/apache/bin/httpd -k start
daemon 59991 59989 0 16:57 ? 00:00:00 /usr/local/apache/bin/httpd -k start
daemon 59992 59989 0 16:57 ? 00:00:00 /usr/local/apache/bin/httpd -k start
daemon 60076 59989 0 16:59 ? 00:00:00 /usr/local/apache/bin/httpd -k start
root 60118 59924 0 17:01 pts/1 00:00:00 grep --color=auto httpd
[root@localhost bin]# pwd
/usr/local/apache/bin
如果想要关闭服务:输入命令./apachectl stop 即可
四、编辑
如果想要编辑网页内容,在/usr/local/apache/htdocs目录下找到index.html文件,
# vim index.html
然后就可以修改了,如果想要查看话,在浏览器中输入本机IP地址就可以了!
搞定,收工!
点赞关注不迷路 小薛带你上高速