In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
Most people do not understand the knowledge points of this article "how to install and deploy Nginx in Centos6.5 64-bit", so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "Centos6.5 64-bit how to install and deploy Nginx" article.
A brief introduction to nginx
Nginx is a web server that can also be used for load balancing and reverse proxy. At present, load balancing is the most commonly used.
II. Nginx installation
1. Download nginx and related components
Linux system is centos 6.564 bit, I directly switch to the root user to install
Enter the user directory to download the program
Download related components
[root@localhost src] # wget http://nginx.org/download/nginx-1.10.2.tar.gz omits installation... [root@localhost src] # wget http://www.openssl.org/source/openssl-fips-2.0.10.tar.gz omits installation... [root@localhost src] # wget http://zlib.net/zlib-1.2.11.tar.gz omits installation... [root@localhost Src] # wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz omits the installation.
Install C++ compiler environment. If installed, you can skip it.
[root@localhost src] # yum install gcc-c++ omits the installation. During this period, there will be a confirmation prompt to enter y enter is this ok [yzone]: y to omit the installation.
2. Install nginx and related components
Openssl installation
[root@localhost src] # tar zxvf openssl-fips-2.0.10.tar.gz omits installation. [root@localhost src] # cd openssl-fips-2.0.10 [root@localhost openssl-fips-2.0.10] #. / config & & make & & make install omit installation.
Pcre installation
[root@localhost src] # tar zxvf pcre-8.40.tar.gz omits installation. [root@localhost src] # cd pcre-8.40 [root@localhost pcre-8.40] #. / configure & & make & & make install omit installation.
Zlib installation
[root@localhost src] # tar zxvf zlib-1.2.11.tar.gz omits installation. [root@localhost src] # cd zlib-1.2.11 [root@localhost zlib-1.2.11] #. / configure & & make & & make install omit installation.
Nginx installation
[root@localhost src] # tar zxvf nginx-1.10.2.tar.gz omits installation. [root@localhost src] # cd nginx-1.10.2 [root@localhost nginx-1.10.2] #. / configure & & make & & make install omit installation.
3. Start nginx
First find out where nginx is installed.
Go to the nginx directory and start
If you reported an error, error while loading shared libraries: libpcre.so.1: cannot open shared object file: no such file or directory, solve it as follows
1. Use the whereis libpcre.so.1 command to find out where libpcre.so.1 is 2. Use the command ln-s / usr/local/lib/libpcre.so.1 / lib64 to make a soft connection. Start nginx4 with sbin/nginx. Use ps-aux | grep nginx to check the status [root@localhost nginx] # whereis libpcre.so.1 [root@localhost nginx] # ln-s / usr/local/lib/libpcre.so.1 / lib64 [root@localhost nginx] # sbin/nginx [root@localhost nginx] # ps-aux | grep nginx
Enter the graphical interface of the linux system, open a browser and enter localhost. You will see the following figure, indicating that nginx has started successfully.
Basic operation of nginx
Start [root@localhost ~] # / usr/local/nginx/sbin/nginx stop / restart [root@localhost ~] # / usr/local/nginx/sbin/nginx-s stop (quit, reload) command to help [root@localhost ~] # / usr/local/nginx/sbin/nginx-h verify the configuration file [root@localhost ~] # / usr/local/nginx/sbin/nginx-t configuration file [root@localhost ~] # vim / usr/local/nginx/conf/nginx.conf
4. Simple configuration of nginx
Open the nginx configuration file located in the conf folder under the nginx directory
Briefly introduce the syntax of vim
Default vim cannot be entered after it is opened, and you need to press the key to operate, as follows: open editing: press "I" or "insert" key to exit editing: "esc" key to exit vim: ": Q" Save vim: ": W" Save exit vim: ": wq" do not save exit vim: ": Q!"
"#" stands for comments, and the most important thing is that the server {} block represents each web site. For a detailed description of the configuration, please refer to my other configuration article. Here, let's set up three sites for the time being.
Save exit and restart nginx using different ports 80,81,82, respectively
5. Enable public network access
In the linux system, there is a firewall iptables manager all ports by default, only default remote connection is enabled, port 22 is turned off, and the 80 and so on we set above are also closed, so we need to open the application port first.
The first method is to turn off the firewall directly, which has better performance, but poor security. This way can be taken if there is a front firewall.
Turn off the firewall [root@localhost ~] # service iptables stop turn off the boot firewall [root@localhost ~] # chkconfig iptables off [root@localhost ~] # chkconfig-- list | grep ipt
Method 2 adds the open ports to the firewall whitelist, which is more secure but has relatively poor performance.
Edit the firewall whitelist [root@localhost ~] # vim / etc/sysconfig/iptables add the following line-an input-p tcp-m state-- state new-m tcp-- dport 80-j accept save exit, restart the firewall [root@localhost ~] # service iptables restart
Linux is configured. Use another computer instead of the one with nginx. I use the windows system. Configure host. Configure the domain name redirection in the hosts under "c:\ windows\ system32\ drivers\ etc".
10.11.13.22 nginx.test.com nginx.test1.com nginx.test2.com
Then cmd ping again to see if the domain name correctly points to this ip.
After pointing correctly, check port 80 of telnet to see if you can communicate with the port (if telnet prompts you that there is no client installed without this command, you can install it at the place where windows is enabled or disabled)
Get the following interface and represent the successful communication
Open the browser in the windows system and enter nginx.test.com to get the following results, which means that the public network access is successful.
If you still enable the firewall, but only set the enabled port, then we will find that we cannot access the port 81 because I am not on the whitelist.
At this point, the nginx server prototype deployment is complete.
6. Nginx load balancing configuration
Nginx integrates reverse proxy and load balancing, which can be implemented by modifying the configuration file.
First, we open the configuration file.
[root@localhost nginx] # vim conf/nginx.conf
Each server is a virtual host, and we have one to use as a web server
Listen 80; on behalf of listening 80 port server_name xxx.com; represents the domain name location / {} accessed by the public network; represents a filter, / matches all requests, and we can also define different filters according to our own situation, such as making exclusive filtering for static files js, css, image root html; represents the site root directory index index.html; represents the default home page
In this way, after configuration, we can enter the domain name to access the site.
After receiving a request, the load balancing function is often distributed to multiple servers at the back end, so we need upstream {} blocks to work together.
Upstream xxx {}; upstream module names a backend server group, the group name must be the domain name of the backend server site, multiple servers ip and port can be written internally, you can also set jump rules and weights, etc. Ip_hash; represents the allocation of redirected backend servers using ip addresses. Each time the same ip request accesses the same backend server, server; represents the backend server address server {}. The server module is still part of the server_name; that receives external requests, representing the public network access domain location / {}, and also represents the filter, which is used to formulate different operations proxy_pass for different requests. This group name represents the backend server group name. The group name must be the backend server site domain name server_name and upstream {}. The group name of server_name is the domain name that the public network accesses to receive the request, and the group name of upstream {} is the domain name accessed by the site when the backend server is transferred.
Configure the host of windows to point the domain name aaa.test.com we want to visit to linux
Because the hardware is limited, I use iis in windows as the back-end server of nginx, so configure the site domain name of iis
Open cmd and then ping aaa.test.com does point to the linux system, and then open the browser to enter aaa.test.com will show bbb this site represents a successful load.
The above is about the content of this article on "how to install and deploy Nginx in Centos6.5 64-bit". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.
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.