Nginx系列(一安裝nginx)

WBOY
發布: 2016-08-08 09:24:06
原創
941 人瀏覽過

零. 聲明:

以下內容適用於linux環境下,採用源碼方式安裝

Nginx官網安裝指南:http://wiki.nginx.org/InstallChs

1

一. 下載ng網inx

1

1. :http://nginx.org/en/download.html
2.Git下載:https://github.com/nginx/nginx

二. 必要的依賴庫

1.pcre

<code>yum -y <span>install</span> pcre* <span>#nginx rewrite模块</span></code>
登入後複製

2.gcc

<code>yum -y <span>install</span> gcc gcc-c++ <span>#编译nginx</span></code>
登入後複製

三. nginx

2.gcc

<code><span>mkdir</span> -p /web/nginx</code>
登入後複製
三. nginx

2.gcc

<code>groupadd www
useradd <span>-r</span><span>-g</span> www www</code>
登入後複製
2.建立運行用戶

<code><span>.</span>/configure <span>--</span>prefix<span>=</span>/web/nginx <span>--</span><span>with</span><span>-http_stub_status_module</span><span>--</span><span>with</span><span>-pcre</span></code>
登入後複製
3.編輯編譯參數

<code><span>make</span> && <span>make</span> install</code>
登入後複製
配置成功成功後,輸出如下內容

4.安裝後

<code>/web/nginx/sbin/nginx</code>
登入後複製
四. 啟動nginx

<code><span>#user  nobody;</span><span>worker_processes</span><span>1</span>;

<span>#error_log  logs/error.log;</span><span>#error_log  logs/error.log  notice;</span><span>error_log</span>  logs/error.log  <span>info</span>;

<span>pid</span>        logs/nginx.pid;


<span>events</span> {
    <span>worker_connections</span><span>1024</span>;
}


<span>http</span> {
    <span>include</span>       mime.types;
    <span>default_type</span>  application/octet-stream;

    <span>log_format</span>  main  <span>'<span>$remote_addr</span> - <span>$remote_user</span> [<span>$time_local</span>] "<span>$request</span>" '</span><span>'<span>$status</span><span>$body_bytes_sent</span> "<span>$http_referer</span>" '</span><span>'"<span>$http_user_agent</span>" "<span>$http_x_forwarded_for</span>"'</span>;

    <span>access_log</span>  logs/access.log  main;

    <span>sendfile</span><span>on</span>;
    <span>#tcp_nopush     on;</span><span>#keepalive_timeout  0;</span><span>keepalive_timeout</span><span>65</span>;

    <span>#gzip  on;</span><span>server</span> {
        <span>listen</span><span>80</span>;
        <span>server_name</span>  localhost;

        <span>#charset koi8-r;</span><span>#access_log  logs/host.access.log  main;</span><span>location</span> / {
            <span>root</span>   html;
            <span>index</span>  index.html index.htm;
        }

        <span>#error_page  404              /404.html;</span><span># redirect server error pages to the static page /50x.html</span><span>#</span><span>error_page</span><span>500</span><span>502</span><span>503</span><span>504</span>  /50x.html;
        <span>location</span> = /50x.html {
            <span>root</span>   html;
        }

        <span># proxy the PHP scripts to Apache listening on 127.0.0.1:80</span><span>#</span><span>#location ~ \.php$ {</span><span>#    proxy_pass   http://127.0.0.1;</span><span>#}</span><span># pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000</span><span>#</span><span>#location ~ \.php$ {</span><span>#    root           html;</span><span>#    fastcgi_pass   127.0.0.1:9000;</span><span>#    fastcgi_index  index.php;</span><span>#    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;</span><span>#    include        fastcgi_params;</span><span>location</span><span>~ \.php$</span> {
        <span>root</span>           /web/www/zhengrui/html/admin;
        <span>fastcgi_pass</span><span>127.0.0.1:9000</span>;
        <span>fastcgi_index</span>  index.php;            
        <span>include</span>        fastcgi_params;
        <span>fastcgi_param</span>   SCRIPT_FILENAME    <span>$document_root</span><span>$fastcgi_script_name</span>;
        <span>fastcgi_param</span>   SCRIPT_NAME        <span>$fastcgi_script_name</span>;
    }

        <span># deny access to .htaccess files, if Apache's document root</span><span># concurs with nginx's one</span><span>#</span><span>#location ~ /\.ht {</span><span>#    deny  all;</span><span>#}</span>
    }


    <span># another virtual host using mix of IP-, name-, and port-based configuration</span><span>#</span><span>#server {</span><span>#    listen       8000;</span><span>#    listen       somename:8080;</span><span>#    server_name  somename  alias  another.alias;</span><span>#    location / {</span><span>#        root   html;</span><span>#        index  index.html index.htm;</span><span>#    }</span><span>#}</span><span># HTTPS server</span><span>#</span><span>#server {</span><span>#    listen       443 ssl;</span><span>#    server_name  localhost;</span><span>#    ssl_certificate      cert.pem;</span><span>#    ssl_certificate_key  cert.key;</span><span>#    ssl_session_cache    shared:SSL:1m;</span><span>#    ssl_session_timeout  5m;</span><span>#    ssl_ciphers  HIGH:!aNULL:!MD5;</span><span>#    ssl_prefer_server_ciphers  on;</span><span>#    location / {</span><span>#        root   html;</span><span>#        index  index.html index.htm;</span><span>#    }</span><span>#}</span>}</code>
登入後複製
3五.偵測是否安裝成功

1.開放埠參考http://longdd.org/index.php/Home/Index/shows/id/158.html

2.訪問127.0.0.1,顯示如下界面,則表示nginx安裝成功

六. 慣例配置

rrreee

以上就介紹了Nginx系列(一安裝nginx),包含了方面的內容,希望對PHP教學有興趣的朋友有幫助。

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板