CentOS6上编译安装httpd2.4 详解(2)

Apache-sebsite

将应用程序添加到环境变量中 # 添加环境变量  [root@localhost httpd-2.4.27]# echo 'PATH=/app/httpd24/bin:$PATH' > /etc/profile.d/http24.sh    #使环境变量生效  [root@localhost httpd-2.4.27]# . /etc/profile.d/http24.sh 编写服务的启用脚本

CentOS 6 中,服务器的启动脚本存放于/etc/init.d/httpd。当然我们自己编写服务的启动脚本有些困难,我们可以参考以前安装过的服务脚本略加修改。

将这个文件/etc/init.d/httpd 改名为/etc/init.d/httpd24,然后修改如下内容

编写启动脚本

将服务添加到开机启动,并开启服务 # 将服务添加到服务列表  [root@localhost init.d]# chkconfig --add httpd24 # 将服务设置为开机启动  [root@localhost init.d]# chkconfig httpd24 on  # 启动服务    [root@localhost init.d]# service httpd24 start

在启动服务的过程中有可能会提示以下错误 ,这是提示没有创建网站的根目录。所以我们去创建一下。

[root@localhost init.d]# service httpd24 start Starting httpd: AH00526: Syntax error on line 225 of /app/httpd24/conf/httpd.conf: DocumentRoot '/app/website' is not a directory, or is not readable                                                                                                                    [FAILED] 创建网站主页,并进行测试 # 创建网站的根目录  [root@localhost init.d]# mkdir /app/website  # 建立网站主页,用于测试路径    [root@localhost init.d]# echo /app/website/index.html > /app/website/index.html

经过上述步骤,基本上就能够在CentOS 6 上成功的安装和运行HTTP 2.4了,如果还有什么疑问,可以留言一起套路。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/5f13e74c3da3ede7855de1bb85e65b76.html