首页 >后端开发 >php教程 > nginx +php 环境筹建之php安装

nginx +php 环境筹建之php安装

WBOY
WBOY原创
2016-06-13 12:37:56930浏览

nginx +php 环境搭建之php安装

?

安装php-5.4.4

?

# tar -jxvf php-5.4.4.tar.bz2   
# cd php-5.4.4  
# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --enable-fpm --enable-sockets --enable-sysvshm  --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-libxml-dir=/usr --enable-xml  --with-mhash --with-mcrypt  --with-config-file-path=/etc/php --with-config-file-scan-dir=/etc/php --with-bz2 --with-curl  
# make   
# make install  
 
复制主配置文件  
# cp php.ini-production /etc/php.ini  
 
服务脚本  
# cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm  
# chmod +x /etc/rc.d/init.d/php-fpm   
 
修改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  
pm.max_children = 50   最多多少子进程  
pm.start_servers = 5   刚开始启动多少进程  
pm.min_spare_servers = 2  最少多少空闲进程  
pm.max_spare_servers = 8  最多多少空闲进程  


<span>#?service?php-fpm?start </span>

?编辑/etc/nginx/nginx.conf,启用如下选项:

?

    location ~ \.php$ {  
                root           html;  
                fastcgi_pass   127.0.0.1:9000;  
                fastcgi_index  index.php;  
                fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;  
                include        fastcgi_params;  
            }  

?

编辑/etc/nginx/fastcgi_params,添加修改如下内容:

?

fastcgi_param? SCRIPT_FILENAME??? $document_root$fastcgi_script_name;

?

添加php格式的主页,如下所示:
location / {
??????????? root?? html;
??????????? index? index.php index.html index.htm;
??????? }
???????
重启服务:
# service nginx restart

写入测试文件,访问查看

?

?

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn