CentOS Apache 安装 配置 启动
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS Apache 安装 配置 启动相关的知识,希望对你有一定的参考价值。
下载Apache安装包 httpd-2.4.23.tar.gz
下载地址:http://apache.fayea.com/httpd/
Apache 安装要求
必须安装APR、APR-Util、PCRE,gcc-c++等包
编译命令:(除了指定Apache的安装目录外,还要安装apr、apr-util、pcre,并指定参数)
[[email protected] software]# tar -zxvf httpd-2.4.23.tar.gz [[email protected] software]# cd httpd-2.4.23 [[email protected] httpd-2.4.23]# ./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre checking for chosen layout... Apache checking for working mkdir -p... yes checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking target system type... x86_64-unknown-linux-gnu configure: configure: Configuring Apache Portable Runtime library... configure: checking for APR... configure: error: the --with-apr parameter is incorrect. It must specify an install prefix, a build directory, or an apr-config file. [[email protected] httpd-2.4.23]#
在编译Apache时出现了问题
http://apr.apache.org/download.cgi 下载apr-1.5.2.tar.gz、apr-util-1.5.4.tar.gz
http://www.pcre.org/ 官网
https://sourceforge.net/projects/pcre/files/pcre/ 选择pcre下载,不用pcre2
下载最新版本pcre-8.39.tar.gz
解决apr问题
[[email protected] software]# tar -zxvf apr-1.5.2.tar.gz [[email protected] software]# cd apr-1.5.2/ [[email protected] apr-1.5.2]# ./configure --prefix=/usr/local/apr [[email protected] apr-1.5.2]# make [[email protected] apr-1.5.2]# make install
解决APR-util问题
[[email protected] software]# tar -zxvf apr-util-1.5.4.tar.gz [[email protected] software]# cd apr-util-1.5.4/ [[email protected] apr-util-1.5.4]# ./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config [[email protected] apr-util-1.5.4]# make [[email protected] apr-util-1.5.4]# make install
解决pcre-config问题
[[email protected] software]# tar -zxvf pcre-8.39.tar.gz [[email protected] software]# cd pcre-8.39 [[email protected] pcre-8.39]# ./configure --prefix=/usr/local/pcre [[email protected] pcre-8.39]# make [[email protected] pcre-8.39]# make install
再次编译httpd-2.4.23:
[[email protected] software]# cd httpd-2.4.23 [[email protected] httpd-2.4.23]# ./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre [[email protected] httpd-2.4.23]# make [[email protected] httpd-2.4.23]# make install
启动Apache:/usr/local/apache2/bin/apachectl start
停止Apache:/usr/local/apache2/bin/apachectl stop
重启Apache:/usr/local/apache2/bin/apachectl restart
网站放在/usr/local/apache2/htdocs目录下
在IE中通过http://localhost:80,如果看到页面中显示“It works!”字样,则代表Apache验证通过。如果网站的index后缀是php格式的,则要修改httpd.conf配置文件(/usr/local/apache2/conf),在DirectoryIndex增加 index.php。
# # DirectoryIndex: sets the file that Apache will serve if a directory # is requested. # <IfModule dir_module> DirectoryIndex index.html index.php </IfModule>
本文出自 “刘振” 博客,转载请与作者联系!
以上是关于CentOS Apache 安装 配置 启动的主要内容,如果未能解决你的问题,请参考以下文章
CentOS 7 Apache 2.4.23 安装 配置 启动
Centos7安装配置Apache+PHP+Mysql+phpmyadmin