安装依赖包:
$ rpm -ivh apr-1.4.8-3.el7.x86_64.rpm
$ rpm -ivh apr-devel-1.4.8-3.el7.x86_64.rpm
$ rpm -ivh cyrus-sasl-devel-2.1.26-20.el7_2.x86_64.rpm
$ rpm -ivh expat-devel-2.1.0-8.el7.x86_64.rpm
$ rpm -ivh libdb-devel-5.3.21-19.el7.x86_64.rpm
$ rpm -ivh openldap-devel-2.4.40-13.el7.x86_64.rpm
$ rpm -ivh apr-util-devel-1.5.2-6.el7.x86_64.rpm
$ rpm -ivh apr-util-1.5.2-6.el7.x86_64.rpm
$ rpm -ivh pcre-devel-8.32-15.el7_2.1.x86_64.rpm
$ rpm -ivh pcre-8.32-15.el7_2.1.x86_64.rpm
apache源码编译及安装
解包
$ tar zxf httpd-2.4.25.tar.gz -C /usr/src
配置
$ ./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi
编译及安装
$ make && make install
$ ls /usr/local/httpd
执行优化路径
$ ln -s /usr/local/httpd/bin/* /usr/local/bin
$ ls -l /usr/local/bin/httpd /usr/local/bin/apachectl
b)启动服务后,客户端通过http://IP能访问默认的网站。
$ vim /lib/systemd/system/httpd.service
[Unit]
Description=The Apache HTTP Server
After=network.target
[Service]
Type=forking
PIDFile=/usr/local/httpd/logs/httpd.pid
ExecStart=/usr/local/httpd/bin/apachectl $OPTIONS
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=graphical.target
开启apache服务
$ systemctl start httpd.service