nginx +php 环境搭建之php安装
# 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 最多多少空闲进程 #?service?php-fpm?start
?编辑/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
写入测试文件,访问查看
?
?