网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 服务器与数据库 > 服务器环境搭建
User Name
Password
 
FAQ Members List Calendar Cheap Glasses

服务器环境搭建 Windows,Linux,IIS,Apache等服务器配置、安全维护以及PHP和MYSQL运行环境讨论。

Reply
 
Thread Tools Display Modes
  #1   IP: 153.99.37.153
Old 2016-05-21, 07:36 AM
Martindale Martindale is offline
初级会员
 
Join Date: 2007-04-23
Posts: 1
Martindale 现在声名狼藉
Default Centos编译安装Apache 2.4.7

Centos 编译安装 Apache 2.4 准备:
yum groupinstall "Development tools"


之前服务器是 yum install httpd 安装的 Apache,所以可能解决了部分依赖关系,在我编译安装的过程中,只需要再格外 yum 两个 devel 包:
yum install zlib-devel pcre-devel


从官方下载:下载到/usr/local/src/
wget http://mirrors.hust.edu.cn/apache/httpd/httpd-2.4.7.tar.gz
wget http://apache.dataguru.cn/apr/apr-1.5.0.tar.gz
wget http://apache.dataguru.cn/apr/apr-util-1.5.3.tar.gz


解压缩:
tar -xvf httpd-2.4.7.tar.gz
tar -xvf apr-1.5.0.tar.gz
tar -xvf apr-util-1.5.3.tar.gz


一点文件操作:
mv apr-1.5.0 httpd-2.4.7/srclib/apr
mv apr-util-1.5.3 httpd-2.4.6/srclib/apr-util
cd httpd-2.4.7


编译命令:
./configure --with-included-apr --enable-nonportable-atomics=yes --with-z


出奇的简单,因为默认就有 --enable-mods-shared=most ,模块化安装,以后自行到 httpd.conf 中决定是否开启模块,所以什么 --enable-deflate --enable-rewrite --enable-blablabla 等就完全不必要了。

默认安装的是 event mpm,如果要用 worker ,就需要 --with-mpm=worker,或者干脆 --enable-mpms-shared=all,这样event、worker、prefork就会以模块化的方式安装,要用哪个就在 httpd.conf 里配置就好了。

编译完成后:
make
make install


安装完毕后, 所有的东西都在 /usr/local/apache2 这个目录下,最重要的当属 conf/httpd.conf ,自行配置吧。

加载模块上,我尽可能的做了精简,仅开启如下:
必须:
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule userdir_module modules/mod_userdir.so
LoadModule dir_module modules/mod_dir.so
LoadModule mime_module modules/mod_mime.so

设置超时:
LoadModule reqtimeout_module modules/mod_reqtimeout.so

以下三个都是为了配合 Google mod_pagespeed 才开启,不用可不开:
LoadModule filter_module modules/mod_filter.so
LoadModule deflate_module modules/mod_deflate.so
LoadModule headers_module modules/mod_headers.so

Apache 日志:
LoadModule log_config_module modules/mod_log_config.so

指定 Apache 用户和组:
LoadModule unixd_module modules/mod_unixd.so

phpMyAdmin 要用:
LoadModule alias_module modules/mod_alias.so

wordpress, joomla 要用:
LoadModule rewrite_module modules/mod_rewrite.so


还有很多配置文件在 /usr/local/apache2/conf/extra 下面,在 httpd.conf 中可以选择是否加载,我加载的部分有:
配置 timeout, keepalive 的
httpd-default.conf

配置 apache mpm 的
httpd-mpm.conf
这个很重要,性能优化基本上就靠这个文件了

配置网站目录的
httpd-userdir.conf

配置虚拟主机的
httpd-vhosts.conf


确定所有配置弄好后,就可以删除服务器上以前的 apache 了,至少我就是这么干的...:
service httpd stop
yum remove httpd


把新编译安装的 Apache 2.4.6 拷贝到位:
cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd


编辑 /etc/init.d/httpd 文件,在首行 #!/bin/sh 下面加入两行:
# chkconfig: 35 85 15
# description: Activates/Deactivates Apache 2.4.6


将 Apache 加入开机自动启动:
chkconfig --add httpd
chkconfig httpd on


最后一步,启动编译好的 Apache 2.4.7:
service httpd start


上面为转载部分

下面如果要从外网访问,还需要设置防火墙,否则外网是无法访问的,默认情况下,linux只开启22端口的,所以要开放80端

口:
vi /etc/sysconfig/iptables
#这里是打开防火墙设置,在22端口的下面一行添加下面这行代码,如果要开启8080端口只需要把80改成8080既可
-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT


编辑器完毕只需要重启防火墙既可,命令为:
service iptables restart
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off

Forum Jump

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 07:29 AM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.