安装 Apache 参考网址
https://www.cnblogs.com/xdouby/p/6406873.html
第一步下载
网址
例如:
wget http://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.37.tar.bz2
错误提示
- xml/apr_xml.c:35:19: fatal error: expat.h: No such file or directory
- yum -y install expat-devel
版本不兼容
https://blog.csdn.net/gouhexiong1989/article/details/78694037?tdsourcetag=s_pctim_aiomsg
见以网址错误提示
结论删除 1.6 版本的 apr 和 apr-util, 重新下载 1.5 版本重新编译和安装.
重新下载
- http://archive.apache.org/dist/apr/
- http://archive.apache.org/dist/apr/apr-1.5.2.tar.gz
- http://archive.apache.org/dist/apr/apr-util-1.5.4.tar.gz
删除旧版本的 apr 和 apr-util
- rm -rf /usr/local/apr
- rm -rf /usr/local/apr-util
开始安装
首先安装编译环境
yum install -y gcc gcc-c++
把压缩包放到 root 下
第一步: 安装 apr
- tar -xvf apr-1.5.2.tar.gz
- cd apr-1.5.2
- ./configure --prefix=/usr/local/apr
会出现错误要下载 gcc
- yum -y install gcc(Ubuntu 是 apt-get,-y 是一直 yes 不用自己选)
- make -j
- make install
第二步: 安装 apr-util
- tar -xvf apr-util-1.5.4.tar.gz
- cd apr-util-1.5.4
- ./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config
- make -j
- make install
第三步: 安装 pcre
- tar -xvf pcre-8.42.tar.gz
- ./configure --prefix=/usr/local/pcre
在之前会报错, 没有 c++, 则需要装 apt-get(CentOS 用 yum) install gcc-c++
- make -j
- make install
第四步: 安装 openssl
- tar -xvf openssl-1.0.2q.tar.gz
- cd openssl-1.0.2q
- ./config --prefix=/usr/local/openssl
- make -j
- make install
- cd /usr/local
- ln -s openssl ssl
在 / etc/ld.so.conf 文件的最后面, 添加如下内容:
/usr/local/openssl/lib
执行 ldconfig
添加 OPESSL 的环境变量, 在 / etc/profile 的最后一行, 添加:
- export OPENSSL=/usr/local/openssl/bin
- export PATH=$OPENSSL:$PATH:$HOME/bin
执行 source /etc/profile
第五步: 安装 httpd
- tar -xvf httpd-2.4.37.tar.gz
- cd httpd-2.4.37
- ./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-
- util=/usr/local/apr-util --with-pcre=/usr/local/pcre
如果上述错误, 则执行第四步, 否则不必要
- make -j
- make install
第六步 (不必要): 启动服务
添加防火墙配置
- /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
- firewall-cmd -reload
- netstat -apnt|grep 80
注: Ubuntu:ufw disable
管理 apache 服务
apache 默认占用 80 端口, 所以如果有应用占用 80 这个端口, 就要注意会存在端口冲突问题.
? 启动 Apache:/usr/local/apache2/bin/apachectl start
来源: http://www.bubuko.com/infodetail-2960771.html