首页 > 代码库 > Nginx 安装文档 (二)PHP
Nginx 安装文档 (二)PHP
下载、编译安装
wget http://cn2.php.net/distributions/php-5.4.7.tar.gz tar zvxf php-5.4.7.tar.gz cd php-5.4.7 ./configure --prefix=/usr/local/php --enable-fpm --with-mcrypt --enable-mbstring --disable-pdo --with-curl --disable-debug --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex--with-mhash --enable-zip --with-pcre-regex --with-mysql--with-mysqli --with-gd --with-jpeg-dir --with-config-file-path=/etc--with-config-file-scan-dir=/etc/php.d make all install
以上就完成了php-fpm的安装。
下面是对php-fpm运行用户进行设置
cd /usr/local/php cp etc/php-fpm.conf.default etc/php-fpm.conf vim etc/php-fpm.conf修改 user =nginx group = nginx
将配置文件路径连接到/etc/php-fpm下
ln –s /usr/local/php/etc /etc/php-fpm
复制/php-5.4.31/sapi/fpm 下init.d.php-fpm 到/etc/ini.d/php-fpm
cp php-5.4.31/sapi/fpminit.d.php-fpm /etc/init.d/php-fpm
修改nginx配置文件为,nginx.conf
其中server段增加如下配置,注意标红内容配置,否则会出现No inputfile specified.错误
# passthe PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location~ \.php$ { roothtml; fastcgi_pass127.0.0.1:9000; fastcgi_indexindex.php; fastcgi_paramSCRIPT_FILENAME $document_root$fastcgi_script_name; includefastcgi_params; }
创建php文件
在/usr/local/nginx/html下创建index.php文件,输入如下内容
<?php echo phpinfo(); ?>
启动php-fpm服务
/etc/init.d/php-fpm start /etc/ini.d/nginx restart
本文出自 “Smurf Linux运维” 博客,请务必保留此出处http://jin771998569.blog.51cto.com/2147853/1536509
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。