Linux下Apache的安装与配置
本文安装的httpd版本为httpd 2.4.4
安装之前确保 Development Libraries与Development tools安装上。安装方法参考:http://www.linuxidc.com/Linux/2016-04/130080.htm 与 http://www.linuxidc.com/Linux/2016-04/130081.htm
一、编译安装
1、解决依赖关系
安装httpd 2.4.4时首先需要解决依赖关系,httpd
2.4.4需要较新版本的apr和apr-util。升级方式有两种,一种是通过源代码编译安装,一种是直接升级rpm包。本文选择第一种方法来进行升级。在这里我们下载
apr-1.4.6.tar.bz2与apr-util-1.5.2.tar.bz2版本。为了以后不必要的麻烦,在这里一定要保证系统时间正确,不正确的(data自行修改)。
apr和apr-util的下载路径为:http://archive.apache.org/dist/apr/
(1)首先根据惯例剪切apr与apr-util到/usr/local/src下,然后进行解压操作
mv apr-1.4.6.tar.bz2 /usr/local/src
mv apr-util-1.5.2.tar.bz2 /usr/local/src
tar -xjvf apr-1.4.6.tar.bz2
tar -xjvf apr-util-1.5.2.tar.bz2
(2)编译安装apr
cd apr-1.4.6
./configure --prefix=/usr/local/apr #安装在/usr/local/下 命名为apr
make
make install
(3)编译安装apr-util
cd apr-util-1.5.2
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make
make install
(4) httpd-2.4.4编译过程也要依赖于pcre-devel软件包,需要事先安装。此软件包系统光盘自带,因此,找到并安装即可。
yum -y install pcre-devel
到此为止基本上解决了依赖关系。
2、编译安装httpd-2.4.4
下载httpd-2.4.4.tar.bz2下载地址为https://archive.apache.org/dist/httpd/
(1)首先根据惯例剪切httpd-2.4.4.tar.bz2到/usr/local/src下,然后进行解压操作
mv httpd-2.4.4.tar.bz2 /usr/local/src
tar -xjvf httpd-2.4.4.tar.bz2
(2)编译安装httpd
cd httpd-2.4.4
./configure
--prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so
--enable-rewirte --enable-ssl --enable-cgi --enable-cgid
--enable-modules=most --enable-mods-shared=most --enable-mpms-shared=all
--with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
解释:
--enable-so:支持动态共享模块,如果支持php将不能与apache一起工作。必须要有
--enable-ssl:启用ssl功能,如果不启用将无法使用https
--enable-mpms-shared=all:prefork、worker、event
--with-mpm=event:event为默认
--enable-rewrite:支持URL重写
--enable-cgi :支持cgi
--enable-cgid:httpd使用event或者worker得启用被线程方式访问
--enable-modules=most :启用大多数模块
--enable-mods-shared=most:启用大多数共享模块
(3)setenforce 0 关掉selinux。(临时关闭)
永久关闭 vim /etc/selinux/config
二、后续操作
1、启动httpd
两种方法:第一种、/usr/local/apache/bin/apachectl start
第二种方法:先修改http.pid文件位置打开配置文件增加一行
vim /etc/httpd/httpd.conf 增加PidFile “/var/run/httpd.pid”
为了启动httpd更加方便,
#!/bin/bash
#
# httpd Startup script for the Apache HTTP Server
#
# chkconfig: - 85 15
# description: Apache is a World Wide Web server. It is used to serve \
# HTML files and CGI.
# processname: httpd
# config: /etc/httpd/conf/httpd.conf
# config: /etc/sysconfig/httpd
# pidfile: /var/run/httpd.pid
# Source function library.
. /etc/rc.d/init.d/functions
if [ -f /etc/sysconfig/httpd ]; then
. /etc/sysconfig/httpd
fi
# Start httpd in the C locale by default.
HTTPD_LANG=${HTTPD_LANG-"C"}
# This will prevent initlog from swallowing up a pass-phrase prompt if
# mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS=""
# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
# with the thread-based "worker" MPM; BE WARNED that some modules may not
# work correctly with a thread-based MPM; notably PHP will refuse to start.
# Path to the apachectl script, server binary, and short-form for messages.
apachectl=/usr/local/apache/bin/apachectl
httpd=${HTTPD-/usr/local/apache/bin/httpd}
prog=httpd
pidfile=${PIDFILE-/var/run/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd}
RETVAL=0
start() {
echo -n $"Starting $prog: "
LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${lockfile}
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc -p ${pidfile} -d 10 $httpd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
reload() {
echo -n $"Reloading $prog: "
if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then
RETVAL=$?
echo $"not reloading due to configuration syntax error"
failure $"not reloading $httpd due to configuration syntax error"
else
killproc -p ${pidfile} $httpd -HUP
RETVAL=$?
fi
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p ${pidfile} $httpd
RETVAL=$?
;;
restart)
stop
start
;;
condrestart)
if [ -f ${pidfile} ] ; then
stop
start
fi
;;
reload)
reload
;;
graceful|help|configtest|fullstatus)
$apachectl $@
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
exit 1
esac
exit $RETVAL
将以上代码加入到vim /etc/init.d/httpd中
而后为此脚本赋予执行权限:
chmod +x /etc/rc.d/init.d/httpd
加入服务列表:
chkconfig --add httpd
给3,5启动
chkconfig --level 3,5 httpd on
最后加路径
将 export PATH=$PATH:/usr/local/apache/bin
vim /etc/profile.d/httpd.sh完成后重新登录就可以了。推荐使用第二种方法
三、验证
安装成功!
Ubuntu Server 14.04 安装Web服务器(Linux+Apache+MySQL+PHP) http://www.linuxidc.com/Linux/2015-06/119061.htm
Linux下安装配置PHP环境(Apache2) http://www.linuxidc.com/Linux/2015-05/118062.htm
Ubuntu 13.04 安装 LAMP\Vsftpd\Webmin\phpMyAdmin 服务及设置 http://www.linuxidc.com/Linux/2013-06/86250.htm
CentOS 5.9下编译安装LAMP(Apache 2.2.44+MySQL 5.6.10+PHP 5.4.12) http://www.linuxidc.com/Linux/2013-03/80333p3.htm
RedHat 5.4下Web服务器架构之源码构建LAMP环境及应用PHPWind http://www.linuxidc.com/Linux/2012-10/72484p2.htm
Apache 的详细介绍:请点这里
Apache 的下载地址:请点这里
本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-04/130079.htm
Linux下Apache的安装与配置的更多相关文章
- linux下vsftpd的安装及配置使用详细步骤(推荐)
vsftpd 是“very secure FTP daemon”的缩写,安全性是它的一个最大的特点. vsftpd 是一个 UNIX 类操作系统上运行的服务器的名字,它可以运行在诸如 Linux.BS ...
- Linux下Qt的安装与配置
参考资料:http://www.cnblogs.com/emouse/archive/2013/01/28/2880142.html Linux 下编译.安装.配置 QT 下载qt 这里用的是4.7. ...
- Linux 下编译、安装、配置 QT
转自Linux 下编译.安装.配置 QT 注意:编译安装耗时费力,且很容易出错,要不断调整编译参数,不推荐使用,否则这将会是一个纠结痛苦的过程. 打算做嵌入式图像处理,计划方案嵌入式Linux+Ope ...
- .Neter玩转Linux系列之六:Linux下MySQL的安装、配置、使用
一.Linux安装MySQL (1)下载安装包:https://dev.mysql.com/downloads/mysql/ (2)解压并安装 命令:tar zxvf 文件名 解压完成之后,重名一下文 ...
- linux下svn的安装与配置
---恢复内容开始--- linux下svn的安装与配置 Linux发行版本:CentOS6.5 1.安装subversion sudo yum -y install subversion 2.创建s ...
- linux下redis的安装及配置启动
linux下redis的安装及配置启动 标签: redisnosql 2014-10-24 14:04 19732人阅读 评论(0) 收藏 举报 分类: 数据与性能(41) wget http:/ ...
- 莫小安 Linux下Redis的安装与配置
转载自--Linux下Redis的安装与配置 redis是当前比较热门的NOSQL系统之一,它是一个key-value存储系统.和Memcached类似,但很大程度补偿了 memcached的不足,它 ...
- Linux下的Maven安装与配置
关于Maven的介绍可以参考:Maven详解 这篇在原理上讲得比较详细,在安装上是windows版本的,这里补上linux下的安装和配置: 1.下载maven安装包 http://maven.apac ...
- Linux下apache+phppgadmin安装配置
1.安装pg 安装PostgreSQL数据库 修改pg_hba.conf配置文件,使得数据库可以通过外部访问. 具体可以配置为: # TYPE DATABASE USER ADDRESS METHOD ...
随机推荐
- SpringBoot整合Dubbo报错: java.lang.ClassCastException
com.alibaba.dubbo.rpc.RpcException: Failed to invoke remote proxy method queryGoodsLimitPage to regi ...
- FW 执行Git命令时出现各种 SSL certificate problem 的解决办法
比如我在windows下用Git clone gitURL 就提示 SSL certificate problem: self signed certificate 这种问题,在windows下出现 ...
- Mysql存储引擎的选择
Mysql存储引擎概述 mysql的存储引擎是插件式的,用户可以根据需求选择如何存储和索引数据是否使用事务等. Mysql支持多种存储引擎,用户可以选择不同的引擎来提高应用的效率,灵活的存储方案,存储 ...
- k8s 安装文档
k8s 安装文档 1.5 http://blog.csdn.net/bobpen/article/details/78958675
- IDEA 跑spring项目找不到get,set的问题
@Autowired的用法和作用 这个注解就是spring可以自动帮你把bean里面引用的对象的setter/getter方法省略,它会自动帮你set/get. iDEA下安装lombok这个插件就可 ...
- CSRF(Cross Site Request Forgery, 跨站请求伪造)
一.CSRF 背景与介绍 CSRF(Cross Site Request Forgery, 跨站域请求伪造)是一种网络的攻击方式,它在 2007 年曾被列为互联网 20 大安全隐患之一.其他安全隐患, ...
- 标准C语言的输入输出流(i/o)方法详解
cppreference.com -> 标准 C I/O ->详细说明 标准 C I/O clearerr 语法: #include <stdio.h> void cleare ...
- 电信、网通、联通等恶意DNS劫持跳广告页面的解决方法
中国电信.网通.联通ADSL用户必读:中国电信.网通.联通劫持dns(中国电信.网通.联通劫持ie浏览器)解决方案D... 宽带连接有 也能上网但是本地连接一直显示为受限制的解决方法 我的电脑一直显示 ...
- 查看linux系统版本信息(Oracle Linux、Centos Linux、Redhat Linux、Debian、Ubuntu)
一.查看Linux系统版本的命令(3种方法) 1.cat /etc/issue,此命令也适用于所有的Linux发行版. [root@S-CentOS home]# cat /etc/issue Cen ...
- js怎么将光标移动特定的位置:
第一种方法: a 标签的锚: 将a标签的herf='#element_id_name' 即可 <a href="#comment_content" class=" ...