Iii. Install nginx and os6.8nginx in 64-bit cent os6.8 of Java Runtime Environment

Source: Internet
Author: User
Tags install openssl

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
  1. #! /Bin/sh
  2. #
  3. # Nginx-this script starts and stops the nginx daemon
  4. #
  5. # Chkconfig:-85 15
  6. # Description: Nginx is an HTTP (S) server, HTTP (S) reverse \
  7. # Proxy and IMAP/POP3 proxy server
  8. # Processname: nginx
  9. # Config:/etc/nginx. conf
  10. # Config:/etc/sysconfig/nginx
  11. # Pidfile:/var/run/nginx. pid
  12. # Source function library.
  13. ./Etc/rc. d/init. d/functions
  14. # Source networking configuration.
  15. ./Etc/sysconfig/network
  16. # Check that networking is up.
  17. ["$ NETWORKING" = "no"] & exit 0
  18. Nginx = "/usr/local/nginx/sbin/nginx"
  19. Prog = $ (basename $ nginx)
  20. NGINX_CONF_FILE = "/usr/local/nginx/conf/nginx. conf"
  21. [-F/etc/sysconfig/nginx] &./etc/sysconfig/nginx
  22. Lockfile =/var/lock/subsys/nginx
  23. Start (){
  24. [-X $ nginx] | exit 5
  25. [-F $ NGINX_CONF_FILE] | exit 6
  26. Echo-n $ "Starting $ prog :"
  27. Daemon $ nginx-c $ NGINX_CONF_FILE
  28. Retval =$?
  29. Echo
  30. [$ Retval-eq 0] & touch $ lockfile
  31. Return $ retval
  32. }
  33. Stop (){
  34. Echo-n $ "Stopping $ prog :"
  35. Killproc $ prog-QUIT
  36. Retval =$?
  37. Echo
  38. [$ Retval-eq 0] & rm-f $ lockfile
  39. Return $ retval
  40. Killall-9 nginx
  41. }
  42. Restart (){
  43. Configtest | return $?
  44. Stop
  45. Sleep 1
  46. Start
  47. }
  48. Reload (){
  49. Configtest | return $?
  50. Echo-n $ "Reloading $ prog :"
  51. Killproc $ nginx-HUP
  52. RETVAL =$?
  53. Echo
  54. }
  55. Force_reload (){
  56. Restart
  57. }
  58. Configtest (){
  59. $ Nginx-t-c $ NGINX_CONF_FILE
  60. }
  61. Rh_status (){
  62. Status $ prog
  63. }
  64. Rh_status_q (){
  65. Rh_status>/dev/null 2> & 1
  66. }
  67. Case "$1" in
  68. Start)
  69. Rh_status_q & exit 0
  70. $1
  71. ;;
  72. Stop)
  73. Rh_status_q | exit 0
  74. $1
  75. ;;
  76. Restart | configtest)
  77. $1
  78. ;;
  79. Reload)
  80. Rh_status_q | exit 7
  81. $1
  82. ;;
  83. Force-reload)
  84. Force_reload
  85. ;;
  86. Status)
  87. Rh_status
  88. ;;
  89. Condrestart | try-restart)
  90. Rh_status_q | exit 0
  91. ;;
  92. *)
  93. Echo $ "Usage: $0 {start | stop | status | restart | condrestart | try-restart | reload | force-reload | configtest }"
  94. Exit 2
  95. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.