Centos 7环境下Apache 2.4服务器搭建

公司内部要装管理系统,所以需要先搭建apache环境。
用的系统是Centos 7。
1,准备apache环境包和关联包:
这里写图片描述
利用psftp上传到服务器,我新建了一个目录,位置为usr/local/bin/soft/apache_linux,将上述包放在此目录下。

2,准备GCC G++等相关环境。
在centos系统中,yum是默认配置,运行以下命令来自动配置编译环境。
# yum -y install gcc
# yum -y install gcc-c++

3,解压并安装apache环境包以及关联包
这里我是将安装目录定在/work/installed里。
—->3.1安装 apr
下载地址:http://apr.apache.org/download.cgi
[root@localhost:/work/soft/apache]# tar jxvf apr-1.5.2.tar.bz2
[root@localhost:/work/soft/apache/apr-1.5.2]# ./configure –prefix=/work/installed/apr
[root@localhost:/work/soft/apache/apr-1.5.2]# make
[root@localhost:/work/soft/apache/apr-1.5.2]# make install

—->3.2安装apr-util
下载地址:http://apr.apache.org/download.cgi
[root@localhost:/work/soft/apache]# tar jxvf apr-util-1.5.4.tar.bz2
[root@@localhost:/work/soft/apache/apr-util-1.5.4]# ./configure –prefix=/work/installed/apr-util –with-apr=/work/installed/apr
[root@@localhost:/work/soft/apache/apr-util-1.5.4]# make

—->3.3安装 pcre
下载地址:http://pcre.org/
[root@localhost:/work/soft/apache]# tar jxvf pcre-8.36.tar.bz2
[root@@localhost:/work/soft/apache/pcre-8.36]# ./configure –prefix=/work/installed/pcre
[root@@localhost:/work/soft/apache/pcre-8.36]# make
[root@@localhost:/work/soft/apache/pcre-8.36]# make install

—->3.4安装apache
下载地址:http://httpd.apache.org/
[root@localhost:/work/soft/apache]# tar zxvf httpd-2.4.12.tar.gz
[root@@localhost:/work/soft/apache/httpd-2.4.12]# ./configure –prefix=/work/installed/apache –with-apr=/work/installed/apr –with-apr-util=/work/installed/apr-util –with-pcre=/work/installed/pcre
[root@@localhost:/work/soft/apache/httpd-2.4.12]# make
[root@@localhost:/work/soft/apache/httpd-2.4.12]# make install

注意,如果安装过程出现类似于:configure: error: You need a C++ compiler for C++ support等问题,请确保第二步骤中gcc g++等环境安装正确。

4,安装完成后,进入根目录下“work/installed/apache/conf/”目录中,找到httpd.conf文件,用vi打开修改:
# vi httpd.conf
找到# ServerName www.example.com:80,改为 ServerName localhost:80,保存退出。

5,如果本机服务器IP为192.168.2.79,那么在本机浏览器上输入192.168.2.79就会出现:
这里写图片描述
但是同局域网的其他机器则不能访问,问题是服务器的防火墙屏蔽了80端口,我们需要关闭防火墙。
CentOS 7默认使用的是firewall作为防火墙(7版本之前的防火墙用的是iptables)
# systemctl start firewalld.service————->#启动firewall
# systemctl stop firewalld.service————->#停止firewall
# systemctl disable firewalld.service————->#禁止firewall开机启动
这样,局域网内其他机器也能访问了,至此apache2.4服务器搭建完成。

注1:服务器命令,在根目录执行:
# /work/installed/apache/bin/apachectl stop————->关闭服务器
# /work/installed/apache/bin/apachectl start————->启动服务器
# /work/installed/apache/bin/apachectl restart———–>重启服务器
若出现:“AH00558: httpd: Could not reliably determine the server’s fully qualified domain name, using localhost.localdomain. Set the ‘ServerName’ directive globally to suppress this message”警告,请确认httpd.conf中# ServerName www.example.com:80已经正确修改为 ServerName localhost:80

注2:每次服务器重启后,记得还要启动mysql服务:
# service mysql start

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值