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/01 Report--
This article focuses on "Nginx+Apache dynamic and static separation deployment process", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn the "Nginx+Apache dynamic and static separation deployment process"!
Why do you need to deploy Nginx+Apache static and dynamic separation deployment?
Earlier, when explaining the construction of Discuz forums based on LNMP architecture (original link: https://blog.51cto.com/14557673/2461480), we mentioned the separation of movement and movement. Here is a brief description of the core reasons:
According to the characteristics of Nginx service, it is good at dealing with static websites (files such as pictures, text and video) to access resources, while Apache is good at dynamic processing (for example, interaction with account registration).
Therefore, we can combine the characteristics and advantages of these two services and deploy to achieve the separation of website services.
Deploy Nginx+Apache static and dynamic separation instances
Experimental environment: two Centos7 virtual machines, one for LAMP architecture and the other for nginx service
First, we need to build the LAMP architecture. This time, we use yum to build the LAMP directly. The specific steps are as follows:
Install and build the LAMP architecture on a virtual machine:
= LAMP simple version build =
1. Install httpd
Yum install-y httpd httpd-devel
Systemctl start httpd.service
[root@lamp] # ifconfig ens33ens33: flags=4163 mtu 1500 inet 192.168.68.144 netmask 255.255.255.0 broadcast 192.168.68.255 inet6 fe80::7330:498c:44ce:c5f7 prefixlen 64 scopeid 0x20 ether 00:0c:29:cc:52:c8 txqueuelen 1000 (Ethernet) RX packets 659954 bytes 964992071 (920.2 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 339462 bytes 20930426 ) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@lamp ~] # yum install-y httpd httpd-devel [root@lamp ~] # systemctl start httpd.service [root@lamp ~] # netstat-antp | grep httpdtcp6 0: 80: * LISTEN 57584/httpd
two。 Firewall settings (can also be turned off directly)
Firewall-cmd-permanent-zone=public-add-service=http
Firewall-cmd-permanent-zone=public-add-service=https
Firewall-cmd-reload
[root@lamp] # firewall-cmd-- permanent-- zone=public-- add-service=http success [root@lamp ~] # firewall-cmd-- permanent-- zone=public-- add-service=httpssuccess [root@lamp ~] # firewall-cmd-- reloadsuccess
3. Install the mariadb database
Yum install mariadb mariadb-server mariadb-libs mariadb-devel-y
Fast, simple and lightweight shortcut database of mariadb
[root@lamp ~] # yum install mariadb mariadb-server mariadb-libs mariadb-devel-y
4. Start the service
Systemctl start mariadb
[root@lamp ~] # systemctl start mariadb.service [root@lamp ~] # netstat-antp | grep 3306tcp 0 0 0.0.0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.
5. Execute the mysql Security configuration Wizard command
Mysql_secure_installation
[root@lamp ~] # mysql_secure_installation / / Interactive NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!In order to log into MariaDB to secure it, we'll need the currentpassword for the root user. If you've just installed MariaDB, andyou haven't set the root password yet, the password will be blank,so you should just press enter here.Enter current password for root (enter for none): / / No password. Directly enter OK, successfully used password, moving on...Setting the root password ensures that nobody can log into the MariaDBroot user without the proper authorisation.Set root password? [root] y / / set the root password and enter New password: Re-enter new password: Password updated fulfilling Reloading privilege tables.. by yourself ... Success!By default, a MariaDB installation has an anonymous user, allowing anyoneto log into MariaDB without having to have a user account created forthem. This is intended only for testing, and to make the installationgo a bit smoother. You should remove them before moving into aproduction environment.Remove anonymous users? [YBO] n / / choose whether or not to remove anonymous users, choose by yourself. Skipping.Normally, root should only be allowed to connect from 'localhost'. Thisensures that someone cannot guess at the root password from the network.Disallow root login remotely? [YPop] n / / whether root is not allowed to log in remotely. Skipping.By default, MariaDB comes with a database named 'test' that anyone canaccess. This is also intended only for testing, and should be removedbefore moving into a production environment.Remove test database and access to it? [YBO] n / / whether to remove the test database. Skipping.Reloading the privilege tables will ensure that all changes made so farwill take effect immediately.Reload privilege tables now? [YBO] y / / overload refresh. Success!Cleaning up...All done! If you've completed all of the above steps, your MariaDBinstallation should now be secure.Thanks for using MariaDB!
6. Install PHP
Yum-y install php
[root@lamp ~] # yum-y install php
7. Install the PHP and mysql associated package
Yum install php-mysql-y
[root@lamp ~] # yum install php-mysql-y
8. 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
[root@lamp ~] # yum install-y php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap
9. Create PHP page content
Cd / var/www/html
Vim index.php
[root@lamp html] # cd / var/www/html/ [root@lamp html] # vim index.php [root@lamp html] # cat index.php
10. Restart the httpd service
Systemctl restart httpd
[root@lamp html] # systemctl restart httpd.service [root@lamp ~] # netstat-antp | grep httpdtcp6 0 0: 80:: * LISTEN 57584/httpd
11. Test whether the architecture is built successfully
Manually compile and install nginx on another virtual machine:
= nginx server configuration =
Manually compile and install the Nginx service
1. Install the environment package
Yum-y install gcc gcc-c++ pcre-devel zlib-devel
[root@nginx] # ifconfig ens33ens33: flags=4163 mtu 1500 inet 192.168.68.136 netmask 255.255.255.0 broadcast 192.168.68.255 inet6 fe80::f14b:5f19:2889:b137 prefixlen 64 scopeid 0x20 ether 00:0c:29:f3:5e:0b txqueuelen 1000 (Ethernet) RX packets 69672 bytes 100983394 (96.3 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 34582 bytes 2297096 (2.1MiB ) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@nginx ~] # yum-y install gcc gcc-c++ pcre-devel zlib-devel
two。 Decompress the software package
Tar zxf nginx-1.12.2 tar.gz-C / opt/
[root@nginx LNMP-C7] # tar zxf nginx-1.12.2.tar.gz-C / opt/ [root@nginx LNMP-C7] # cd / opt/nginx-1.12.2/ [root@nginx nginx-1.12.2] # lsauto CHANGES.ru configure html man srcCHANGES conf contrib LICENSE README
3. Create a home directory but not a home directory
Useradd-M-s / sbin/nologin nginx
[root@nginx nginx-1.12.2] # useradd-M-s / sbin/nologin nginx
4. Configure related parameters
Cd / opt/nginx-1.12.0
. / configure\
-- prefix=/usr/local/nginx\
-- user=nginx\
-- group=nginx\
-- with-http_stub_status_module
[root@nginx nginx-1.12.2] #. / configure\ >-- prefix=/usr/local/nginx\ >-- user=nginx\ >-- group=nginx\ >-- with-http_stub_status_module
5. Compilation and installation
Make & & make install
[root@nginx nginx-1.12.2] # make & & make install
6. Create a soft link
Ln-s / usr/local/nginx/sbin/nginx / usr/local/sbin/
[root@nginx nginx-1.12.2] # ln-s / usr/local/nginx/sbin/nginx / usr/local/sbin/
7. Profile Settin
Vim / usr/local/nginx/conf/nginx.conf
Location ~ .php ${
Proxy_pass http://192.168.68.144;
}
[root@nginx nginx-1.12.2] # ln-s / usr/local/nginx/sbin/nginx / usr/local/sbin/ [root@nginx nginx-1.12.2] # vim / usr/local/nginx/conf/nginx.conf [root@nginx nginx-1.12.2] # sed-n'59 61p'/ usr/local/nginx/conf/nginx.conf location ~\ .php$ {proxy_pass http://192.168.68.144;}
8. Enable the nginx service
Nginx
[root@nginx nginx-1.12.2] # nginx [root@nginx nginx-1.12.2] # netstat-antp | grep nginxtcp 0 0 0.0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0 of the antp. * LISTEN 81215/nginx: master
9. Turn off the firewall
Systemctl stop firewalld
Setenforce 0
[root@nginx nginx-1.12.2] # systemctl stop firewalld.service [root@nginx nginx-1.12.2] # setenforce 1
10. Test and verify that php web pages are accessed through the nginx server
At this point, I believe you have a deeper understanding of the "Nginx+Apache dynamic and static separation deployment process". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.