本文使用软件版本:

Nginx:             nginx-1.0.5
MySQL:          mysql-5.0.40
PHP :               php-5.2.10
libmcrypt:         libmcrypt-2.5.7
mhash ;            mhash-0.8.15
mcrypt:             mcrypt-2.6.8

其他rpm软件使用CentOS5.5自带rpm包

 

Nginx:

 

下载

 

 
  
  1. # wget http://nginx.org/download/nginx-1.0.5.tar.gz 

安装:

  安装依赖:

 
  
  1. # yum  -y install zlib-devel pcre-devel openssl-devel  

 

编译安装:

 
  
  1. # ./configure --prefix=/usr/local/nginx\   
  2. --with-openssl=/usr/include/openssl\  #启用ssl   
  3. --with-pcre\                          #启用正规表达式)   
  4. --with-http_stub_status_module        #安装可以查看nginx状态的程序   
  5.  
  6.    
  7. # make && make install 

 

Nginx的启动,停止

 
  
  1. # /usr/local/nginx/sbin/nginx   启动nginx  
  2. # kill –HUP `cat /usr/local/nginx/logs/nginx.pid` 重新启动  
  3. # kill -9 `cat /usr/local/nginx/logs/nginx.pid` 停止nginx  
  4.  

Mysql:

安装依赖

 
  
  1. # yum –y install ncurses-devel 

安装:

 
  
  1. # useradd –M –s /sbin/nologin mysql  
  2. # tar –zxvf mysql-5.0.40  
  3. # ./configure --prefix=/usr/local/mysql --with-ssl --with-readline --with-big-tables --enable-assembler  
  4. # make && make install   
  5. # cp support-files/mymedium.cnf /etc/my.cnf  
  6. # cp support-files/mysql.server /etc/init.d/mysqld  
  7. # chmod +x /etc/init.d/mysqld  
  8. # cd /usr/local/mysql  
  9. # bin/mysql_install_db –user=mysql 
  10. # chown –R root.mysql ./  
  11. # chown –R mysql var/  
  12. # ln –sf /usr/local/mysql/bin/mysql /usr/bin  
  13. # echo ‘/usr/local/msyql/lib/mysql’ >> /etc/ld.so.conf  
  14. # ldconfig  
  15.  
  16. # for b in `ls /usr/local/mysql/include/mysql/`:  
  17. > do  
  18. > ln –s /usr/local/mysql/include/mysql/”$b” /usr/include/”$b”  
  19. > done  

 

 

PHP:

安装rpm依赖:

 
  
  1. # yum –y install libxml2-devel curl-devel libpng-devel openldap-devel  
  2.  

 

安装源码包依赖:

 

 
  
  1. # wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz  
  2.  
  3. # tar –zxvf libmcrypt-2.5.7.tar.gz  
  4.  
  5. # cd libmcrypt-2.5.7  
  6.  
  7. # ./configure   
  8.  
  9. # make && make install  
  10.  
  11. # ldconfig  
  12.  

 

 

 
  
  1. # wget http://downloads.sourceforge.net/project/mhash/mhash/0.8.15/mhash-0.8.15.tar.gz?r=  
  2.  
  3. &ts=1312522467&use_mirror=cdnetworks-kr-1  
  4.  
  5. # tar –zxvf mhash-0.8.15.tar.gz  
  6.  
  7. # cd mhash-0.8.15  
  8.  
  9. # ./configure   
  10.  
  11. # make &&make install  
  12.  
  13.    
  14.  

为了一下能正常安装,为上面装的两个软件的lib建立软连接

 
  
  1. for b in `ls /usr/local/lib/libmcrypt.*`:  
  2.  
  3. > do  
  4.  
  5. > file=`echo “$b” | awk –F/ ‘{print $5}’`  
  6.  
  7. > ln –s “$b” /usr/lib/”$file”  
  8.  
  9. >done  
  10.  
  11.    
  12.  
  13. for b in `ls /usr/local/lib/libmhash.*`:  
  14.  
  15. > do  
  16.  
  17. > file=`echo “$b” | awk –F/ ‘{print $5}’`  
  18.  
  19. > ln –s “$b” /usr/lib/”$file”  
  20.  
  21. > done  
  22.  

 

 

 
  
  1. # wget http://cdnetworks-kr-1.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.  
  2.  
  3. tar.gz  
  4.  
  5. # tar –zxvf mcrypt-2.6.8.tar.gz  
  6.  
  7. # cd mcrypt-2.6.8  
  8.  
  9. # ./configure  
  10.  
  11. # make && make install  
  12.  

 

安装FPM补丁

下载:

 
  
  1. # wget http://php-fpm.org/downloads/php-5.2.10-fpm-0.5.11.diff.gz 

打补丁

 
  
  1. # gzip -d php-5.2.10-fpm-0.5.11.diff.gz   
  2. # cd php-5.2.10  
  3. # patch -p1 < ../php-5.2.10-fpm-0.5.11.diff 

 

编译安装PHP:

 
  
  1. # tar -zxvf php-5.2.10.tar.bz2
  2. # cd php-5.2.10
  3. #  ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql/ --with-zlib --enable-xml --disable-rpath --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --with-curl --with-curlwrappers --enable-fpm --enable-fastcgi --with-mcrypt --with-gd --with-openssl --with-mhash --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc -enable-zip --enable-soap
  4. # make && make install  
  5.  
  6.    
  7.  

 

为PHP创建配置文件并启动php-cgi:

 
  

 

  1. # cp php.ini-dist /usr/local/php/php.ini  
  2. # ln –s /usr/local/php/bin/php /usr/bin/php  
  3. # vi /usr/local/php/etc/php-fpm.conf # 去掉64 和66行的注释,使用nobody用户启动
  4.  
  5.      63                         <value name="user">nobody</value>
         64
         65                         Unix group of processes
         66                         <value name="group">nobody</value>
  6. # /usr/local/php/sbin/php-fpm start   # 启动phpcgi默认绑定本地端口127.0.0.1:9000
  7.  

然后修改nginx.conf:

 
  
  1. # vi /usr/local/nginx/conf/nginx.conf  
  2.  
  3. 在server{  
  4.  
  5. ….  
  6.  
  7. }  
  8.  
  9. 里添加  
  10.  
  11. location ~ \.php$ {  
  12.  
  13.                 fastcgi_pass    127.0.0.1:9000;  
  14.  
  15.                 fastcgi_index   index.php;  
  16.  
  17.                 fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;  
  18.  
  19.                 include fastcgi_params;  
  20. include fastcgi.conf;
  21.  
  22.         }  
  23.  
  24.    
  25.  

重启nginx