解压tar -zxvf httpd-2.4.17.tar.gz,完成之后,会在当前目录出现一个httpd-2.4.17目录,然后顺序执行如下命令
cd httpd-2.4.17
设置安装参数,命令如下:
./configure --prefix=/usr/local/apache --enable-module=so
其中prefix参数指明将apache安装到/usr/local/apache目录
提示以下错误:
configure: error: APR not found. Please read the documentation.
下载依赖包
1出现找不到apr
[iyunv@localhost local]# wget http://archive.apache.org/dist/apr/apr-1.4.5.tar.gz
解压
[iyunv@localhost local]# tar -zxvf apr-1.4.5.tar.gz
然后顺序执行如下命令
[iyunv@localhost local]# cd apr-1.4.5
[iyunv@localhost apr-1.4.5]# ./configure --prefix=/usr/local/apr
[iyunv@localhost apr-1.4.5]# make
[iyunv@localhost apr-1.4.5]# make install
2,后面可能还会出现找不到apr-util
[iyunv@localhost local]# wget http://archive.apache.org/dist/apr/apr-util-1.3.12.tar.gz
解压
[iyunv@localhost local]# tar -zxvf apr-util-1.3.12.tar.gz
然后顺序执行如下命令
[iyunv@localhost local]# cd apr-util-1.3.12
[iyunv@localhost apr-util-1.3.12]#./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[iyunv@localhost apr-util-1.3.12]# make
[iyunv@localhost apr-util-1.3.12]# make install
3,后面可能还会出现找不到pcre
[iyunv@localhost local]# wget http://sourceforge.net/projects/pcre/files/pcre/8.37/pcre-8.37.tar.gz
解压
[iyunv@localhost local]# tar -zxvf pcre-8.37.tar.gz
然后顺序执行如下命令
[iyunv@localhost local]# cd pcre-8.37
[iyunv@iZ94v4g54vuZ pcre-8.37]# ./configure --prefix=/usr/local/pcre
[iyunv@iZ94v4g54vuZ pcre-8.37]# make
[iyunv@iZ94v4g54vuZ pcre-8.37]# make install
设置安装参数,命令如下:
./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre
最后编译,安装;顺序执行如下命令:
make
make install
启动 apache 服务器
进去apache 安装目录(/usr/local/apache)下 cd bin
[iyunv@iZ94v4g54vuZ bin]# ./apachectl start
如果报下面错误
httpd: Could not reliably determine the server's fully qualified domain name
解决方案:在conf/http.conf文件里面加上
ServerName localhost:80 (要和Listen 80的端口一致)
访问 http://ip:端口
如果页面显示“It works!”,即表示apache已安装并启动成功。
停止apache 服务器
[iyunv@iZ94v4g54vuZ bin]# ./apachectl stop
查看apache服务占用的端口
ps aux |grep apache