23, LNMP architecture

1, what is LNMP
LNMP is a combination of techniques, L = the Linux, the Nginx = N, M = the MySQL, the PHP P =
2, LNMP workflow
23, LNMP architecture

How it works:
1. User initiated by the http protocol request, the request will first arrive LNMP architecture Nginx
2.Nginx will be judged according to the user's request, the judge is carried out to complete the Location
3. judgment requested by the user is a static page, Nginx directly processing
4. Analyzing the user request is a dynamic page, Nginx fastcgi the request is sent to the protocol in
5.fastgi to php-fpm will request management process will be called after the specific job management process php-fpm received process warrapr
6.warrap php process calls for resolution, if only parsing code php directly back
7. If you have a query database operations, connected by php database (user password IP) to initiate action query
8. final data from the mysql-> PHP-> PHP-fpm-> fastcgi-> nginx-> http-> user
. 3, mounting LNMP
. 1, create a unified user and group
the groupadd -g WWW 666
the useradd WWW -s / sbin / nologin -M -u 666 -g 666
2, download source nginxREPO
wget http://nginx.org/packages/centos/$releasever/$basearch/
wget http://nginx.org/packages/mainline/centos/$releasever/$basearch/
yum the install -Y nginx
3, set up and boot nginx
systemctl Start nginx
systemctl enable nginx
4, download php7.1 third-party source
RPM -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch. RPM
RPM -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

yum -y install php71w php71w-cli php71w-common php71w-devel php71w-embedded php71w-gd php71w-mcrypt php71w-mbstring php71w-pdo php71w-xml php71w-fpm php71w-mysqlnd php71w-opcache php71w-pecl-memcached php71w-pecl-redis php71w-pecl-mongodb

5, and starts the boot provided PHP
systemctl Start PHP-FPM
systemctl enable PHP-FPM
. 6, modified to the www user profile Nginx and PHP
sed -i '/ ^ user / c user = www' / etc / php-fpm 2.d / www.conf
Sed -i '/ ^ Group / Group C = WWW' /etc/php-fpm.d/www.conf
. 7, i.e. the installation Mysql MariaDB
yum the install MariaDB MariaDB -Y-Server
. 8, set up and boot MariaDB
systemctl start MariaDB
systemctl enable MariaDB
9, the configuration database account password
mysqladmin password 'oldboy123' (default root password)
MySQL-uroot--poldboy123 (Log mysql)
with the specified IP login
MySQL-uroot--poldboy123 -h127.0.0.1
Show Databases;
Show from tables mysql;
SELECT user, Host from the mysql.user; mysql which users view the current
desc user; Display field
4, i.e., turned on and php nginx fastcgi

cat /etc/nginx/conf.d/php.conf
server {
    server_name www.oldboy.com;
    listen 80;
    root /code;
    index index.php index.html;

    location ~ \.php$ {
        root /code;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

1. Create a code directory and do a test page php
mkdir / code
chown -R the WWW: the WWW / code /
CAT /code/info.php

<?php
    phpinfo();
?>

2,nginx -t
systemctl restart nginx

3, page testing
23, LNMP architecture

4 the communication between the test and database PHP

cat /code/mysql.php 
<?php
    $servername = "localhost";
    $username = "root";
    $password = "oldboy123";

    // 创建连接
    $conn = mysqli_connect($servername, $username, $password);
    // // 检测连接
    if (!$conn) {
        die("Connection failed: " . mysqli_connect_error());
    }
    echo "php 连接 MySQL 数据库成功";
?>

Enter the browser: http://www.oldboy.com/mysql.php
23, LNMP architecture
So far, Nginx and PHP turned on, PHP and database turned

5, deployment Wordpress blog

1,配置wordpress虚拟主机
server {
    server_name blog.oldboy.com;
    listen 80;
    root /code/wordpress/;
    index index.php index.html;

    location ~ \.php$ {
        root /code/wordpress/;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

2, restart nginx
nginx -t
systemctl restart nginx

3, download wordpress code archive
CD / code
wget https://cn.wordpress.org/wordpress-4.9.4-zh_CN.tar.gz
the tar-4.9.4-zh_CN.tar.gz -zxvf wordpress
chown -R & lt WWW : www / code / wordpress

4, create a database called any wordpress
MySQL-uroot--poldboy123
the Create Database wordpress;
Exit
5, wordpress browser to access and deploy
23, LNMP architecture
23, LNMP architecture
23, LNMP architecture
23, LNMP architecture
23, LNMP architecture
the above steps to generate /code/wopress/wp-config.php editing configuration files generated in PHP. Database for turning
23, LNMP architecture

Guess you like

Origin blog.51cto.com/13858002/2434782