參考鳥哥的Linux私房菜 http://linux.vbird.org/linux_server/0360apache.php
使用CentOS時,與Ubuntu比較不一樣的地方在於安裝程式的指令為 yum
還有Apache的程式名稱叫做 httpd
其他地方大概都差不多,這篇文章主要記錄一下不一樣的地方
安裝
# yum install httpd mysql-server php php-devel php-mysql
● 修改apache設定檔
# vim /etc/httpd/conf/httpd.conf
#設定保持持續連線
KeepAlive Off #改為 On
MaxKeepAliveRequests 100 #改為500
<IfModule prefork.c>
StartServers 1
MinSpareServers 1
MaxSpareServers 5
ServerLimit 256
MaxClients 256
MaxRequestsPerChild 4000
</IfModule>
# apache程序的使用者與群組
User apache
Group apache
#ServerName www.example.com:80
改為 ServerName disp.cc:80
DocumentRoot "/var/www/html"
DirectoryIndex #要再加上 index.htm 至於 index.php 在 conf.d/php.conf 裡會加
重新啟動 apache
# /etc/init.d/httpd restart
● 將php升級至 5.3
參考 http://gogo2man.world.edoors.com/CeR8uEH5D4xQ
CentOS的php預設只會裝到5.1,若想升到最新的5.3,必需抓remi的rpm檔來升級
(新版的phpMyAdmin必需使用PHP5.2以上)
以下為 x86_64 的版本,若是 i386 可參考上面的網址
在 http://rpm.pbone.net/index.php3?stat=3& ... &dist[]=52 (這裡) 找epel載點
# wget ftp://ftp.univie.ac.at/systems/linux/fe ... noarch.rpm
# wget http://rpms.famillecollet.com/enterpris ... ease-5.rpm
# rpm -Uvh epel-release-5-3.noarch.rpm remi-release-5.rpm
執行以下執令即可自動升級 php 與 MySQL
# yum --enablerepo=remi update
若要使用phpMyAdmin要再安裝 php-mbstring
# yum --enablerepo=remi install php-mbstring
● 修改 /etc/php.ini
short_open_tag = On ;改成Off
display_errors = Off
log_errors = On
ignore_repeated_errors = On
ignore_repeated_source = On
date.timezone = Asia/Taipei
; cookie存活時間設為一個禮拜
session.cookie_lifetime = 604800
; session存活時間設為一個禮拜
session.gc_maxlifetime = 604800
● 設定 MySQL
初次啟動
/etc/init.d/mysqld start
修改root密碼
mysqladmin -u root password 密碼
設定 MySQL 服務隨系統一起啟動
# chkconfig mysqld on
確認 MySQL 自動啟動有打開
# chkconfig --list mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
如果2--5為on的狀態就OK
在 CentOS 5 x86_64 安裝 apache, php, MySQL
版主: stnet253
誰在線上
正在瀏覽這個版面的使用者:Semrush [Bot] 和 1 位訪客