正在加载...

升级最新 Nginx Mysql Php

[ 2011/10/04 19:48 | by selboo ]

本站博客使用的是 瑞豪开源(RASHOST) 美国 Linux VPS

web架构使用的是 Nginx 0.8.x + PHP 5.2.13(FastCGI)搭建胜过Apache十倍的Web服务器(第6版)

上面文章已经一年多也没更新,本着开源精神,爱折腾,爱最新版,十一在家呆着没事。

对本博客升级到最新版本 nginx-1.0.8, mysql-5.5.16, php-5.3.8

一、Nginx升级

This is The Text Code
[root@74-82-173-217 lnmp]# wget http://www.nginx.org/download/nginx-1.0.8.tar.gz
[root@74-82-173-217 lnmp]# tar zxvf nginx-1.0.8.tar.gz
Parsed in 0.000 seconds at 307.88 KB/s

修改 auto/cc/gcc 关闭 debug

This is The Text Code
[root@74-82-173-217 lnmp]# cd nginx-1.0.8
[root@74-82-173-217 nginx-1.0.8]# ./configure --prefix=/usr/local/nginx-1.0.8 --with-cpu-opt=pentium4 --with-cc-opt=-O3 --user=root --group=root --without-select_module --with-poll_module --without-http_ssi_module --without-http_geo_module --without-http_map_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-http_stub_status_module --with-google_perftools_module
[root@74-82-173-217 nginx-1.0.8]# make
[root@74-82-173-217 nginx-1.0.8]# make install
Parsed in 0.001 seconds at 831.93 KB/s

把当前 Nginx 目录下 conf 文件复该到 /usr/local/nginx-1.0.8/conf/ 下即可

This is The Text Code
[root@74-82-173-217 nginx-1.0.8]# cp -rfp /usr/local/nginx/conf/* /usr/local/nginx-1.0.8/conf/
[root@74-82-173-217 nginx-1.0.8]# /usr/local/nginx-1.0.8/sbin/nginx -t
nginx: the configuration file /usr/local/nginx-1.0.8/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx-1.0.8/conf/nginx.conf test is successful
Parsed in 0.000 seconds at 1192.42 KB/s

--with-cc-opt=-O3由于我购买的是 瑞豪开源(RASHOST) 128M内存,相对CPU来说内存更宝贵,所以节省更多的内存交给CPU处理
--with-google_perftools_module
增加对内存优化 google_perftools_module 具体方法可以查看 Tcmalloc 优化 Nginx Mysql

二、Mysql升级

This is The Text Code
[root@74-82-173-217 lnmp]# wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.16.tar.gz/from/http://mysql.mirrors.pair.com/
[root@74-82-173-217 lnmp]# tar zxvf mysql-5.5.16.tar.gz
[root@74-82-173-217 lnmp]# cd mysql-5.5.16
[root@74-82-173-217 mysql-5.5.16]# cmake . \
  -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.5.16/ \
  -DMYSQL_DATADIR=/data/mysql \
  -DMYSQL_UNIX_ADDR=/data/mysql/mysqld.sock \
  -DWITH_MYISAM_STORAGE_ENGINE=1 \
  -DWITH_INNOBASE_STORAGE_ENGINE=0 \
  -DWITH_BLACKHOLE_STORAGE_ENGINE=0 \
  -DWITH_ARCHIVE_STORAGE_ENGINE=0 \
  -DWITHOUT_PARTITION_STORAGE_ENGINE=1 \
  -DENABLED_LOCAL_INFILE=1 \
  -DMYSQL_TCP_PORT=3306 \
  -DEXTRA_CHARSETS=all \
  -DDEFAULT_CHARSET=utf8 \
  -DDEFAULT_COLLATION=utf8_general_ci \
  -DWITH_DEBUG=0
[root@74-82-173-217 mysql-5.5.16]# make
[root@74-82-173-217 mysql-5.5.16]# make install
[root@74-82-173-217 mysql-5.5.16]# cp support-files/mysql.server /etc/init.d/mysqld5516
[root@74-82-173-217 mysql-5.5.16]# chmod 755 /etc/init.d/mysqld5516
Parsed in 0.001 seconds at 1374.95 KB/s

由于升级所以不必拷贝my.cnf和初始化数据库
为了节省资源,本站只开启MyISAM引擎,并关闭其他不用的引擎,比如InnoDB,
由于mysql 5.5.* 默认启用InnoDB,所以需要在 my.cnf 添加 default-storage-engine = MyISAM否则会启动失败

三、Php升级

This is The Text Code
[root@74-82-173-217 lnmp]# wget http://cn.php.net/get/php-5.3.8.tar.gz/from/this/mirror
[root@74-82-173-217 lnmp]# tar zxvf php-5.3.8.tar.gz
[root@74-82-173-217 lnmp]# cd php-5.3.8
[root@74-82-173-217 php-5.3.8]# ./configure --prefix=/usr/local/php-5.3.8 --with-config-file-path=/usr/local/php-5.3.8/etc --with-mysql=/usr/local/mysql-5.5.16 --with-mysqli=/usr/local/mysql-5.5.16/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fpm  --enable-ftp --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --with-fpm-user=www --with-fpm-group=www
[root@74-82-173-217 php-5.3.8]# make ZEND_EXTRA_LIBS='-liconv'
[root@74-82-173-217 php-5.3.8]# make install
[root@74-82-173-217 php-5.3.8]# cp php.ini-production /usr/local/php-5.3.8/etc/
Parsed in 0.001 seconds at 1375.85 KB/s

php-fpm配置文件

This is The Text Code
[root@74-82-173-217 php-5.3.8]# cat /usr/local/php-5.3.8/etc/php-fpm.conf
[global]
pid = run/php-fpm.pid
error_log = log/php-fpm.log
log_level = alert
emergency_restart_threshold = 10
emergency_restart_interval = 1m
process_control_timeout = 5
daemonize = yes
rlimit_files = 65536
rlimit_core = 0

[www]
listen = /tmp/php-cgi_www.sock
user = www
group = www
pm = dynamic
pm.max_children = 10
pm.start_servers = 4
pm.min_spare_servers = 2
pm.max_spare_servers = 5
pm.max_requests= 500

[blog]
listen = /tmp/php-cgi_blog.sock
user = www
group = www
pm = dynamic
pm.max_children = 10
pm.start_servers = 4
pm.min_spare_servers = 2
pm.max_spare_servers = 5
pm.max_requests= 500
Parsed in 0.000 seconds at 1336.82 KB/s

启动php-fpm

This is The Text Code
[root@74-82-173-217 php-5.3.8]# /usr/local/php-5.3.8/sbin/php-fpm
Parsed in 0.000 seconds at 762.87 KB/s

自php-5.3.3以后,不用在打FPM补丁,FPM已内置到PHP中,详细可观看http://cn.php.net/releases/5_3_3.php
新的FPM配置更加灵活,但是 php 5.2.* 和 php 5.3.* 还有以一定差距,请根据实际情况进行升级
最后编辑: selboo 编辑于2011/12/19 19:02
Tags: , , , ,
,
PiaCa
2011/10/14 11:54
博主,mysql编译参数 有笔误
DDEFAULT_COLLATION=utf8-general_ci

应该改成
DDEFAULT_COLLATION=utf8_general_ci
selboo 回复于 2011/10/14 11:55
感谢,已修改。
bedspreads
2011/10/09 18:29
好专业的网站
分页: 1/1 第一页 1 最后页
发表评论
表情
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]