httpd安装与配置(centos7) 2

承接上文

1./usr/local/apache/bin/apachectl start启动apache,出现错误

解决方法:(进入安装目录,编辑httpd.conf文件,添加ServerName localhost:80或者去掉ServerName www.example前面的#号,这里添加本地ip)

重启后用浏览器访问172.16.121.67时提示It works!

 2.添加环境变量使httpd可以任意访问

vim /etc/profile

在"/etc/profile"文件最后添加export PATH=$PATH:/usr/local/apache/bin

报错Failed to start httpd.service: Unit not found.

 将apachectl文件拷贝到 /etc/rc.d/init.d 中,然后在相应的启动级别如3,5中加入链接即可

 cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd # 复制到init.d 并重命名为httpd

ln -s /etc/rc.d/init.d/httpd /etc/rc.d/rc3.d/S61httpd

还是报错后执行命令

systemctl daemon-reload

原文地址:https://www.cnblogs.com/yigehezi/p/10560335.html