Home > Backend Development > PHP Tutorial > Nginx series (one installation nginx)

Nginx series (one installation nginx)

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-08-08 09:24:06
Original
972 people have browsed it

Zero. Statement:

The following content is applicable to the Linux environment and is installed using source code.

Nginx official website installation guide: http://wiki.nginx.org/InstallChs

1. Download nginx

1. Official website download :http://nginx.org/en/download.html
2. Git download: https://github.com/nginx/nginx

2. Necessary dependent libraries

1.pcre

<code>yum -y <span>install</span> pcre* <span>#nginx rewrite模块</span></code>
Copy after login

2.gcc

<code>yum -y <span>install</span> gcc gcc-c++ <span>#编译nginx</span></code>
Copy after login

3. Install nginx

1. Create an installation folder

<code><span>mkdir</span> -p /web/nginx</code>
Copy after login

2. Create a running user

<code>groupadd www
useradd <span>-r</span><span>-g</span> www www</code>
Copy after login

3. Compile and compile parameters

<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>
Copy after login

After the configuration is successful, the following content is output

4. Compile and install

<code><span>make</span> && <span>make</span> install</code>
Copy after login

After the compilation is successful, the following content is output

4. Start nginx

<code>/web/nginx/sbin/nginx</code>
Copy after login

35. Check whether the installation is successful

1. For open ports, refer to http://longdd.org/index.php/Home/Index/shows/id/158.html

2. Visit 127.0.0.1, if the following interface is displayed, it means that nginx is installed successfully

6. Conventional configuration

<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>
Copy after login

The above has introduced the Nginx series (once installing nginx), including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Error restarting nginx
From 1970-01-01 08:00:00
0
0
0
server - Nginx configuration webapp problem
From 1970-01-01 08:00:00
0
0
0
Nginx default.conf problem
From 1970-01-01 08:00:00
0
0
0
centos7 - NGINX exception occurs
From 1970-01-01 08:00:00
0
0
0
nginx load balancing
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template