Nginx migrates openResty
1.1 Version Selection
- The current
2020-12-31
Nginx latest stable version 1.18.0
- OpenResty 1.17.8. X version
- OpenResty 1.17.8. X version
Based on the above information, openResty chose version 1.17.8.2
1.2 openResty installation
- Download & Extract
CD/usr/local # download wget https://openresty.org/download/openresty-1.17.8.2.tar.gz # extract tar - XVF openresty - 1.17.8.2. Tar. GzCopy the code
- The source code to compile
Openresty-1.17.8.2 openResty-1.17.8.2 ./configure # or below, followed by parameters, /configure --prefix=/usr/local/openresty/ --with-http_stub_status_module --with-luajit --without-http_redis2_module --with-http_iconv_module --with-http_postgres_module --with-stream gmake & & gmake installCopy the code
- Adding environment variables
1, open the configuration file: vim: / etc/profile, add 2 code PATH = / usr/local/openresty/nginx/sbin: $PATH export PATH 3, exit save 4, executed command: 5. Run the echo $PATH command to check whether the command takes effectCopy the code
- Add repository execution command (install OpenResty nginx)
yum install yum-utils
Copy the code
If you do not know the kernel version of your system, please refer to the following instructions:
Uname -a # Displays information about the computer and operating system. Cat /proc/version # indicates which kernel version is running. Cat /etc/issue # displays release information. Lsb_release -A #(for all Linux distributions, including Redhat, SuSE, Debian, etc., but in Debian to install LSB)Copy the code
Kernel for red hat here, not this kernel please refer to the website: https://openresty.org/cn/linux-packages.html
# add the yum repo:*
wget https://openresty.org/package/rhel/openresty.repo
sudo mv openresty.repo /etc/yum.repos.d
Copy the code
- Perform the installation
# update the yum index:* sudo yum check-update # install openresty yum install openresty # subscription-manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager To register, Setting up the Install Process TPS: / / openresty. Org/package/centos/sErver/x86 64 / repodata repomd. XML: 【Errno 14】 Problem making SSL connection Trying other mirror. Error:Cannot retrieve repository metadata (repomd.xml) For repository:openresty. Please verify its path and try again The server fails to connect to the remote repository using SSL. To solve this problem, modify the repository configuration and use HTTP instead of SSL. Execution: vim/etc/yum. Repos. D/openresty. 'one: baseurl HTTPS to the address of the HTTP; /usr/local/openresty: /usr/local/openresty: /usr/local/openrestyCopy the code
- Check the nginx
nginx -t
Nginx-v or nginx-v
At this point, openResty’s nginx has been installed, the system has been switched to openResty, and restarted (nginx -s reload)nginx will read the configuration files in the openResty directory.
1.3 restart nginx
1.3.1 Specifying the startup configuration file mode
# conf-path=*path*: -c file
nginx -s reload -c /etc/nginx/nginx.conf
Copy the code
If executed nginx -s reload restart nginx, note/usr/local/openresty/nginx/conf/nginx. The pid in the conf configuration items consistent with the history to install nginx configuration file
1.3.2 Reading the Default Configuration File
- Recompile openResty
/configure --conf-path=/etc/nginx/nginx.conf installCopy the code
- validation
nginx -t
- restart
nginx -s reload
Switch between openResty and Nginx
- Nginx installation path
Install the test machine in /usr/local/nginx
2.1 OpenResty cuts to nginx
- Checking the Current Version
- Backup openresty nginx
# switch catalog CD/usr/local/openresty/nginx/sbin # backup nginx file mv nginx nginx. OpenrestyCopy the code
- Nginx file replacement
# use installed under the nginx service nginx file replace adjustable openResty service nginx cp/usr/local/nginx/sbin/nginx/usr/local/openResty/nginx/sbin /Copy the code
- Check the Nginx version again
2.2 Nginx cuts back to openResty
- Train of thought
Just cut back to the openResty compiled nginx file
- Operation directory & command
Directory: CD/usr/local/openresty/nginx/sbin command: mv nginx nginx. 1 x mv nginx. Openresty nginx
- Check the version