In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Centos7 compile and install nginx:
First, make sure that the necessary tools for compilation and installation are running on the system:
# yum groupinstall "development tools"server platform development"
Download PCRE version 4.48.40 (required for ngx_http_rewrite_module module)
# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz
2 download zlib (required for ngx_http_gzip_module module)
# wget https://zlib.net/zlib-1.2.11.tar.gz
3 download openssl (required for http_ssl_module module)
# wget https://github.com/openssl/openssl/archive/OpenSSL_1_1_0f.tar.gz
3 download nginx
# wget https://nginx.org/download/nginx-1.12.1.tar.gz
Official commencement of construction:
1 decompress PCRE
# tar xzvf pcre-8.40.tar.gz-C / usr/local/src/
2 decompress zlib
# tar xzf zlib-1.2.11.tar.gz-C / usr/local/src/
3 decompress openssl
# tar xzf OpenSSL_1_1_0f.tar.gz-C / usr/local/src/
4 install nginx
To add a nginx user:
# groupadd nginx # useradd-g nginx-s / sbin/nologin nginx
Create a nginx log save directory
# mkdir / var/log/nginx
Extract the installation package
# tar xzf nginx-1.12.1.tar.gz # cd nginx-1.12.1 #. / configure-prefix=/usr/local/nginx\-conf-path=/etc/nginx/nginx.conf\-pid-path=/var/log/nginx/run/nginx.pid\-error-log-path=/var/log/nginx/error.log\-http-log-path=/var/log/nginx/access.log\-- User=nginx-- group=nginx\-- with-select_module\-- with-poll_module\-- with-http_ssl_module\-- with-pcre=/usr/local/src/pcre-8.40\-- with-zlib=/usr/local/src/zlib-1.2.11\-with-openssl=/usr/local/src/openssl-OpenSSL_1_1_0f # make & & make install
At this point, nginx has been installed, you can go to / usr/local/nginx/sbin/ and start nginx by running the. / nginx command
5 configure NGINX systemd service (Note: configure path information according to your own configuration! )
# vim / lib/systemd/system/nginx.service [Unit] Description=The NGINX HTTP and reverse proxy server After=syslog.target network.target remote-fs.target nss-lookup.target [Service] Type=forking PIDFile=/var/log/nginx/run/nginx.pid ExecStartPre=/usr/local/nginx/sbin/nginx-t ExecStart=/usr/local/nginx/sbin/nginx ExecReload=/bin/kill-s HUP $MAINPID ExecStop=/bin/kill-s QUIT $MAINPID PrivateTmp=true [Install] WantedBy=multi-user.target
At this time
Start nginx
# systemctl start nginx
View statu
# systemctl status nginx
Stop nginx
# systemctl stop nginx
6 compiled and installed nginx will not do log segmentation
# vim logrotate.sh #! / bin/bash cd / var/log/nginx mv access.log access.log.$ (date +% F) mv error.log error.log.$ (date +% F) kill-USR1 $(cat / var/log/nginx/run/nginx.pid) sleep 1 gzip access.log.$ (date +% F) gzip error.log.$ (date +% F)
Timed log rotation is realized through crontab.
If you have any questions about the above, please correct them.
Thank you!
Reference link https://nginx.org/en/docs/configure.html
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.