CentOS 7 编译安装httpd-2.4.17

简介: 环境说明VMware 12 中 CentOS 7 x64 4cpu 2G内存 环境中已经安装了《CentOS 7 编译安装 MySQL-5.

环境说明

VMware 12 中 CentOS 7 x64 4cpu 2G内存
环境中已经安装了《CentOS 7 编译安装 MySQL-5.7.9》《CentOS 7 编译安装PHP7

配置防火墙和开放端口

参考CentOS 7 编译安装 MySQL-5.7.9》中的 “配置防火墙和开放端口”

编译安装httpd所需依赖

下载
apr-1.5.2.tar.gz
apr-util-1.5.4.tar.gz
httpd-2.4.17.tar.gz
pcre-8.38.tar.gz
上传到/root/目录

######编译安装apr-1.5.2.tar.gz
[root@localhost ~]# tar zxf apr-1.5.2.tar.gz && cd apr-1.5.2
[root@localhost apr-1.5.2]# yum install gcc libtools -y
[root@localhost apr-1.5.2]# ./configure --prefix=/usr/local/apr
[root@localhost apr-1.5.2]# make && make install
[root@localhost apr-1.5.2]# cd .. && rm -rf ../apr-1.5.2*

######编译安装apr-util-1.5.4.tar.gz
[root@localhost ~]# tar zxf apr-util-1.5.4.tar.gz && cd apr-util-1.5.4
[root@localhost apr-util-1.5.4]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/
[root@localhost apr-util-1.5.4]# make && make install
[root@localhost apr-util-1.5.4]# cd .. && rm -rf apr-util-1.5.4*

######编译安装pcre-8.38.tar.gz
[root@localhost ~]# tar zxf pcre-8.38.tar.gz && cd pcre-8.38
[root@localhost pcre-8.38]# ./configure --prefix=/usr/local/pcre
[root@localhost pcre-8.38]# make && make install
[root@localhost pcre-8.38]# cd .. && rm -rf pcre-8.38*

编译安装httpd-2.4.17

[root@localhost ~]# tar zxf httpd-2.4.17.tar.gz && cd httpd-2.4.17
[root@localhost httpd-2.4.17]# ./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre
[root@localhost httpd-2.4.17]# make && make install
[root@localhost httpd-2.4.17]# cd .. && rm -rf httpd-2.4.17*

配置Apache

设置Apache开机启动,添加Apache到Linux服务

[root@localhost init.d]# vi /usr/local/apache/conf/httpd.conf
1.搜索ServerName www.example.com:80 去掉前面的注释
2.修改DocumentRoot到/home/htdocs,以及这一行下面的一句中的<Directory到/home/htdocs
这个是www的根目录设置

[root@localhost apache]# cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
[root@localhost init.d]# vi httpd 
在第一行下添加如下两行文字
# Comments to support chkconfig on RedHat Linux
# chkconfig: 2345 90 90
# description:http server

注册该服务 
[root@localhost init.d]# chkconfig --add httpd  #所有开机模式下自启动
[root@localhost init.d]# chkconfig httpd on  #345开机模式下自启动

运行Apache

[root@localhost init.d]# service httpd start
######查看运行状态
[root@localhost init.d]# ps -aux | grep httpd
在主机浏览器输入linux的ip
出现
It works!

参考网址

http://linux.it.net.cn/CentOS/server/webserver/2015/0320/14007.html

目录
相关文章
|
5月前
|
Linux 开发工具 C语言
Centos8下编译安装最新版ffmpeg解决方案(含Centos8换源阿里云)
Centos8下编译安装最新版ffmpeg解决方案(含Centos8换源阿里云)
856 3
|
5月前
|
Linux 网络安全 Apache
Centos下操作Apache httpd
Centos下操作Apache httpd
120 0
|
4月前
|
Linux 数据库管理 Python
CentOS7编译安装Python3.10(含OpenSSL1.1.1安装),创建虚拟环境,运行Django项目(含sqlite版本报错)
CentOS7编译安装Python3.10(含OpenSSL1.1.1安装),创建虚拟环境,运行Django项目(含sqlite版本报错)
676 4
|
5月前
|
Linux 应用服务中间件 网络安全
CentOS7搭建本地离线局域网yum源(Httpd/Nginx+yum)
CentOS7搭建本地离线局域网yum源(Httpd/Nginx+yum)
1543 0
|
17天前
|
Linux 网络安全 Apache
CentOS 7.2配置Apache服务httpd(上)
CentOS 7.2配置Apache服务httpd(上)
133 1
|
14天前
|
安全 Linux 编译器
Centos 7.9如何使用源码编译安装curl最新版本
通过上述步骤,您就能在CentOS 7.9上成功地从源代码编译并安装curl的最新版本。这种方法不仅提供了灵活性,允许您定制编译选项,还确保了软件的最新功能和安全更新得到应用。
26 1
|
17天前
|
Linux PHP Apache
CentOS 7.2配置Apache服务httpd(下)
CentOS 7.2配置Apache服务httpd(下)
44 1
|
2月前
|
Linux 开发工具 C语言
centos7编译安装python3
centos7编译安装python3
|
2月前
|
分布式计算 Java Hadoop
centos7编译安装Hadoop3
centos7编译安装Hadoop3
|
4月前
|
关系型数据库 MySQL Linux
centos linux mysql 5.5脚本全自动源码包 编译安装
centos linux mysql 5.5脚本全自动源码包 编译安装
54 0