注意:从php 5.3.3 起,可以直接使用PHP-FPM了,不需要再以打补丁的形式安装了
附补丁代码:gzip -cd php-5.3.2-fpm-0.5.14.diff.gz | patch -d php-5.3.2 -p1
一.安装相关程序库
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
二.安装php所需程序库
tar zxvf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1/
./configure --prefix=/usr/local
make
make install
cd ../
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure
make
make install
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
make
make install
cd ../../
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make
make install
cd ../
ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure
make
make install
cd ../
三.创建相关用户
groupadd www
useradd -g www -s /sbin/nologin -M www
./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-openssl=/usr --with-png-dir --with-jpeg-dir --with-freetype-dir --with-iconv-dir=/usr/local --enable-gd-native-ttf --with-libxml-dir --with-zlib --with-mhash --with-mcrypt --with-ldap --with-ldap-sasl --with-curl=/usr/local --with-curlwrappers --enable-bcmath --enable-calendar --enable-mbstring --enable-ftp --enable-zip --enable-sockets --enable-exif --enable-zend-multibyte --enable-fpm --with-fpm-user=www --with-fpm-group=www make && make install
cp /usr/local/src/php-5.3.8/php.ini-development etc/php.ini
五.配置php-fpm
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf vim /usr/local/php/etc/php-fpm.conf
查找下面语句,并将前面"#"号去掉。 pid = run/php-fpm.pid error_log = log/php-fpm.log log_level = notice pm.start_servers pm.min_spare_servers pm.max_spare_servers
六.配置php-fpm自启动
cp /usr/local/src/php-5.3.8/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod -R 755 /etc/init.d/php-fpm chkconfig --add php-fpm
七.编译nginx1.1.6
1、安装Nginx所需的pcre库:
2. 安装nginxtar zxvf pcre-8.10.tar.gz cd pcre-8.10/ ./configure make && make install
./configure --prefix=/usr/local/nginx
3.配置nginx.confmake make install
location / { root /usr/www; index index.html index.htm index.php; } location ~ \.php$ { root /usr/www; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name; include fastcgi_params; }
1、在/etc/init.d/目录下创建脚本 vi /etc/init.d/nginx 2、更改脚本权限 chmod 775 /etc/init.d/nginx 3、编写脚本内容 #!/bin/bash # nginx Startup script for the Nginx HTTP Server # it is v.0.0.2 version. # chkconfig: - 85 15 # description: Nginx is a high-performance web and proxy server. # It has a lot of features, but it's not for everyone. # processname: nginx # pidfile: /var/run/nginx.pid # config: /usr/local/nginx/conf/nginx.conf nginxd=/usr/local/nginx/sbin/nginx nginx_config=/usr/local/nginx/conf/nginx.conf nginx_pid=/usr/local/nginx/logs/nginx.pid RETVAL=0 prog="nginx" # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ ${NETWORKING} = "no" ] && exit 0 [ -x $nginxd ] || exit 0 # Start nginx daemons functions. start() { if [ -e $nginx_pid ];then echo "nginx already running...." exit 1 fi echo -n {1}quot;Starting $prog: " daemon $nginxd -c ${nginx_config} RETVAL=$? echo [ $RETVAL = 0 ] && touch /var/lock/subsys/nginx return $RETVAL } # Stop nginx daemons functions. stop() { echo -n {1}quot;Stopping $prog: " killproc $nginxd RETVAL=$? echo [ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /usr/local/nginx/logs/nginx.pid } reload() { echo -n {1}quot;Reloading $prog: " #kill -HUP `cat ${nginx_pid}` killproc $nginxd -HUP RETVAL=$? echo } # See how we were called. case "$1" in start) start ;; stop) stop ;; reload) reload ;; restart) stop start ;; status) status $prog RETVAL=$? ;; *) echo {1}quot;Usage: $prog {start|stop|restart|reload|status|help}" exit 1 esac exit $RETVAL 4、设置开机启动
chkconfig --add nginx
chkconfig nginx on
>