標籤:nginx php php-fpm
下載、編譯安裝
wget http://cn2.php.net/distributions/php-5.4.7.tar.gztar zvxf php-5.4.7.tar.gzcd 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.dmake all install
以上就完成了php-fpm的安裝。
下面是對php-fpm運行使用者進行設定
cd /usr/local/phpcp etc/php-fpm.conf.default etc/php-fpm.confvim etc/php-fpm.conf修改user =nginxgroup = 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