cetos7.4 下编译安装:
Apache 是世界使用排名第一的 web 服务器软件它可以运行在几乎所有广泛使用的计算机平台上, 由于其跨平台和安全性被广泛使用, 是最流行的 Web 服务器端软件之一它快速可靠并且可通过简单的 API 扩充, 将 Perl/Python 等解释器编译到服务器中同时 Apache 音译为阿帕奇!(引用网络中的词)
需要源码编译安装的软件包
- httpd-2.4.28.tar.gz #Apache 主程序包
- apr-1.5.2.tar.gz #Apache 依赖包
- apr-util-1.5.4.tar.gz #Apache 依赖包
- pcre-8.41.tar.gz #Apache 依赖包
下载源码安装包
- http://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.28.tar.gz http://archive.apache.org/dist/apr/apr-1.6.2.tar.gz
- http://archive.apache.org/dist/apr/apr-util-1.6.0.tar.gz
- ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.tar.gz
首先下载最新的源码包
安装之前请先安装 makegccopenssl 等编译工具和开发包
[root@localhost ~]# yum -y install make gcc gcc-c++ openssl openssl-devel expat-devel
安装依赖包: apr-1.5.2.tar.gz
- [root@localhost ~]# tar xf apr-1.5.2.tar.gz
- [root@localhost ~]# cd apr-1.5.2
- [root@localhost apr-1.5.2]# ./configure --prefix=/usr/local/apr && make && make install
编译安装依赖包 apr-util-1.5.4.tar.gz
- [root@localhost ~]# tar xf apr-util-1.5.4.tar.gz
- [root@localhost ~]# cd apr-util-1.5.4
- [root@localhost apr-util-1.5.4]# ./configure --prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr/bin/apr-1-config && make && make install
编译安装依赖包 pcre-8.41.tar.gz
- [root@localhost pcre-8.41]# tar xf pcre-8.41.tar.gz
- [root@localhost ~]# cd pcre-8.41
- [root@localhost pcre-8.41]# ./configure --prefix=/usr/local/pcre && make && make install
编译安装 apache
- [root@localhost ~]# tar xf httpd-2.4.28.tar.gz -C /usr/local/src/
- [root@localhost ~]# cd /usr/local/src/httpd-2.4.28/
- [root@localhost httpd-2.4.28]# ./configure --prefix=/usr/local/apache --enable-so --enable-rewrite --enable-ssl --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre/ && make && make install
注:
- --enable-so #支持动态加载模块
- --enable-rewrite #支持网站地址重写
- --enable-ssl #支持 ssl 加密
- --with-apr=/usr/local/apr #关联 apr
- --with-apr-util=/usr/local/apr-util #关联 apr-util
- --with-pcre=/usr/local/pcre #关联 pcre
- --libdir=/usr/lib64 #关联库文件
配置文件
- [root@localhost httpd-2.4.28]# ls /usr/local/apache/conf/httpd.conf
- /usr/local/apache/conf/httpd.conf
网站根目录
- [root@localhost httpd-2.4.28]# ls /usr/local/apache/htdocs/
- index.html
生成启动脚本
- [root@localhost httpd-2.4.28]# cp /usr/local/apache/bin/apachectl /etc/init.d
- [root@localhost httpd-2.4.28]# chmod +x /etc/init.d/apachectl
写个 apache 系统服务脚本, 以 754 的权限保存此文件
- [Unit]
- Description=apache
- After=network.target
- [Service]
- Type=forking
- ExecStart=/etc/init.d/apachectl start
- ExecReload=/etc/init.d/apachectl restart
- ExecStop=/etc/init.d/apachectl stop
- PrivateTmp=true
- [Install]
- WantedBy=multi-user.target
启动 apache 报错:
- [root@localhost httpd - 2.4.28]# / etc / init.d / apachectl restart AH00558: httpd: Could not reliably determine the servers fully qualified domain name,
- using localhost.localdomain.Set the ServerName directive globally to suppress this message
解决:
[root@localhost httpd-2.4.28]# vim /usr/local/apache/conf/httpd.conf
改成:
ServerName 192.168.140.138(服务器 IP):80
启动 apache
/etc/init.d/apachectl start
测试:
apache 编译安装
来源: http://www.bubuko.com/infodetail-2491186.html