一、更新 yum
yum -y update
二、利用yum升級各種程式庫
1.LANG=C
2.yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
三、安裝nginx
由於centos沒有預設的nginx軟體包,需要啟用REHL的附件包
1.rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
2.yum -y install nginx
設定開機啟動
chkconfig nginx on
nginx:http://www.uusnn.com.cn/?attachment_id=81(去掉.rar)
配置nginx
nginx.conf設定檔如下:
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events{
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log ;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on;
# Load config files from the /etc/nginx/conf.d directory
include /etc/nginx/conf.d/*.conf;
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
include common_www;
}
}
common_www檔案如下
index index.html index.htm;
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
四、安裝php,memcache
yum -y install php-cli php-pdo php-mcrypt php-mbstring php-json php-fastcgi php-cgi php-gd php-tidy php-xml php-xmlrpc php-pear php-pecl-memcache php-eaccelerator
# APC 和 eAccelerator 有衝突,2選1
yum -y install php-pecl-apc
五、安裝spawn-fcgi來運行php-cgi
yum install spawn-fcgi
六、下載spawn-fcgi 的啟動指令碼
wget http://bash.cyberciti.biz/dl/419.sh.zip
unzip 419.sh.zip
mv 419.sh /etc/init.d/php_cgi
chmod +x /etc/init.d/php_cgi
啟動php_cgi
/etc/init.d/php_cgi start
查看進程
netstat -tulpn | grep :9000
若出現如下代表一切正常
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 4352/php-cgi
:419.sh.zip
http://www.uusnn.com.cn/?attachment_id=80
七、安裝mysql
yum -y install mysql-server ← 安裝MySQL
yum -y install php-mysql ← 安裝php-mysql
vi /etc/my.cnf
在[mysqld]一節加入
default-character-set = utf
在末尾加入以下章節
[mysql]
default-character-set = utf8
然後開始啟動mysql
chkconfig mysqld on ← 設定MySQL服務隨系統啟動自啟動
chkconfig –list mysqld ← 確認MySQL自啟動
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off ← 如果2–5為on的狀態就OK
/etc/rc.d/init.d/mysqld start ← 啟動MySQL服務
設定初始密碼
mysqladmin -u root password 123456