这里是以php-fpm这个php补丁的形式运行php的.
#yum -y install wget make#yum -y install patch
cd /etc/yum.repos.dmv CentOS-Base.repo CentOS-Base.repo.bakwget -O CentOS-Base.repo http://mirrors.sohu.com/help/CentOS-Base-sohu.repovi CentOS-Base.repo
#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 libmcrypt libmcrypt-devel mhash mhash-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
cd /usr/srcwget http://blog.s135.com/soft/linux/nginx_php/php/php-5.2.14.tar.gzwget http://blog.s135.com/soft/linux/nginx_php/phpfpm/php-5.2.14-fpm-0.5.14.diff.gzwget http://blog.s135.com/soft/linux/nginx_php/mysql/mysql-5.5.3-m3.tar.gzwget http://blog.s135.com/soft/linux/nginx_php/pcre/pcre-8.10.tar.gzwget http://blog.s135.com/soft/linux/nginx_php/nginx/nginx-0.8.46.tar.gzwget http://blog.s135.com/soft/linux/nginx_php/libiconv/libiconv-1.13.1.tar.gz//wget http://blog.s135.com/soft/linux/nginx_php/mcrypt/libmcrypt-2.5.8.tar.gz//wget http://blog.s135.com/soft/linux/nginx_php/mcrypt/mcrypt-2.6.8.tar.gz//wget http://blog.s135.com/soft/linux/nginx_php/mhash/mhash-0.9.9.9.tar.gzwget http://blog.s135.com/soft/linux/nginx_php/memcache/memcache-2.2.5.tgzwget http://blog.s135.com/soft/linux/nginx_php/eaccelerator/eaccelerator-0.9.6.1.tar.bz2wget http://blog.s135.com/soft/linux/nginx_php/pdo/PDO_MYSQL-1.0.2.tgzwget http://blog.s135.com/soft/linux/nginx_php/imagick/ImageMagick.tar.gzwget http://blog.s135.com/soft/linux/nginx_php/imagick/imagick-2.3.0.tgz
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
wget http://nginx.org/download/nginx-0.9.7.tar.gz
wget http://cn.php.net/distributions/php-5.2.17.tar.gzwget http://php-fpm.org/downloads/php-5.2.17-fpm-0.5.14.diff.gzwget http://blog.s135.com/soft/linux/nginx_php/mysql/mysql-5.5.3-m3.tar.gzwget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgzwget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.12.tar.gzwget http://bart.eaccelerator.net/source/0.9.6.1/eaccelerator-0.9.6.1.tar.bz2wget http://pecl.php.net/get/memcache-2.2.5.tgzwget ftp://mirror.aarnet.edu.au/pub/imagemagick/ImageMagick-6.6.9-3.tar.gz
wget http://pecl.php.net/get/imagick-2.3.0.tgz
//wget http://pecl.php.net/get/imagick-3.0.1.tgz 最新的版本有问题,提示无法加载imagick.so库文件.
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql
tar zxvf mysql-5.5.3-m3.tar.gzcd mysql-5.5.3-m3/./configure --prefix=/usr/local/mysql/ --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=partition,innobase,myisammrgmake && make install
chmod +w /usr/local/mysqlchown -R mysql:mysql /usr/local/mysql
/usr/local/mysql/bin/mysql_install_db --basedir=/usr/local/mysql --user=mysqlcp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf/usr/local/mysql/bin/mysqld_safe &
/usr/local/mysql/bin/mysqladmin -u root password '123456'/usr/local/mysql/bin/mysql -u root -p
为了在下次重启服务器的时候可以自动重启相关服务,需要将MySQL加入到系统服务里面,这样就可以用service mysqld start|stop|restart进行操作
cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld
#把msql的脚本文件拷到系统的启动目录下
cd /etc/init.d/
chkconfig --add mysqld #将mysql加到启动服务列表里
chkconfig mysqld on #让系统启动时自动打开mysql服务,如果指定级别,用--level参数
=======================================
tar zxvf libiconv-1.13.1.tar.gzcd libiconv-1.13.1/./configure --prefix=/usr/localmakemake installcd ../
error while loading shared libraries: libiconv.so.2: cannot open shared object file: No such file or directorymake[1]: *** [install-pear-installer] 错误 127
make: *** [install-pear] Error 2
ln -s /usr/local/lib/libiconv.so.2 /usr/lib/libiconv.so.2
cd /usr/srctar zxvf php-5.2.14.tar.gzgzip -cd php-5.2.14-fpm-0.5.14.diff.gz | patch -d php-5.2.14 -p1cd php-5.2.14/./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/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-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --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-soapmake ZEND_EXTRA_LIBS='-liconv'make installcp php.ini-dist /usr/local/php/etc/php.ini
cd /usr/srctar zxvf memcache-2.2.5.tgzcd memcache-2.2.5//usr/local/php/bin/phpize./configure --with-php-config=/usr/local/php/bin/php-configmakemake installcd ../
########################################
tar jxvf eaccelerator-0.9.6.1.tar.bz2cd eaccelerator-0.9.6.1//usr/local/php/bin/phpize./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-configmakemake installcd ../
########################################
tar zxvf PDO_MYSQL-1.0.2.tgzcd PDO_MYSQL-1.0.2//usr/local/php/bin/phpize./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysqlmakemake installcd ../
########################################
tar zxvf ImageMagick.tar.gzcd ImageMagick-6.5.1-2/./configuremakemake installcd ../
########################################
tar zxvf imagick-2.3.0.tgzcd imagick-2.3.0//usr/local/php/bin/phpize./configure --with-php-config=/usr/local/php/bin/php-configmakemake installcd ../
#vi /usr/local/php/etc/php.ini
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"
extension = "memcache.so"extension = "pdo_mysql.so"extension = "imagick.so"
#mkdir -p /usr/local/eaccelerator_cache#vi /usr/local/php/etc/php.ini
[eaccelerator]zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"eaccelerator.shm_size="64"eaccelerator.cache_dir="/usr/local/eaccelerator_cache"eaccelerator.enable="1"eaccelerator.optimizer="1"eaccelerator.check_mtime="1"eaccelerator.debug="0"eaccelerator.filter=""eaccelerator.shm_max="0"eaccelerator.shm_ttl="3600"eaccelerator.shm_prune_period="3600"eaccelerator.shm_only="0"eaccelerator.compress="1"eaccelerator.compress_level="9"
/usr/sbin/groupadd www/usr/sbin/useradd -g www www
vi /usr/local/php/etc/php-fpm.conf
/usr/local/php/sbin/php-fpm start
tar zxvf pcre-8.10.tar.gzcd pcre-8.10/./configuremake && make installcd ../
########################################
tar zxvf nginx-0.8.46.tar.gzcd nginx-0.8.46/./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_modulemake && make installcd ../
location ~ \.php$ {root html;fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;include fastcgi_params;}
/usr/local/nginx/sbin/nginx -t
/usr/local/nginx/sbin/nginx
ulimit -SHn 65535/usr/local/php/sbin/php-fpm start/usr/local/nginx/sbin/nginx
vi /usr/local/nginx/html/phpinfo.php
使用技巧:
/usr/local/nginx/sbin/nginx -t
the configuration file /usr/local/nginx/conf/nginx.conf syntax is okthe configuration file /usr/local/nginx/conf/nginx.conf was tested successfully
/usr/local/nginx/sbin/nginx -s reload
ps -ef | grep "nginx: master process" | grep -v "grep" | awk -F ' ' '{print $2}'
kill -HUP 6302
kill -HUP `cat /usr/local/nginx/nginx.pid`
convert -version
参考李宴的Nginx 0.8.x + PHP 5.2.13(FastCGI)搭建胜过Apache十倍的Web服务器(第6版)[原创]而整理的.