fedora 15+php 5.3.8+nginx-1.1.6

注意:從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 ../

注意: mcrypt庫需要在安裝完libmcrypt,mhash庫後再安裝,並需要執行上面所有ln語句才能安裝成功


三.創建相關用戶

groupadd www
useradd -g www -s /sbin/nologin -M www

四.編譯PHP

 ./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庫:
tar zxvf pcre-8.10.tar.gz
cd pcre-8.10/
./configure
make && make install
2. 安裝nginx

   ./configure --prefix=/usr/local/nginx
    make
    make install
3.配置nginx.conf

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







>













發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章