LNMP3 Host separation for deployment

Source: Internet
Author: User
Tags install openssl nginx server

LNMP 3 Host separation for deployment

First virtual host to deploy Nginx second virtual host for deployment PHP-FPM third virtual host for deployment Mariadb-server

First host to deploy Nginx installation: Implement static Web page processing (192.168.1.107)

1. Download the 1.8 version first, then unzip the work.

2. Compile and install the following actions

3.yum Groupinstall "Development Tools" "Server Platform Development"-Y

Yum-y Install Openssl-devel pcre-devel zlib-devel

Useradd-r Nginx

4. Create an environment

./configure--prefix=/usr/local/nginx--conf-path=/etc/nginx/nginx.conf--user=nginx--group=nginx--error-log-path =/var/log/nginx/error.log--http-log-path=/var/log/nginx/access.log--pid-path=/var/run/nginx/nginx.pid-- Lock-path=/var/lock/nginx.lock--with-http_ssl_module--with-http_gzip_static_module--with-debug--with-http_stub _status_module

5. Compile the work

Make && make install

6.[[email protected] nginx]#/usr/local/nginx/sbin/nginx-t Check that the syntax is correct

Nginx:the configuration file/etc/nginx/nginx.conf syntax is OK

Nginx:configuration file/etc/nginx/nginx.conf Test is successful

7./usr/local/nginx/sbin/nginx Start Service

8. Test the following

9. Modify the command to edit the configuration file

[Email protected] ~]# vim/etc/profile.d/nginx.sh

Export Path=/usr/local/nginx/sbin: $PATH

EXEC bash/etc/profile.d/nginx.sh

[Email protected] ~]# echo $PATH

/usr/local/nginx/sbin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

NGINX-T, test the grammar.

Nginx-s Reload re-load it in.

10. Start Nginx to see the 80 port Cd/usr/local/nginx

Then execute nginx using the command SS-TNL to see if the port is enabled.

11. Define the Nginx configuration file vim/etc/nginx/nginx.conf

server {

Listen 80;

server_name www.magedu.com;

#charset Koi8-r;

#access_log Logs/host.access.log Main;

Location/{

Root html/wordpress;

Index index.html index.htm;

}

Location ~ \.php$ {

root HTML;

Fastcgi_pass 192.168.1.109:9000;

Fastcgi_index index.php;

Fastcgi_param Script_filename/var/www/html/wordpress/scripts$fastcgi_script_name;

Include Fastcgi_params;

}

12. Reload the configuration file nginx-t nginx-s reload

13 The single-machine Nginx service is able to access the normal, if not, its selinux must be shut down, the firewall must be closed OK

Welcome to nginx!

If you see this page, the Nginx Web server is successfully installed and working. Further configuration is required.

For online documentation and the refer to nginx.org.
Commercial support was available at nginx.com.

Thank for using Nginx.


Source: http://192.168.1.107/can have normal access, no problem, next test the following services.

Second virtual host for PHP-FPM installation work (192.168.1.100)

1.yum Install php-fpm-y yum install php-mbstring yum install Php-mysql

Then start service php-fpm start

Check that the ports that are listening are 127.0.0.1:9000 changed and become 192.168.1.100:9000 ports by default.

2. Edit the configuration file vim/etc/php-fpm.d/www.conf

Listen.allowed_clients = 192.168.1.107 This is the IP address of the Nginx virtual machine, which is the IP of the first virtual machine.

Listen = 192.168.1.100:9000

3. Restart Service php-fpm Restart

Third virtual host for Mariadb-server database installation work (192.168.1.109)

1. Then start the service mysqld start monitoring port number is 3306 SSL-TNLP for viewing work

[Email protected] ~]# SS-TNL

State recv-q send-q Local address:port Peer address:port

LISTEN 0 *:3306 *:*

2. Set the data name to work, and open the allowed network can be connected to the database.

MySQL for database

MariaDB [(None)]> GRANT all on * * to [e-mail protected] ' 192.168.%.% ' identified by ' root '; Allows the host of this network segment to access any database

Query OK, 0 rows Affected (0.00 sec)

MariaDB [(None)]> CREATE DATABASE rootdb; Name of the database created

Query OK, 1 row Affected (0.00 sec)

MariaDB [(None)]> FLUSH privileges; Immediate effect

Query OK, 0 rows Affected (0.00 sec)

3. You can perform test work on the database

The database of its virtual machine can be installed, and then the virtual machine 3 of the data to test, if you can log into the instructions no problem, command mysql-uroot-h192.168.1.109-proot

It is OK to close the database after the test is complete.

4. Then upload their software wordpress to virtual machine 1/usr/local/nginx/html/and virtual machine 2/var/www/html

Create a directory on 192.168.1.100 that provides PHP-FPM virtual machine hosts mkdir-pv/var/www/html

Then copy the software to this directory and edit the configuration file of its software. Vim config.php

Two of these are $cfg that need to be modified [' blowfish_secret '] = '68/w1kbacrdot/ptgbbo'; The Red Area section is where the password is set using the command OpenSSL rand-base64 15

An encrypted secret key is generated and pasted in the red area. $cfg [' Servers '] [$i] [' host '] = '192.168.1.109'; This IP address is to write the IP address of the host where the database resides. OK

In the same vein, upload its software to an Nginx server that provides a static service, and put it under/usr/local/nginx/html/.

5. It is now possible to test the service provided by the second virtual host, through the first virtual host, to see if it can be forwarded to the second one, as shown below; see if the second Test page provided can be displayed.

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "border=" 0 "style=" Background:url ("/e/u261/ Lang/zh-cn/images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650) this.width=650 ; "Src=" http://s1.51cto.com/wyfs02/M01/7F/C4/wKioL1csA82yI4GjAAHmGbRveIk779.jpg "title=" 1.jpg "alt=" Wkiol1csa82yi4gjaahmgbrveik779.jpg "/>

6. Then the next is to connect to the third virtual host to provide the database, if you can properly link, we edit the The phpMyAdmin software should show the login interface. OK, let's have a test. (The login interface has been shown, indicating that our LNMP was built successfully).

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "border=" 0 "style=" Background:url ("/e/u261/ Lang/zh-cn/images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650) this.width =650; "src=" http://s5.51cto.com/wyfs02/M02/7F/C6/wKiom1csAwbAm3Y-AAFNVZGPEuc891.jpg "title=" 2.jpg "alt=" Wkiom1csawbam3y-aafnvzgpeuc891.jpg "/>








This article is from the "Li Wenming blog" blog, make sure to keep this source http://liwenming18.blog.51cto.com/11068518/1770656

LNMP3 Host separation for deployment

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.