Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6091691
  • 博文数量: 2759
  • 博客积分: 1021
  • 博客等级: 中士
  • 技术积分: 4091
  • 用 户 组: 普通用户
  • 注册时间: 2012-03-11 14:14
文章分类

全部博文(2759)

文章存档

2019年(1)

2017年(84)

2016年(196)

2015年(204)

2014年(636)

2013年(1176)

2012年(463)

分类: 架构设计与优化

2014-03-14 09:41:12

1,解压缩软件
     所需依赖包

  1. yum install -y libxml2-devel libjpeg-devel libpng-devel freetype-devel openssl-devel libcurl-devel libmcrypt-devel
  2. tar zxvf libmcrypt-2.5.8.tar.gz
  3. cd libmcrypt-2.5.8
  4. vi INSTALL
  5.  ./configure
  6.  make && make instal

  7.    
php编译安装
  1.  tar xvjf php-5.4.25.tar.bz2 
  2.  cd php-5.4.25
  3.  mkdir -p /usr/local/php
   2,编译  
    ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml  --enable-sockets --with-apxs2=/usr/local/apache2/bin/apxs --with-mcrypt  --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2  --enable-maintainer-zts  --enable-fpm

错误:
  configure: error: mcrypt.h not found. Please reinstall libmcrypt.
  解决办法:
  libmcrypt-2.5.8.tar.gz
  编译安装
  [root@wang soft]# tar -zxvf libmcrypt-2.5.8.tar.gz  
  [root@wang soft]# cd libmcrypt-2.5.8
  [root@wang libmcrypt-2.5.8]# ./configure
  [root@wang libmcrypt-2.5.8]# make && make install
  同理安装bzip2-1.0.6.tar.gz
   
    3,为php-fpm提供Sysv init脚本,并将其添加至服务列表:
# cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
# chmod +x /etc/rc.d/init.d/php-fpm
# chkconfig –add php-fpm
# chkconfig php-fpm on
    4,为php-fpm提供配置文件:
# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
    5,编辑php-fpm的配置文件:
# vim /usr/local/php/etc/php-fpm.conf
配置pm.的相关选项为你所需要的值,并启用pid文件(如下最后一行):

  1. pm.max_children = 50
  2. pm.start_servers = 5
  3. pm.min_spare_servers = 2
  4. pm.max_spare_servers = 8
  5. pid = /usr/local/php/var/run/php-fpm.pid
    6,接下来就可以启动php-fpm了:
# service php-fpm start
使用如下命令来验正(如果此命令输出有中几个php-fpm进程就说明启动成功了):
# ps aux | grep php-fpm
[root@www conf]# ps aux | grep php-fpm
root     25424  0.0  0.4 182452  4152 ?        Ss   20:30   0:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)                                                                    
nobody   25425  0.0  0.5 182452  5648 ?        S    20:30   0:00 php-fpm: pool www                                                                                                            
nobody   25426  0.0  0.5 182816  5756 ?        S    20:30   0:00 php-fpm: pool www                                                                                                            
root     25618  0.0  0.0 103236   892 pts/0    S+   20:53   0:00 grep php-fpm
     7,编辑/usr/ocal/nginx/conf/fastcgi_params,将其内容更改为如下内容:

  1. fastcgi_param GATEWAY_INTERFACE CGI/1.1;
  2. fastcgi_param SERVER_SOFTWARE nginx;
  3. fastcgi_param QUERY_STRING $query_string;
  4. fastcgi_param REQUEST_METHOD $request_method;
  5. fastcgi_param CONTENT_TYPE $content_type;
  6. fastcgi_param CONTENT_LENGTH $content_length;
  7. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  8. fastcgi_param SCRIPT_NAME $fastcgi_script_name;
  9. fastcgi_param REQUEST_URI $request_uri;
  10. fastcgi_param DOCUMENT_URI $document_uri;
  11. fastcgi_param DOCUMENT_ROOT $document_root;
  12. fastcgi_param SERVER_PROTOCOL $server_protocol;
  13. fastcgi_param REMOTE_ADDR $remote_addr;
  14. fastcgi_param REMOTE_PORT $remote_port;
  15. fastcgi_param SERVER_ADDR $server_addr;
  16. fastcgi_param SERVER_PORT $server_port;
  17. fastcgi_param SERVER_NAME $server_name;
     8,nginx配置文件
     在主文件/usr/local/nginx/conf/nginx.conf配置文件中需插入include vhost/其中vhost为/usr/local/nginx/conf/中的新建目录
  1. vi www.conf
  2.     server {
  3.         listen 80;
  4.         server_name www.wang.tiger;
  5.         root /var/www/html;
  6.         charset utf-8;
  7.         access_log logs/www.access.log;
  8.         location / {
  9.             index index.php index.html index.htm;
  10.         }
  11.         error_page 404 /404.html;
  12.          error_page 500 502 503 504 /50x.html;
  13.         location = /50x.html {
  14.             root html;
  15.         }
  16.         location ~ \.php$ {
  17.             #root html;
  18.             fastcgi_pass 127.0.0.1:9000;
  19.             fastcgi_index index.php;
  20.             fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
  21.             include fastcgi_params;
  22.         }
  23. }
  9,重启nginx
   service nginx restart
     10,在/usr/html新建index.php的测试页面,测试php是否能正常工作:

  1. <?php
  2. phpinfo();
  3. ?>



阅读(801) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~