Linu下Apache(httpd)的安装、配置

一、检查是否已装

ps -ef|grep httpd

二、软件下载

1. Apache HTTP Server
地址:http://httpd.apache.org/download.cgi#apache24

2. APR 和 APR-Util
地址:http://apr.apache.org/download.cgi

3. PCRE
地址:https://sourceforge.net/projects/pcre/files/pcre/
三、安装

1、如果没有安装gcc/gcc-c++的话必须安装

yum install gcc-c++

gcc -v

yum list

2、安装APR、APR-Util、PCRE、Apache Http Server

  1)将这些都安装在./usr/local中,先mkdir目录如下:

  mkdir /usr/local/httpd

mkdir /usr/local/apr

mkdir /usr/local/apr-util

mkdir /usr/local/pcre

2)然后按照步骤:

mkdir /usr/soft

              cd soft

     tar -zxf apr-1.5.2.tar.gz

tar -zxf apr-util-1.5.4.tar.gz

tar -zxf pcre-8.38.tar.gz

tar -zxf httpd-2.4.18.tar.gz

=============================================

               cd apr-1.5.2

                ./configure --prefix=/usr/local/apr

                make

 make install

=============================================

cd ../apr-util-1.5.4

./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config

    make

    make install

==============================================

编译apr-util-1.6.0的时候遇到一个错误

xml/apr_xml.c:35:19: fatal error: expat.h: No such file or directory

解决方法:yum install expat-devel安装该库,安装完再次编译,就OK了

===============================================

cd ../pcre-8.38

./configure --prefix=/usr/local/pcre --with-apr=/usr/local/apr/bin/apr-1-config

     make

    make install

================================================

cd ../httpd-2.4.18

./configure --prefix=/usr/local/httpd --with-pcre=/usr/local/pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util

     make

    make install

================================================

3、安装

## 先yum list看看有没有你可以的包

yum list httpd

## 如果有的话,比如我用x86_64版,就可以安装

yum install httpd.x86_64

4、修改配置文件

cd  /usr/local/httpd/conf

              vi  httpd.conf

             修改:Listen 31000【端口号】

                        ServerName 123.206.9.227:31000

5、启动:

cd  /usr/local/httpd/bin

./apachectl start

./apachectl stop

./apachectl restart

6、访问:http://ip:port/ 如果页面显示 “It works!” ,即表示apache已安装并启动成功。

       7、目录创建软连接

ln -s /export/client/  /usr/local/httpd/htdocs/download

8、完成

转载于:https://www.cnblogs.com/cherish010/p/11592355.html