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 > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Introduction of Nginx
Nginx (engine x) is a high-performance HTTP and reverse proxy web server, as well as providing IMAP/POP3/SMTP services. Nginx was developed by Igor Sesoyev for the second most visited Rambler.ru site in Russia. The first public version 0.1.0 was released on October 4, 2004.
It distributes the source code as a BSD-like license and is known for its stability, rich feature set, sample configuration files, and low consumption of system resources. Nginx 1.0.4 was released on June 1, 2011.
Nginx is a lightweight Web server / reverse proxy server and email (IMAP/POP3) proxy server, distributed under the BSD-like protocol. It is characterized by less memory and strong concurrency ability. in fact, the concurrency ability of nginx performs better in the same type of web server.
Advantages of Nginx
Nginx can be compiled and run on most UnixLinux OS, and there is a portable version of Windows. The 1.4.0 stable version of Nginx was released on April 24, 2013. in general, for new sites, it is recommended to use the latest stable version as the production version, and existing sites are not urgent to upgrade.
The source code for Nginx uses 2-clause BSD-like license.
Nginx is a powerful high-performance Web and reverse proxy service with many excellent features:
In the case of high concurrency of connections, Nginx is a good alternative to Apache services: Nginx is one of the software platforms often chosen by web hosting bosses in the United States. To be able to support a response of up to 50000 concurrent connections, thanks to Nginx for choosing epoll and kqueue as our development model.
I. A brief introduction to the separation of motion and motion.
The static processing capacity of Nginx is very strong, and it is commonly used to deal with static requests, but the dynamic processing capacity is insufficient. Therefore, the dynamic and static separation technology is commonly used in enterprises.
For the static and dynamic separation of PHP, static pages are handed over to Nginx, and dynamic pages are handed over to PHP-FPM module or Apache.
In the configuration of Nginx, different processing methods of static and dynamic pages are realized through location configuration segment and regular matching.
Second, the principle of reverse agency
Nginx not only acts as a Web server, but also has the functions of reverse proxy, load balancing and caching.
Nginx proxies the request of the client to the upstream server through the proxy module, and the connection between nginx and the upstream server is carried out through http negotiation.
The most important instruction of nginx when implementing the reverse proxy function is: proxy_pass its processing logic dispatches user requests to the upstream server.
Third, configuration experiment
3.1. Experimental requirements
According to the needs of the enterprise, the static and dynamic separation is realized by configuring nginx, the request for PHP page is forwarded to LAMP for processing, and the static page is handed over to nginx for processing to achieve static and dynamic separation.
3.2. Environmental preparation
Prepare two centos virtual machines, the first has been set up with Nginx configuration, and the second is used to build the LAMP platform.
3.3.Architectural LAMP
1. Install http and turn off the firewall
Systemctl stop firewalld
Setenfoce 0
Yum install httpd httpd-devel-y
# enable the service
Systemctl start httpd
2. Install the database MySQL and start the service
# install mariadb (simple, fast, lightweight, easy to install) database
Yum install mariadb mariadb-server mariadb-libs mariadb-devel-y
# start mariadb
Systemctl start mariadb.service
# filter to see
Netstat-anpt | grep 3306
3. Set the password for the MySQL database and configure the database
Mysql_secure_installstion
# enter
# set password for root: abc123
# enter
# will display Remove anonymouns users (anonymous user)-> N
# enter
# Disallow root login remotely (whether to deny root remote login)-> N
# enter
# Remove test database and access to it (whether to delete the test database)-> N
# enter
# Reload pricilegs tables now (whether to reload the permission list)-> Y
4. Install php and establish the association between php and mysql
# install php
Yum install php-y
# install (establish php and mysql) associated plug-ins
Yum install php-mysql-y
5. Install the php plug-in
# install the php plug-in
Yum install-y php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel php-bcmath
6. Create a new PHP web page content file
Cd / var/www/html
Mv index.html index.php
Vim index.php
7. Restart the service and enter 192.168.111.141/index.php in the browser of 'nginx'.
# restart the service again
Systemctl restart httpd.service
Systemctl restart mariadb
3.4.static separation of architecture Nginx
The installation of nginx has been configured in advance. If you need it, please read a blog. The link is: configuration of Nginx.
1. Modify the configuration file of Nginx and forward the PHP file request to Apache for processing.
Vim / usr/local/nginx/conf/nginx.conf
2. Restart the nginx service
Service nginx restart
3. Visit the website in the browser of nginx: 192.168.111.139/index.php verification
. Php is a dynamic request and html is a static request.
. If it is a static request, Nginx handles it directly. If it is a dynamic request, nginx automatically forwards the dynamic request to Apache for processing.
Visit the website: 192.168.111.139/index.html
LAMP platform: 192.168.111.141
Nginx platform: 192.168.111.139
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.