Iii. Install nginx and os6.8nginx in 64-bit cent os6.8 of Java Runtime Environment
Article reprinted: http://blog.csdn.net/tao_627/article/details/45249267
According to work needs, now we need to install the nginx server. We could have directly installed the rpm packages prepared by others, but in the spirit of hard work and time-consuming, I decided to download the latest nginx source code from the official website for installation. The installation process is recorded below.
The following installation assumes that the root user is logged on and executed
1. Install the dependent Library
These dependent libraries mainly include g ++, gcc, openssl-devel, pcre-devel, and zlib-devel.
Yum-y install make gcc-c ++ glibc-devel lsof
Yum-y install pcre-devel
Yum-y install zlib-devel
Yum-y install openssl -- devel
2. Download the source code package
Cd/usr/local/src
Wget-d "http://nginx.org/download/nginx-1.8.0.tar.gz"
Tar zxvf nginx-1.8.0.tar.gz
Cd nginx-1.8.0
./Configure -- prefix =/usr/local/nginx -- with-http_stub_status_module -- with-http_realip_module -- with-http_ssl_module
Make-j 4
Make install
3. Verify that nginx is started
Note that, before nginx is set as a system service, it is only a validation start test. Run the following command to view the path of the nginx executable program:
Whereis nginx
The default value is under the/usr/local/nginx directory.
Ulimit-SHn 65535
/Usr/local/nginx/sbin/nginx
4. Add nginx as the System Service
Add the following file
Vim/etc/init. d/nginx
[Html]View plain copy
- #! /Bin/sh
- #
- # Nginx-this script starts and stops the nginx daemon
- #
- # Chkconfig:-85 15
- # Description: Nginx is an HTTP (S) server, HTTP (S) reverse \
- # Proxy and IMAP/POP3 proxy server
- # Processname: nginx
- # Config:/etc/nginx. conf
- # Config:/etc/sysconfig/nginx
- # Pidfile:/var/run/nginx. pid
- # Source function library.
- ./Etc/rc. d/init. d/functions
- # Source networking configuration.
- ./Etc/sysconfig/network
- # Check that networking is up.
- ["$ NETWORKING" = "no"] & exit 0
- Nginx = "/usr/local/nginx/sbin/nginx"
- Prog = $ (basename $ nginx)
- NGINX_CONF_FILE = "/usr/local/nginx/conf/nginx. conf"
- [-F/etc/sysconfig/nginx] &./etc/sysconfig/nginx
- Lockfile =/var/lock/subsys/nginx
- Start (){
- [-X $ nginx] | exit 5
- [-F $ NGINX_CONF_FILE] | exit 6
- Echo-n $ "Starting $ prog :"
- Daemon $ nginx-c $ NGINX_CONF_FILE
- Retval =$?
- Echo
- [$ Retval-eq 0] & touch $ lockfile
- Return $ retval
- }
- Stop (){
- Echo-n $ "Stopping $ prog :"
- Killproc $ prog-QUIT
- Retval =$?
- Echo
- [$ Retval-eq 0] & rm-f $ lockfile
- Return $ retval
- Killall-9 nginx
- }
- Restart (){
- Configtest | return $?
- Stop
- Sleep 1
- Start
- }
- Reload (){
- Configtest | return $?
- Echo-n $ "Reloading $ prog :"
- Killproc $ nginx-HUP
- RETVAL =$?
- Echo
- }
- Force_reload (){
- Restart
- }
- Configtest (){
- $ Nginx-t-c $ NGINX_CONF_FILE
- }
- Rh_status (){
- Status $ prog
- }
- Rh_status_q (){
- Rh_status>/dev/null 2> & 1
- }
- Case "$1" in
- Start)
- Rh_status_q & exit 0
- $1
- ;;
- Stop)
- Rh_status_q | exit 0
- $1
- ;;
- Restart | configtest)
- $1
- ;;
- Reload)
- Rh_status_q | exit 7
- $1
- ;;
- Force-reload)
- Force_reload
- ;;
- Status)
- Rh_status
- ;;
- Condrestart | try-restart)
- Rh_status_q | exit 0
- ;;
- *)
- Echo $ "Usage: $0 {start | stop | status | restart | condrestart | try-restart | reload | force-reload | configtest }"
- Exit 2
- Esac
Chmod + x/etc/init. d/nginx
Register nginx Service
Chkconfig -- add nginx
Chkconfig -- list nginx
If you see that the nginx service is not opened at any level, you can use the following command again to explicitly enable it at different levels:
Chkconfig -- level 2345 nginx on
Adopt again
Chkconfig -- list nginx
Check whether it is enabled at the above levels. The reason for this is that we hope that the nginx service will be restarted automatically after the power is down.
4. modify the configuration file nginx. conf.
Configure nginx. conf based on the business logic. The specific content is ignored here.
After the configuration is complete, retest and load nginx. conf
Service nginx configtest
Service nginx reload
Let nginx run in the new configuration.
5. Problems and errors during installation
The following error is displayed because of an error in nginx. conf:
Nginx: [emerg] unknown directive "lua_shared_dict" in/usr/local/nginx/conf/nginx. conf: 11
Nginx: [emerg] unknown directive "rewrite_by_lua_file" in/usr/local/nginx/conf/nginx. conf: 136
Solution
These two errors are reported because these two commands are added to nginx. conf to delete the corresponding configuration and logic.
Reference
Https://www.centos.bz/2012/12/openresty-nginx-block-cc-attack-deploy/
I will comment them out temporarily
-
Top
-
0
-
Step on
-
0
View comments