安装软件运行基础
apr
下载地址
下载地址
[root@localhost soft]# wget -i http://www-eu.apache.org/dist//apr/apr-1.6.3.tar.gz
解压编译安装
[root@localhost soft]# tar -zxf apr-1.6.3.tar.gz && apr-1.6.3
[root@localhost apr-1.6.3]# ./configure --prefix=/usr/local/apr
[root@localhost apr-1.6.3]# make && make install
apr-util
下载地址
下载地址
[root@localhost soft]# wget -i http://www-eu.apache.org/dist//apr/apr-util-1.6.1.tar.gz
解压编译安装
[root@localhost soft]# tar -zxf apr-util-1.6.1.tar.gz && cd apr-util-1.6.1
[root@localhost apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@localhost apr-util-1.6.1]# make && make install
pcre
下载地址
下载地址
[root@localhost soft]# wget -i https://ftp.pcre.org/pub/pcre/pcre-8.41.tar.gz
解压编译安装
[root@localhost soft]# tar -zxf pcre-8.41.tar.gz && cd pcre-8.41
[root@localhost pcre-8.41]# ./configure --prefix=/usr/local/pcre
[root@localhost pcre-8.41]# make && make install
安装Apache2
下载地址
下载地址
[root@localhost soft]# wget -i http://www-us.apache.org/dist//httpd/httpd-2.4.29.tar.bz2
解压编译安装
[root@localhost soft]# tar -jxf httpd-2.4.29.tar.bz2 && cd httpd-2.4.29
[root@localhost httpd-2.4.29]# ./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre
[root@localhost httpd-2.4.29]# make && make install
配置Apache2
修改配置文件
[root@localhost soft]# vim /usr/local/apache2/conf/httpd.conf
Listen 8088
ServerName www.apache-host.dev:8088
DocumentRoot "/www/apache-host"
<Directory "/www/apache-host">
设置Apache2为Linux服务并实现开机自启动
添加Apache2配置文件
apachectl
到linux服务
[root@localhost soft]# cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd
[root@localhost soft]# chkconfig --add httpd
[root@localhost soft]# chkconfig httpd on
检测系统服务 httpd
是否启动成功
[root@localhost soft]# chkconfig --list | grep httpd
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.
If you want to list systemd services use 'systemctl list-unit-files'.
To see services enabled on particular target use
'systemctl list-dependencies [target]'.
httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
可见服务已经在 第2 到 第5 运行等级打开, 说明系统服务
httpd
已正常开启开机启动
禁用系统服务 httpd
[root@localhost soft]# chkconfig httpd off
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.
If you want to list systemd services use 'systemctl list-unit-files'.
To see services enabled on particular target use
'systemctl list-dependencies [target]'.
httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
可见服务已经在 第1 到 第6 运行等级关闭, 说明系统服务
httpd
已正常关闭开机启动功能
开启系统服务Apache2
[root@localhost soft]# systemctl start httpd.service
查看系统服务运行状态
[root@localhost soft]# systemctl status httpd.service
验证是否成功安装Apache2
通过curl命令行检测是否安装成功
[root@localhost soft]# curl -I "http://127.0.0.1:8088"
HTTP/1.1 200 OK
Date: Sun, 31 Dec 2017 18:23:24 GMT
Server: Apache/2.4.29 (Unix)
Content-Type: text/html;charset=ISO-8859-1
通过浏览器检测是否安装成功