今天教大家怎么配置http服务器的apache平台

虽然nginx很火,很多人喜欢用nginx,但是还是有些会用apache来放网站。

今天教大家怎么配置的apache平台。

1、下载APACHE源代码

#wget http://ftp.cuhk.edu.hk/pub/packages/apache.org/httpd/httpd-2.4.38.tar.gz 

安装相关库

#yum install zlib zlib-devel apr apr-util pcre -y

解压、安装

#tar -zxvf httpd-2.4.38.tar.gz
 
#cd httpd-2.4.38 

开始安装


#./configure 
--prefix=/usr/local/apache2.4.38 
--enable-deflate 
--enable-expires 
--enable-headers 
--enable-modules=most 
--enable-so 
--with-mpm=worker 
--enable-rewrite 
--with-apr=/usr/local/apr/ 
--with-apr-util=/usr/local/apr-util/ 
--with-pcre=/usr/local/pcre

编译参数说明:

#1. --prefix=/usr/local/apache2.4.38 指定安装路径为

#2. --enable-deflate 提供对内容的压缩传输编码支持

#3. --enable-expires 允许通过配置文件控制http的“expires”和“cahe-control

#4. --enable-headers 提供允许对HTTP请求头的控制

#5. --with-mpm=worker 选择apache mpm的模式为worker模式

#6. --enable-rewrite 提供基于URL规则的重写功能

#7. --enable-so 激活APACHE服务的DSO(全称dynamic shared object,动态共享对象

上面如果没有安装zlib-devel包,这步编译时会报如下错误:

checking for zlib location... not found

checking whether to enable mod_deflate... configure: error: mod_deflate has been requested but can not be built due to prerequisite failures

上面编译无误后执行下面的命令开始安装:

编译Apache出现的问题:configure: error: APR not found

今天编译apache时出错:

#./configure --prefix……检查编辑环境时出现:

checking for APR... no

configure: error: APR not found . Please read the documentation

解决办法:

方法一:

安装httpd的软件依赖包

#yum install -y apr-devel apr-util-devel openssl-devel libevent-devel pcre-devel

方法二源码安装

1.下载所需软件包:

#wget http://archive.apache.org/dist/apr/apr-1.4.5.tar.gz
#wget http://archive.apache.org/dist/apr/apr-util-1.3.12.tar.gz
#wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.10/pcre-8.10.zip

2.卸载系统自带的apr

#yum remove apr

a:解决apr not found 的问题>>>

#tar -zxf apr-1.4.5.tar.gz
#cd  apr-1.4.5
#./configure --prefix=/usr/local/apr
#make && make instal

b:解决APR-util not found问题>>>>

#tar -zxf apr-util-1.3.12.tar.gz
#cd apr-util-1.3.12
#./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/
#make && make install

c:解决pcre问题>>>>>>>>>

#unzip -o pcre-8.10.zip
#cd pcre-8.10
#./configure --prefix=/usr/local/pcre
#make && make install

这一步可能会出现pcre编译失败,libtool: line 990: g++: command not found错误只要yum -y install gcc+ gcc-c++即可解决问题

4.最后编译Apache时加上:

--with-apr=/usr/local/apr 
--with-apr-util=/usr/local/apr-util/ 
--with-pcre=/usr/local/pcre

2、最后,成功编译完成,安装

#make
#make install

3、创建软链接

#ln -s apache2.2.31 apache

4、启动APACHE并测试


#/usr/local/apache/bin/apachectl start 

5、安装php支持apache,编译php文件(详细安装请看我另外一篇:完美运行centos7上的PHP服务器配置)

安装配置

#./configure --prefix=/usr/local/php 
--with-apxs2=/usr/local/apache/bin/apxs 
--with-config-file-path=/usr/local/php/etc 
--enable-inline-optimization --disable-debug 
--disable-rpath --enable-shared --enable-opcache 
--enable-fpm --with-fpm-user=www 
--with-fpm-group=www 
--with-mysql=mysqlnd 
--with-mysqli=mysqlnd 
--with-pdo-mysql=mysqlnd 
--with-gettext 
--enable-mbstring 
--with-iconv 
--with-mcrypt 
--with-mhash 
--with-openssl 
--enable-bcmath 
--enable-soap 
--with-libxml-dir 
--enable-pcntl 
--enable-shmop 
--enable-sysvmsg 
--enable-sysvsem 
--enable-sysvshm 
--enable-sockets 
--with-curl --with-zlib 
--enable-zip

6、修改apache配置文件

httpd.conf

1、在LoadModule后面添加:LoadModule php5_module modules/libphp5.so

备注:不添加则访问.php文件将会变成下载

2、在DirectoryIndex后面添加:index.php

3、 在AddType application/x-gzip .gz .tgz后面添加:AddType application/x-httpd-php .php //.php前面有一个空格

注意:源码安装的时候必须加上这个(--with-apxs2=/usr/local/apache24/bin/apxs),它的作用就是生成libphp5.so。

展开阅读全文

页面更新:2024-05-12

标签:可能会   软件包   重写   全称   时会   空格   源代码   备注   路径   源码   命令   错误   模式   服务器   文件   方法   数码   平台

1 2 3 4 5

上滑加载更多 ↓
推荐阅读:
友情链接:
更多:

本站资料均由网友自行发布提供,仅用于学习交流。如有版权问题,请与我联系,QQ:4156828  

© CopyRight 2020-2024 All Rights Reserved. Powered By 71396.com 闽ICP备11008920号-4
闽公网安备35020302034903号

Top