In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to deploy static and dynamic separation of NGINX". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to deploy dynamic and static separation of NGINX".
I. brief introduction of the project
Deploy wordpress to achieve the separation of movement and movement of the entire website to achieve the following requirements:
1. The front-end Nginx receives a static request and returns it directly from the NFS to the client.
two。 The front-end Nginx receives the dynamic request and transfers it to the PHP server through FastCGI for processing.
If you get the static result, take the result directly from NFS and give it to Nginx and return it to the client.
-- if data processing is required, the PHP server connects to the database and returns the result to Nginx
3. The front-end Nginx receives image requests and submits them to the backend Images server for processing as .jpg, .png, .gif and other requests.
2. Overall architecture figure 3. Configuration details 1.NFS server configuration vim / etc/exports/app/blog 10.10.0.0 Universe 24 (ro,sync,root_squash,no_all_squash) # only allows mounting of private network segments to improve security. Cd / app/blog # extract the wordpress file from the tar-xvf wordpress-4.8.1-zh_CN.tar.gz2.Nginx server configuration
First of all, both Nginx and PHP servers need to mount NFS. Achieve unified deployment for easy management
Mount 10.10.0.72:/app/blog / app/blog # Mount / app/blog of NFS to local / app/blog
Then configure Nginx
Nginx is mainly the configuration of location in server. Configure location to give the end of .php to the PHP server. Give the end of. Jpg and gif to Image. Other configurations can be configured by default.
Vim / etc/nginx/nginx.confhttp {log_format main'$remote_addr-$remote_user [$time_local] "$request"'$status $body_bytes_sent "$http_referer"'"$http_user_agent"$http_x_forwarded_for"; access_log / var/log/nginx/access.log main; sendfile on; tcp_nopush on Tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include / etc/nginx/mime.types; default_type application/octet-stream; include / etc/nginx/conf.d/*.conf; server {listen 80 default_server; server_name www.shuaiguoxia.com; index index.php index.html; root / app/blog # the root directory is the mount point of the mounted NFS include / etc/nginx/default.d/*.conf; location ~ *\ .php$ {# location matches the end of the php to the PHP server fastcgi_pass 10.10.0.22 php$ 9000; fastcgi_index index.php Fastcgi_param SCRIPT_FILENAME / app/blog$fastcgi_script_name; include fastcgi_params;} location ~ *\. (jpg | gif) ${# location match hand over the picture to Image for processing proxy_pass http://10.10.0.23:80; # Image server to enable web service} error_page 404 / 404.html; location = / 40x.html {} error_page 500502503504 / 50x.html; location = / 50x.html {} 3.PHP server configuration
The configuration of the PHP server is relatively simple, mainly talking about the simple configuration after PHP is installed in FPM mode.
Yum install php-fpm php-mysqlvim / etc/php-fpm.d/www.conflisten = 9000 # write-only listening port, that is, listen to all IPlisten.allowed_clients = any # to allow all IP access. Or comment this line. 4.MySQL server yum install marirdb-server/usr/local/mysql/bin/myhsql_secure_installation # MySql initialization script, the following is whether the translation of each item sets the root password, enter the password, confirm whether the password is set, whether anonymous users allow root remote login to delete the test database, whether it is now valid mysql-uroot-pcreate database wpdb # create wp database grant all on wpdb.* to wpadm@'10.10.%' idenfied by 'centos'; # authorized user. User does not exist the system will automatically create a 5.Image server to configure yum install nginx # install Nginxcd / app/image # and extract all images to this path. The directory structure of the image should remain intact tar-xvf wordpress-4.8.1-zh_CN.tar.gzserver {root / app/image; # just modify the root directory line. Httpd the same way} # if you use apache, you should note that all nginx start # startup services are rejected by default under CentOS7. Configure wordpresscp wp-config-sample.php wp-config.php # to copy a template file and rename it as the name of the main configuration file vim wp-config.php/** WordPress database * / define ('DB_NAME',' wpdb'); # wpdb is the database created in MySQL / * * MySQL database user name * / define ('DB_USER',' wpadm') # wpadm is the authorized user in MySQL / * * MySQL database password * / define ('DB_PASSWORD',' centos'); # password of authorized user / * * MySQL host * / define ('DB_HOST',' 10.10.0.24'); # MySQL host address
At this point, the configuration is complete. The picture is returned from the picture server, the static nginx is returned directly, and it is dynamically handed over to PHP for processing.
Thank you for reading, the above is the content of "how to deploy dynamic and static separation of NGINX". After the study of this article, I believe you have a deeper understanding of the problem of how to deploy dynamic and static separation of NGINX, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.