Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Nginx-1.12.0 version (compile and install)-Custom installation path

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Nginx-1.12.0 version (compile and install)-Custom installation path

Installation path: / application/nginx-1.12.0

1. Preparation in advance

Install gcc and gcc-c++ required for compilation

Yum install-y gcc gcc-c++nginx dependency

Pcre-devel 、 openssl-devel 、 zlib-devel

Yum install-y pcre pcre-devel openssl openssl-devel zlib zlib-devel create user nginx Execute nginxuseradd-s / bin/false-M nginx as this user to download the nginx source package and extract it to the current directory cd / toolswget http://nginx.org/download/nginx-1.12.0.tar.gztar-zxf nginx-1.12.0.tar.gz2.nginx to compile and install to generate the Makefile file cd nginx-1.12.0./configure-- user=nginx-- group=nginx-- prefix=/application/nginx-1.12.0/-- with-http_v2 _ module-- with-http_ssl_module-- with-http_sub_module-- with-http_stub_status_module-- with-http_gzip_static_module-- with-pcre compile the source code and install make & & make install3. At the end of the later stage, create a soft link for nginx-1.12.0, remove the version number ln-s / application/nginx-1.12.0/ / application/nginx at the end and add environment variables.

Create a nginx command soft link to an environment variable

Ln-s / application/nginx/sbin/* / usr/local/sbin/4. Configure nginx to enable php support enable php support cd / application/nginxvim conf/nginx.conf in server segment

Find the following, delete the comment character, and replace the / scripts on the penultimate line with $document_root

Before modification

# 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

#}

After modification

Location ~\ .php$ {

Root html

Fastcgi_pass 127.0.0.1:9000

Fastcgi_index index.php

Fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name

Include fastcgi_params

}

The location of this code in server:

Server {

Listen 80

Server_name localhost

Location / {

Root html

Index index.php index.html index.htm

}

Location ~\ .php$ {

Root html

Fastcgi_pass 127.0.0.1:9000

Fastcgi_index index.php

Fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name

Include fastcgi_params

}

}

Note: the value of root in location ~\ .php$ {} block needs to be the same as that of root in location / {} block

5. Common commands check configuration file nginx-t specify other configuration files start nginxnginx-c / application/nginx/conf/nginx.conf.bak start nginxnginx stop nginxnginx-s stop restart nginxnginx-s reload parameter interpretation

-s stop Quick stop nginx

-s quit smooth stop nginx

-s reopen reopens the log file

-s reload smooth overload all configurations

6. Directory introduction [root@www nginx] # tree. ├── conf # configuration files directory │ ├── fastcgi.conf │ ├── fastcgi.conf.default │ ├── fastcgi_params │ ├── fastcgi_params.default # fastcgi * with php │ ├── koi-utf │ ├── koi-win │ ├── mime.types # mime Media Type │ ├── mime.types.default │ ├── nginx.conf # nginx main configuration file │ ├── nginx.conf.default │ ├── scgi_params │ ├── scgi_params.default │ ├── uwsgi_params │ ├── uwsgi_params.default │ └── win-utf ├── html # default site directory │ ├── 50x.html │ └── index.html ├── logs # access log, Error log, pid file directory │ ├── access.log # access log │ ├── error.log # error log │ └── nginx.pid # pid file └── sbin # command directory └── nginx # nginx command file

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report