国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > WEB服務 > 正文

5分鐘搭建nginx+php (LNMP)新手專用

2020-03-22 18:18:49
字體:
來源:轉載
供稿:網友
  • 這里要先聲明一下,針對Nginx的php安裝和針對apache的php安裝是有區別的,因為Nginx中的php是以fastcgi的方式結合nginx的,可以理解為nginx代理了php的fastcgi,而apache是把php作為自己的模塊來調用的。

      先把php 和php-fpm編譯安裝吧 請看http://heilinux.blog.51cto.com/6123663/1575582

      修改配置文件

      1 cd php-5.6.2
      cp php.ini-production /usr/local/php/etc/php.inicp /usr/local/php/etc/php-fpm.conf.default.conf  php-fpm.conf

      保存配置文件后,檢驗配置是否正確的方法為:

      /usr/local/php/sbin/php-fpm -t

      如果出現諸如 “test is successful” 字樣,說明配置沒有問題。

      啟動php-fpm

      cp /usr/local/src/php-5.3.27/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpmchmod 755 /etc/init.d/php-fpmservice php-fpm start

      如果想讓它開機啟動,執行:

      chkconfig php-fpm on

      檢測是否啟動:

      ps aux |grep php-fpm
      netstat -ant |grep 9000

      看看是不是有很多個進程(大概20多個)還有你的9000端口開啟了么?。

      》》》》》》》》》》》》》》》》華華麗麗的分隔符《《《《《《《《《《《《《《《《《《《

      安裝nginx

      開始安裝nginx吧

      1 2 wget http://nginx.org/download/nginx-1.6.2.tar.gz //最新穩定版哦

      解壓nginx

      tar zxvf nginx-1.6.2.tar.gz

      配置編譯參數

      cd nginx-1.6.2./configure --prefix=/usr/local/nginx --with-http_realip_module --with-http_sub_module --with-http_gzip_html' target='_blank'>static_module --with-http_stub_status_module  --with-pcre

      編譯nginx

      make

      安裝nginx

      make install

      因為nginx比較小,所以很快就會安裝完,而且也不會出什么錯誤,如果出錯了,yum安裝pcre-devel(嘿嘿,我是這個問題了,至于你出別的問題問度娘吧。j_0058.gif

      》》》》》》》》》》》》》》》》》》華麗的分隔符《《《《《《《《《《《《《《《《《《《《《

      添加一個nginx主程序的符號鏈接

      1 2 ln -sf /usr/local/nginx/sbin/nginx /usr/sbin
      1 nginx -t 測試一下吧,成功了吧,是不是很有成就感,別著急 咱們繼續!

      更改nginx配置

      首先把原來的配置文件清空:

      > /usr/local/nginx/conf/nginx.conf

      “>” 這個符號之前阿銘介紹過,為重定向的意思,單獨用它,可以把一個文本文檔快速清空。

      vim /usr/local/nginx/conf/nginx.conf

      寫入如下內容:

      user nobody nobody;worker_processes 2;error_log /usr/local/nginx/logs/nginx_error.log crit;pid /usr/local/nginx/logs/nginx.pid;worker_rlimit_nofile 51200;events{    use epoll;    worker_connections 6000;}http{    include mime.types;    default_type application/octet-stream;    server_names_hash_bucket_size 3526;    server_names_hash_max_size 4096;    log_format combined_realip '$remote_addr $http_x_forwarded_for [$time_local]'    '$host "$request_uri" $status'    '"$http_referer" "$http_user_agent"';    sendfile on;    tcp_nopush on;    keepalive_timeout 30;    client_header_timeout 3m;    client_body_timeout 3m;    send_timeout 3m;    connection_pool_size 256;    client_header_buffer_size 1k;    large_client_header_buffers 8 4k;    request_pool_size 4k;    output_buffers 4 32k;    postpone_output 1460;    client_max_body_size 10m;    client_body_buffer_size 256k;    client_body_temp_path /usr/local/nginx/client_body_temp;    proxy_temp_path /usr/local/nginx/proxy_temp;    fastcgi_temp_path /usr/local/nginx/fastcgi_temp;    fastcgi_intercept_errors on;    tcp_nodelay on;    gzip on;    gzip_min_length 1k;    gzip_buffers 4 8k;    gzip_comp_level 5;    gzip_http_version 1.1;    gzip_types text/plain application/x-javascript text/css text/htm application/xml;server{    listen 80;    server_name localhost;    index index.html index.htm index.php;    root /usr/local/nginx/html;    location ~ .php$ {        include fastcgi_params;        fastcgi_pass 127.0.0.1:9000;        fastcgi_index index.php;        fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;    }}}

      》》》》》》》》》》》》》》》》你相信么,你已經搞定了LNMP了《《《《《《《《《《《《《《

      測試是否解析php文件

      創建測試文件:

      vim /usr/local/nginx/html/2.php

      內容如下:

      <?php    echo "測試php是否解析";?>

      測試:

       curl localhost/2.php

      看到什么了。。不要懷疑自己的眼睛,不要熱淚盈眶。你已經成功了。

      PHP編程

      鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

  • 發表評論 共有條評論
    用戶名: 密碼:
    驗證碼: 匿名發表
    主站蜘蛛池模板: 翼城县| 申扎县| 永嘉县| 荆门市| 海淀区| 长宁县| 青田县| 山阴县| 涪陵区| 故城县| 西丰县| 谷城县| 蓬溪县| 茂名市| 静宁县| 临汾市| 滦平县| 香格里拉县| 泰和县| 教育| 哈巴河县| 乌鲁木齐市| 天峨县| 东乡县| 区。| 望奎县| 会东县| 石河子市| 永州市| 万源市| 托克逊县| 鄂托克旗| 罗源县| 洪湖市| 重庆市| 榆社县| 新乡市| 拉萨市| 南开区| 衡阳县| 台北县|