centos 5.0 編譯安裝apache 2.2.6+php5.2.5+mysql5.0.46+Zend筆記
V2.0 2007年10月8日 操作系統(tǒng)更新為centos 5.0 apache 更新為2.2.6版本, php更新為5.2.5,增加集成Suhosin補(bǔ)丁,mysql 更新為5.0.46, Zend Optimizer 更新為3.3.0。解決新平臺(tái)下的一些問題。修正文字錯(cuò)誤。
v1.2 2007年2月12日 apache 更新為2.2.4版本,增加mod_ssl和openssl支持,增加apr和apr-util的編譯, php更新為5.2.1,增加集成Suhosin補(bǔ)丁,mysql 更新為5.0.33, Zend Optimizer 更新為3.2.2,增加phpmyadmin。修改一些文字錯(cuò)誤。
v1.0 2007年1月11日
先聲明,我絕對(duì)是個(gè)Linux的菜鳥,以下的這些文字個(gè)人的安裝筆記,是參考了網(wǎng)上許多高手的成功經(jīng)驗(yàn)組合而成的,說(shuō)實(shí)話我自己的東西不多 :)我想把這些經(jīng)驗(yàn)寫下來(lái),既可以對(duì)其他跟我一樣摸索的兄弟一個(gè)經(jīng)驗(yàn),也可以防止以后自己都忘記了,嘿嘿。
所以如果某個(gè)大蝦看到我借用了你的資源,請(qǐng)你不要生氣。也歡迎大家進(jìn)行指點(diǎn)。
1、下載centos 5
我是下載的DVD版本,大家也可以下載服務(wù)器CD安裝版本,其實(shí)都差不多。大家可以到這兒下載,速度很快的。
http://ftp.iasi.roedu.net/mirrors/ce...86-bin-DVD.iso
當(dāng)然也可以在windows下用BT或迅雷下載,速度也很不錯(cuò)的。
下載后當(dāng)然就刻錄成光盤。我建議你刻錄DVD啦,如果是菜鳥,也可以在圖形界面進(jìn)行學(xué)習(xí),不會(huì)這么抓不住頭腦。
2、(1)安裝CentOS 5
作為服務(wù)器,不安裝不需要的組件,所以在選擇組件的時(shí)候,除了選擇FTP SERVER外取消所有組件的選擇。也不要選web服務(wù)器。因?yàn)槲覀兒竺嬉謩?dòng)編譯安裝。
系統(tǒng)約定RPM包和源碼包存放位置
RPM包和源碼包存放位置 /usr/local/src
源碼包編譯安裝位置(prefix) /usr/local/xxx
腳本以及維護(hù)程序存放位置 /usr/local/sbin
MySQL 數(shù)據(jù)庫(kù)位置 /var/lib/mysql
Apache 網(wǎng)站根目錄 /home/www
Apache 虛擬主機(jī)日志根目錄 /data/logs/www
yum RPM包信息文件 /etc/yum.list
3、系統(tǒng)環(huán)境部署及調(diào)整
(1). 檢查系統(tǒng)是否正常
# more /var/log/messages //檢查有無(wú)系統(tǒng)內(nèi)核級(jí)錯(cuò)誤信息
# demesg //檢查硬件設(shè)備是否有錯(cuò)誤信息
# ifconfig //檢查網(wǎng)卡設(shè)置是否正確
# ping www.163.com // 檢查網(wǎng)絡(luò)是否正常
(2). 關(guān)閉不需要的服務(wù)
# export LANG='en_US' //設(shè)置語(yǔ)言
# setup //選擇啟動(dòng)的服務(wù)
進(jìn)入system service 選項(xiàng)。
以space 鍵選定所需服務(wù)。
以下僅列出需要啟動(dòng)的服務(wù),未列出的服務(wù)一律關(guān)閉:
crond
irqbalance 僅當(dāng)服務(wù)器CPU為S.M.P架構(gòu)或支持雙核心、HT技術(shù)時(shí),才需開啟,否則關(guān)閉。
microcode_ctl
network
vsftpd
sshd
syslog
(3)、修改/etc/yum.repos.d/CentOS-Base.repo,將鏡象站點(diǎn)地址改為在中國(guó)的鏡象站點(diǎn)地址。不然我們通過(guò)yum安裝軟件速度會(huì)極慢。修改如下:
# CentOS-Base.repo
#
# This file uses a new mirrorlist system developed by Lance Davis for CentOS.
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base
baseurl=http://mirror.be10.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
protect=1
#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=http://mirror.be10.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
protect=1
#packages used/produced in the build but not released
[addons]
name=CentOS-$releasever - Addons
baseurl=http://mirror.be10.com/centos/$releasever/addons/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
protect=0
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=http://mirror.be10.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
protect=0
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=http://mirror.be10.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
protect=1
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
baseurl=http://mirror.be10.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
protect=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
#packages in testing
[testing]
name=CentOS-5 - Testing
baseurl=http://mirror.be10.com/centos/5/testing/i386/
gpgcheck=1
enabled=0
protect=0
保存。
(2)更新系統(tǒng),我們使用yum,
然后執(zhí)行:
# yum upgrade
建議更新所有列出的程序,rhel 5.X的穩(wěn)定性還要繼續(xù)努力呢。
(4)、定時(shí)校正服務(wù)器時(shí)間
# yum install ntp
# crontab -e
0 23 * * * root /usr/sbin/ntpdate 210.72.145.44 > /dev/null 2>&1
以上命令設(shè)置好后存盤。您的機(jī)器將在每天的23:00根據(jù)中國(guó)國(guó)家授時(shí)中心的NTP服務(wù)器時(shí)間自動(dòng)校準(zhǔn)時(shí)間。
(5). 對(duì)TCP/IP網(wǎng)絡(luò)參數(shù)進(jìn)行調(diào)整,加強(qiáng)抗SYN Flood能力
# echo 'net.ipv4.tcp_syncookies = 1' >> /etc/sysctl.conf //將net.ipv4.tcp_syncookies = 1寫入sysctl.conf 文件
# sysctl -p //查看
(6)、FTP服務(wù)器的配置
vi /etc/vsftpd/vsftpd.conf
把a(bǔ)nonymous_enable=YES注釋掉不允許匿名登錄。
把chroot_list_enable=YES
chroot_list_file=/etc/vsftpd.chroot_list
前的注釋去掉。
把ftpd_banner=*前的注釋去掉。后面改成你的歡迎信息(這樣設(shè)置可以避免顯示ftp服務(wù)器的版本信息)
然后保存,service vsftpd start就可以了。
這時(shí)應(yīng)當(dāng)添加用戶,因?yàn)閞oot默認(rèn)不能通過(guò)FTP方式登錄。
# adduser username
# passwd userpassword
這樣對(duì)于我們上傳一些文件到系統(tǒng)中很方便。
4. 重新啟動(dòng)系統(tǒng)
# init 6
5. 使用 yum 程序安裝所需開發(fā)包(以下為標(biāo)準(zhǔn)的 RPM 包名稱)
# yum install gcc gcc-c++ gcc-g77 flex bison autoconf automake bzip2-devel zlib-devel ncurses-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel pam-devel openssl-devel libxml2-devel
#這里我們將編譯GD所必須的一些小軟件比如libpng,libtiff,freetype,libjpeg,等先用RPM的方式一并安裝好,避免手動(dòng)編譯浪費(fèi)時(shí)間,同時(shí)也能避免很多錯(cuò)誤,這幾個(gè)小軟件的編譯很麻煩。這幾個(gè)小軟件編譯錯(cuò)誤了,GD當(dāng)然安裝不了,php5的編譯當(dāng)然也沒戲了。所以我們抓大放小,對(duì)這些小牛鬼蛇神采取快速簡(jiǎn)潔的方式進(jìn)行安裝。并且對(duì)服務(wù)器的性能也不能產(chǎn)生什么影響。
另外libxml2系統(tǒng)已經(jīng)默認(rèn)安裝了,所以我們不需要手工編譯了,直接安裝它的開發(fā)包就行了。
6. 源碼編譯安裝所需包 (Source)
(1) GD2
# cd /usr/local/src
# wget http://www.boutell.com/gd/http/gd-2.0.34.tar.gz
# tar xzvf gd-2.0.34.tar.gz
# cd gd-2.0.34
# CHOST="i686-pc-linux-gnu" CFLAGS="-O3 -msse2 -mmmx -Wall -W -mfpmath=sse -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer" CXXFLAGS="-O3 -msse2 -mmmx -Wall -W -mfpmath=sse -funroll-loops -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer" ./configure --prefix=/usr/local/gd2 --mandir=/usr/share/man //./configure 配置。
# make //make 是用來(lái)編譯的,它從 Makefile 中讀取指令,然后編譯。
# make install //make install 是用來(lái)安裝的,它也從 Makefile 中讀取指令,安裝到指定的位置。
(2) Apache 日志截?cái)喑绦?br /># cd /usr/local/src
# wget http://cronolog.org/download/cronolog-1.6.2.tar.gz
# tar xzvf cronolog-1.6.2.tar.gz
# cd cronolog-1.6.2
# ./configure --prefix=/usr/local/cronolog
# make
# make install
7、編譯mysql 5.0.46
mysql 5.0.46是企業(yè)版本,貌似雙數(shù)版本都是企業(yè)版本了。個(gè)人覺得代碼質(zhì)量要比社區(qū)版本要好一些。大家可以下載,免費(fèi)使用。并不需要向mysql公司交錢。
cd /usr/local/src
# wget http://mirror.provenscaling.com/mysq...-5.0.46.tar.gz
# tar xzvf mysql-5.0.46.tar.gz
# cd mysql-5.0.46
修改mysql 客戶端最大連接數(shù), 默認(rèn)的只有100,遠(yuǎn)遠(yuǎn)達(dá)不到我們的要求。
# vi sql/mysqld.cc
搜索找到下面一行:
{"max_connections", OPT_MAX_CONNECTIONS,
"The number of simultaneous clients allowed.", (gptr*) &max_connections,
(gptr*) &max_connections, 0, GET_ULONG, REQUIRED_ARG, 100, 1, 16384, 0, 1,
0},
將其中的100改為1500, 當(dāng)然小點(diǎn)也可以,根據(jù)你的需要來(lái),不建議改的太大。
{"max_connections", OPT_MAX_CONNECTIONS,
"The number of simultaneous clients allowed.", (gptr*) &max_connections,
(gptr*) &max_connections, 0, GET_ULONG, REQUIRED_ARG, 1500, 1, 16384, 0, 1,
0},
保存。
# CHOST="i686-pc-linux-gnu" CFLAGS="-O3 -msse2 -mmmx -Wall -W -mfpmath=sse -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer" CXXFLAGS="-O3 -msse2 -mmmx -Wall -W -mfpmath=sse -funroll-loops -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer" ./configure --prefix=/usr/local/mysql --localstatedir=/var/lib/mysql --with-comment=Source --with-server-suffix=-enterprise-gpl --with-mysqld-user=mysql --without-debug --with-big-tables --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=all --with-pthread --enable-static --enable-thread-safe-client --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --enable-assembler --without-innodb --without-ndb-debug --without-isam
配置成功會(huì)提示:
MySQL has a Web site at http://www.mysql.com/ which carries details on the
latest release, upcoming features, and other information to make your
work or play with MySQL more productive. There you can also find
information about mailing lists for MySQL discussion.
Remember to check the platform specific part of the reference manual for
hints about installing MySQL on your platform. Also have a look at the
files in the Docs directory.
Thank you for choosing MySQL!
// 注意 ,CHOST="i686-pc-linux-gnu" CFLAGS="-O3 -msse2 -mmmx -Wall -W -mfpmath=sse -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer" CXXFLAGS="-O3 -msse2 -mmmx -Wall -W -mfpmath=sse -funroll-loops -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer" 這個(gè)環(huán)境參數(shù)只針對(duì)intel P4 芯片,如果你的CPU是AMD的,注意不能使用。請(qǐng)查看相應(yīng)的編譯優(yōu)化參數(shù)。否則程序會(huì)無(wú)法編譯,即使編譯成功也無(wú)法運(yùn)行,嘿嘿。
關(guān)于其他CPU的優(yōu)化請(qǐng)看我的BLOG的一篇轉(zhuǎn)貼:
http://www.cnprint.org/bbs/blogs/1/blog43.html
# make
編譯的時(shí)間可能會(huì)比較長(zhǎng),畢竟優(yōu)化的比較厲害。
# make install
編譯安裝完成后執(zhí)行后續(xù)操作:
# useradd mysql //添加 mysql 用戶
# cd /usr/local/mysql
# bin/mysql_install_db --user=mysql
# chown -R root:mysql . //設(shè)置權(quán)限,注意后面有一個(gè) "."
# chown -R mysql /var/lib/mysql //設(shè)置 mysql 目錄權(quán)限
# chgrp -R mysql . //注意后面有一個(gè) "."
# cp share/mysql/my-medium.cnf /etc/my.cnf
# cp share/mysql/mysql.server /etc/rc.d/init.d/mysqld //開機(jī)自動(dòng)啟動(dòng) mysql。
# chmod 755 /etc/rc.d/init.d/mysqld
# chkconfig --add mysqld
# /etc/rc.d/init.d/mysqld start //啟動(dòng) MySQL
# bin/mysqladmin -u root password "password_for_root"
# service mysqld stop //關(guān)閉 MySQL
8. 編譯安裝 Apache
# cd /usr/local/src
# wget http://www.ip97.com/apache.org/httpd/httpd-2.2.6.tar.gz
# tar zxvf httpd-2.2.6.tar.gz
# cd httpd-2.2.6
依次安裝apr和apr-util
# cd srclib/apr
# CHOST="i686-pc-linux-gnu" CFLAGS="-O3 -msse2 -mmmx -Wall -W -mfpmath=sse -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer" CXXFLAGS="-O3 -msse2 -mmmx -Wall -W -mfpmath=sse -funroll-loops -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer" ./configure --prefix=/usr/local/apr --enable-threads --enable-other-child --enable-static
# make && make install
# cd ../apr-util
# CHOST="i686-pc-linux-gnu" CFLAGS="-O3 -msse2 -mmmx -Wall -W -mfpmath=sse -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer" CXXFLAGS="-O3 -msse2 -mmmx -Wall -W -mfpmath=sse -funroll-loops -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer" ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/ --with-mysql=/usr/local/mysql
# make && make install
cd /usr/local/src/httpd-2.2.6
# CHOST="i686-pc-linux-gnu" CFLAGS="-O3 -msse2 -mmmx -Wall -W -mfpmath=sse -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer" CXXFLAGS="-O3 -msse2 -mmmx -Wall -W -mfpmath=sse -funroll-loops -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer" ./configure --prefix=/usr/local/apache2 --enable-mods-shared=all --with-mysql=/usr/local/mysql --enable-cache --enable-file-cache --enable-mem-cache --enable-disk-cache --enable-static-support --enable-static-htpasswd --enable-static-htdigest --enable-static-rotatelogs --enable-static-logresolve --enable-static-htdbm --enable-static-ab --enable-static-checkgid --disable-cgid --disable-cgi --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --enable-ssl --with-ssl=/usr/include/openssl
# make
# make install
# echo '/usr/local/apache2/bin/apachectl start ' >> /etc/rc.local //將 apachectl 的調(diào)用加入到你的系統(tǒng)啟動(dòng)文件中。
注解:
./configure //配置源代碼樹
--prefix=/usr/local/apache2 //體系無(wú)關(guān)文件的頂級(jí)安裝目錄PREFIX ,也就Apache的安裝目錄。
--enable-module=so //打開 so 模塊,so 模塊是用來(lái)提 DSO 支持的 apache 核心模塊
--enable-mods-shared=all //編譯全部的模板,對(duì)于不需要我們可以在httpd.conf去掉。
--enable-cache //支持緩存
--enable-file-cache //支持文件緩存
--enable-mem-cache //支持記憶緩存
--enable-disk-cache //支持磁盤緩存
--enable-static-support //支持靜態(tài)連接(默認(rèn)為動(dòng)態(tài)連接)
--enable-static-htpasswd //使用靜態(tài)連接編譯 htpasswd - 管理用于基本認(rèn)證的用戶文件
--enable-static-htdigest //使用靜態(tài)連接編譯 htdigest - 管理用于摘要認(rèn)證的用戶文件
--enable-static-rotatelogs //使用靜態(tài)連接編譯 rotatelogs - 滾動(dòng) Apache 日志的管道日志程序
--enable-static-logresolve //使用靜態(tài)連接編譯 logresolve - 解析 Apache 日志中的IP地址為主機(jī)名
--enable-static-htdbm //使用靜態(tài)連接編譯 htdbm - 操作 DBM 密碼數(shù)據(jù)庫(kù)
--enable-static-ab //使用靜態(tài)連接編譯 ab - Apache HTTP 服務(wù)器性能測(cè)試工具
--enable-static-checkgid //使用靜態(tài)連接編譯 checkgid
--disable-cgid //禁止用一個(gè)外部 CGI 守護(hù)進(jìn)程執(zhí)行CGI腳本
--disable-cgi //禁止編譯 CGI 版本的 PHP
--enable-ssl // 編譯 ssl模塊。
我們不再使用worker模式編譯apache,worker模式和php貌似有一些不協(xié)調(diào)不穩(wěn)定之處。所以使用了默認(rèn)的perfork模式。
將apache設(shè)置成開機(jī)自啟動(dòng):
在/etc/rc.d/rc.local文件中加入一行
/usr/local/apache2/bin/apachectl start
這樣每次重新啟動(dòng)系統(tǒng)以后,apache也會(huì)隨系統(tǒng)一起啟動(dòng).
或者
# cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd
然后 vi /etc/rc.d/init.d/httpd 添加(#!/bin/sh下面)
# chkconfig: 2345 10 90
# description: Activates/Deactivates Apache Web Server
最后,運(yùn)行chkconfig把Apache添加到系統(tǒng)的啟動(dòng)服務(wù)組里面:
# chkconfig --add httpd
# chkconfig httpd on
9、編譯php 5.2.5-devel。
php 5.2.4有點(diǎn)小BUG,無(wú)法在centos 5上正常編譯,官方已經(jīng)在php5.2.5中修復(fù)了。所以我們使用php 5.2.5進(jìn)行編譯。
Suhosin是php增強(qiáng)型安全補(bǔ)丁,可以編譯到靜態(tài)內(nèi)核中,也可以編譯成php動(dòng)態(tài)擴(kuò)展。我個(gè)人強(qiáng)烈你建議安裝成靜態(tài)內(nèi)核。Suhosin已經(jīng)進(jìn)入freebsd和gentoo的ports。下面的以下先說(shuō)靜態(tài)安裝步驟。當(dāng)然你也可以在安裝php后將它編譯成php的動(dòng)態(tài)擴(kuò)展。
# cd /usr/local/src
# wget http://cn.php.net/get/php-5.2.5.tar.gz/from/this/mirror
wget http://www.hardened-php.net/suhosin/...9.6.2.patch.gz
# tar zxvf php-5.2.5.tar.gz
# gunzip suhosin-patch-5.2.1-0.9.6.2.patch.gz
# cd php-5.2.5
# CHOST="i686-pc-linux-gnu" CFLAGS="-O3 -msse2 -mmmx -Wall -W -mfpmath=sse -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer" CXXFLAGS="-O3 -msse2 -mmmx -Wall -W -mfpmath=sse -funroll-loops -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer" ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-pear=/usr/share/php --with-zlib-dir --with-bz2 --with-libxml-dir=/usr --with-gd=/usr/local/gd2 --enable-gd-native-ttf --enable-gd-jis-conv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-ttf=shared,/usr --enable-mbstring --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-config-file-path=/etc --with-iconv --disable-ipv6 --enable-static --enable-maintainer-zts --enable-zend-multibyte --enable-inline-optimization --enable-zend-multibyte --enable-sockets --enable-soap --with-openssl
配置成功會(huì)提示:
+--------------------------------------------------------------------+
| License: |
| This software is subject to the PHP License, available in this |
| distribution in the file LICENSE. By continuing this installation |
| process, you are bound by the terms of this license agreement. |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point. |
+--------------------------------------------------------------------+
Thank you for using PHP.
# make
# make install
# cp php.ini-recommended /etc/php.ini
在這里也順便說(shuō)一下將suhosin安裝成為php的動(dòng)態(tài)擴(kuò)展的方法。畢竟網(wǎng)上根本不見它的中文安裝教程。
雖然我個(gè)人不推薦這種方式。
wget http://www.hardened-php.net/suhosin/...sin-0.9.16.tgz
tar zxvf suhosin-0.9.16.tgz
cd suhosin-0.9.16
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
會(huì)提示編譯的模塊存在的目錄,記住它。
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/
然后在php.ini中增加一行下列語(yǔ)句。
extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/suhosin.so
10 、整合apache 與php
# vi /usr/local/apache2/conf/httpd.conf
在最后一行加上:
AddType application/x-httpd-php .php
查找:(設(shè)置 WEB 默認(rèn)文件)
DirectoryIndex index.html
替換為:
DirectoryIndex index.php index.html index.htm //在 WEB 目錄不到默認(rèn)文件,httpd 就會(huì)執(zhí)行 /var/www/error/noindex.html
找到這一段:
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride none
更改為AllowOverride all
允許apache rewrite
# 監(jiān)聽443端口,支持https連接
取消注釋 httpd.conf 中的 Include conf/extra/httpd-ssl.conf
保存httpd.conf,退出。
# /usr/local/apache2/bin/apachectl restart //重啟 Apache
這時(shí)會(huì)出現(xiàn)錯(cuò)誤:
/usr/local/apache2/bin/apachectl start
httpd: Syntax error on line 107 of /usr/local/apache2/conf/httpd.conf: Cannot load /usr/local/apache2/modules/libphp5.so into server: /usr/local/apache2/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied
不急,我們慢慢解決。
先重啟下機(jī)器:
reboot
這個(gè)Permission denied問題,在centos 5下面一般是Selinux引起的,作為生產(chǎn)用服務(wù)器,我建議你千萬(wàn)別草率地關(guān)掉Selinux一了百了。就像家里的防盜網(wǎng),阻礙了你的貓自由進(jìn)出窗戶,你不能為了貓方便,就把防盜網(wǎng)簡(jiǎn)單拆除是同樣的道理。我看見網(wǎng)上許多人建議把Selinux簡(jiǎn)單關(guān)閉來(lái)解決這個(gè)問題,很不以為然。
我們可以這樣操作:
# audit2allow -d
allow initrc_t usr_t:file execmod;
allow mount_t default_t:file execute;
# cd /etc/selinux/targeted/modules/
# audit2allow -M local -d
屏幕產(chǎn)生如下提示:
產(chǎn)生類型強(qiáng)制文件:local.te
正在編譯策略
checkmodule -M -m -o local.mod local.te
semodule_package -o local.pp -m local.mod
********************重要 ***********************
為了在內(nèi)核中加載這個(gè)新創(chuàng)建的策略軟件包,
您需要執(zhí)行
semodule -i local.pp
我們運(yùn)行
# semodule -i local.pp
這樣就讓Selinux加載了新的規(guī)則。
更詳細(xì)的內(nèi)容請(qǐng)看我在BLOG上的轉(zhuǎn)貼:
http://www.cnprint.org/bbs/blogs/1/blog48.html
reboot
哈哈,apache不會(huì)再報(bào)錯(cuò)了吧?
這樣我保留了selinux的功能,同時(shí)apache也能正常運(yùn)行。
11. 查看確認(rèn) L.A.M.P 環(huán)境信息
vi /usr/local/apache2/htdocs/phpinfo.php
新增加下面一行,并保存。