Linux 安装 Apache 及配置运行
0:前言1:安装apr2:安装expat-devel3:安装apr-util4:安装apache5:运行apache--------------------------------------------------------------notice 1:关于AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using . Set the 'ServerName' directive globally to suppress this message;及自定义端口notice 2:关于防火墙,无法访问notice 3:浏览器访问
0:前言需要安装的软件比较多,比如apr,apr-util等安装完毕后才可以正确安装运行apache,此外apache依赖于apr-util,apr-util依赖于apr,而apr-util又依赖于expat-devel。
1:安装aprwget https://dlcdn.apache.org//apr/apr-1.7.0.tar.gz tar -xzvf apr-1.7.0.tar.gz cd apr-1.7.0 ./configue --prefix=/usr/local/apr make make install cd ..2:安装expat-devel
yum install expat-devel3:安装apr-util
wget https://dlcdn.apache.org//apr/apr-util-1.6.1.tar.gz tar -xzvf apr-util-1.6.1.tar.gz cd apr-util-1.6.1 ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config make make install cd ..4:安装apache
wget https://dlcdn.apache.org//httpd/httpd-2.4.52.tar.gz tar -xzvf httpd-2.4.52.tar.gz cd httpd-2.4.52 ./configure --prefix=/usr/local/apache --with-apr-util=/usr/local/apr-util make make install cd ..5:运行apache
/usr/local/apache/bin/apachectl start-------------------------------------------------------------- notice 1:关于AH00558: httpd: Could not reliably determine the server’s fully qualified domain name, using . Set the ‘ServerName’ directive globally to suppress this message;及自定义端口
这一步是没有设置服务器的完全限定域名,比如 www.aaa.com 就是你的服务器域名,你需要在ServerName配置上。在不配置的情况下并不影响程序正常执行,如有需要可以去除该提醒。
执行:
vi /usr/local/apache/conf/httpd.conf
如图:将前面的 # 号去掉就行。另外 www.example.com 用于示例域名。可以在没有正式域名的情况下使用此域名。
此外,你也可以在此步修改自定义端口号:
修改端口号:Listen 5555(自定义域名)
notice 2:关于防火墙,无法访问如果是购买的云服务器,注意开启服务器防火墙,不然无法访问。
notice 3:浏览器访问1.11.111.11:5555(这里1.11.111.11是你的服务器域名,切记开启该端口的防火墙)
当浏览器出现 It works! 证明运行成功。



