Nginx 安裝文檔 (二)PHP

來源:互聯網
上載者:User

標籤: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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.