在liunx系统下面安装Apache

今天在liunx服务器上面安装了一个Apache,由于是第一次安装搞了一天在搞定于是将操作步骤记录下来,防止以后忘记。

  1. 查看liunx是什么版本?
    执行命令:lsb_release -a
    uname
    uname -r
    uname -a

  2. 下载Apache相关资源包。
    我们要下载的包有: httpd-2.4.23.tar.gz,apr-1.5.2.tar.gz,apr-util-1.5.4.tar.gz,pcre-8.39.tar.bz2
    Apache下载地址:http://httpd.apache.org/
    Apr下载地址:http://apr.apache.org/
    Pcre下载地址:
    http://sourceforge.net/projects/pcre/files/pcre/
    ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/

  3. 安装Apache
    3.1 执行命令:tar -zvxf httpd-2.4.23.tar.gz 解压得到httpd-2.4.23

    # tar –zvxf httpd-2.4.23.tar.gz
    # cd httpd-2.4.23
    # ./configure

报错:configure: error: APR not found. Please read the documentation.报这个错误的原因是没有安装APR.那么我们接下来安装APR.

3.2安装APR

# tar –zvxf apr-1.5.2.tar.gz
# cd apr-1.5.2
# ./configure --prefix=/home/apr
# make
# make install

注:上面的代码逐条执行,如果每条都执行成功的话并且在home目录下面创建了apr目录,那就恭喜你APR安装成功。–prefix指定安装路径,表示把程序安装到那个目录,如果目录不存在就会新建一个这样的目录。如果不指定prefix的话,则可执行文件默认放在/usr /local/bin,库文件默认放在/usr/local/lib,配置文件默认放在/usr/local/etc。其它的资源文件放在/usr /local/share。

3.3返回到httpd-2.4.23目录,执行如下命令:

./configure --prefix=/home/apache --with-apr=/home/apr

报错:checking for APR-util… no
configure: error: APR-util not found. Please read the documentation。意思是没有安装APR-util,那么我们接下来安装APR-util.

3.4安装APR-util

# tar –zvxf apr-util-1.5.4.tar.gz
# cd apr-util-1.5.4
# ./configure --prefix=/home/apr-util --with-apr=/home/apr/bin/apr-1-config
//执行./configure 执行这个文件时需要加上刚才安装完成的apr配置文件; 如果不加此配置文件会报找不到apr异常。
# make
# make install

注:逐条执行上面语句,如果都成功执行并且在home目录下面创建了apr-util目录则代表apr-util安装成功。

3.5再次返回到 httpd-2.4.23目录进行安装,执行命令

# ./configure --prefix=/home/apache --with-apr=/home/apr/bin/apr-1-config --with-apr-util=/home/apr-util/bin/apu-1-config

报错:configure: error: pcre-config for libpcre not found. PCRE is required and available,错误是没有安装PCRE,接下来安装PCRE

3.6安装PCRE

# bunzip2 -d pcre-8.39.tar.bz2
# tar -xvf  pcre-8.39.tar
# cd pcre-8.39
# ./configure --prefix=/home/pcre --with-apr=/home/apr/bin/apr-1-config
# make
# make install

注:逐条执行上面代码,如果没报错且在 home目录下面创建了pcre目录,则代表pcre安装成功。

3.7安装httpd服务,需要指定apr apr-util pcre这三个目录才能正常安装

#cd /home/httpd-2.4.23
#./configure --prefix=/home/httpd --with-apr=/home/apr/bin/apr-1-config --with-apr-util=/home/apr-util/bin/apu-1-config --with-pcre=/home/pcre/bin/pcre-config

3.8再次返回到httpd-2.4.23 目录进行安装,执行命令

# ./configure --prefix=/home/apache --with-apr=/home/apr/bin/apr-1-config --with-apr-util=/home/apr-util/bin/apu-1-config
执行过程中没有报错;继续执行make命令
# make
Make执行完成后执行make install
# make install
httpd服务安装完成

3.9进入安装目录,启动httpd服务

# cd /home/apache/bin/
# ./apachectl –k start|stop|restart 分别为启动停止 重启

netstat -ltnp 检查网络端口 验证默认的80是否打开了
这时查看我们的端口号是否打开了 结果:80打开了
打开浏览器 输入 http://IP地址
出现 it works 表示连接已经正常
到此安装完毕

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值