Linux下安装nginx和php

1. 安装nginx,传送门:http://www.cnblogs.com/emberd/p/4536238.html
2. 下载php源码压缩包:php-5.6.1.tar.gz
3. 解压后进入目录,执行编译前配置

./configure --prefix=/usr/local/php5.6.1 --enable-mbstring --with-mcrypt --with-mhash --enable-fpm --with-iconv

中途会报错缺少依赖库,依次安装

libxml2:

yum install -y libxml2-devel

libmcrypt:

源码安装libmcrypt-2.5.7.tar.gz

4. 修改MakeFile文件

1 vim Makefile
2 EXTRA_LIBS=后加上-liconv
3 make
4 make install

5. 修改php配置文件

1 cd /usr/local/php5.6.1/etc
2 cp php-fpm.conf.default php-fpm.conf
3 修改如下参数:
4 pm.max_children = 40
5 pm.start_servers = 20
6 pm.min_spare_servers = 5
7 pm.max_spare_servers = 35
8 pm.max_requests = 500
9 listen = 127.0.0.1:40000

6. 启动php-fpm

usr/local/php5.6.1/sbin/php-fpm &

7. 修改nginx配置文件

location / {
    root   /data/www;
    index  index.html index.htm;
}

location ~ \.php$ {
    root           /data/www;
    fastcgi_pass   127.0.0.1:40000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME /data/www$fastcgi_script_name;
    include        fastcgi_params;
}

8. 重载nginx

/usr/local/nginx/sbin/nginx -s reload

 

  • php-fpm关闭与重载

php-fpm 关闭:
kill -INT `cat /usr/local/php5.6.1/var/run/php-fpm.pid`
php-fpm 重载:
kill -USR2 `cat /usr/local/php5.6.1/var/run/php-fpm.pid`

  • 开启mysql扩展

1. 进入php源码目录

cd ext/mysql/

2. 执行php扩展脚本

/usr/local/php5.6.1/bin/phpize

3. 编译前配置

./configure --with-php-config=/usr/local/php5.6.1/bin/php-config --with-mysql=/data/software/mysql

注:/data/software/mysql为mysql源码目录

4. 编译并安装

1 make
2 make install

注意生成的mysql.so位置,后面需要使用,例如:Installing shared extensions:/usr/local/php5.6.1/lib/php/extensions/no-debug-non-zts-20131226/

5. 修改php.ini,增加

extension=/usr/local/php5.6.1/lib/php/extensions/no-debug-non-zts-20131226/mysql.so

6. 重启php-fpm

 

posted @ 2015-11-17 17:40  桔子大  阅读(695)  评论(0编辑  收藏  举报
/*火箭返回顶层*/