nginx +php 環境籌建之php安裝

來源:互聯網
上載者:User
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  最多多少空閑進程  #?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

寫入測試檔案,訪問查看

?

?

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.