当前位置:网站首页>Detailed explanation of LNMP construction process
Detailed explanation of LNMP construction process
2022-07-28 06:55:00 【Fish fire loach】
LNMP Detailed explanation of the construction process , Verification and establishment Forum
One 、 install Nginx service
preparation : Turn off firewalls and security
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
1、 Install dependency packages
yum -y install pcre-devel zlib-devel gcc gcc-c++ make
2、 Create a running user
(Nginx The service program defaults to nobody Identity running , It is recommended to create a special user account for it , In order to more accurately control its access rights )
useradd -M -s /sbin/nologin nginx
3、 Compilation and installation
cd /opt
# Drag in the package
tar zxvf nginx-1.12.0.tar.gz -C /opt/ # decompression
cd nginx-1.12.0/ # Switch to path
./configure
–prefix=/usr/local/nginx \ # Appoint nginx Installation path for
–user=nginx \ # Specify user name
–group=nginx \ # Specify the group name
–with-http_stub_status_module # Enable http_stub_status_module Module to support State Statistics
make -j4 && make install


./configure
–prefix=/usr/local/nginx
–user=nginx
–group=nginx
–with-http_stub_status_module
4、 Optimize the path
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/ # Let the system recognize nginx Operation command of
5、 add to Nginx system service
vim /lib/systemd/system/nginx.service

[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStart=/usr/local/nginx/sbin/nginx
ExecrReload=/bin/kill -s HUP $MAINPID
ExecrStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target

chmod 754 /lib/systemd/system/nginx.service
systemctl start nginx.service
systemctl enable nginx.service
6、 Test page : Firefox
Enter this machine IP:192.168.80.77

Add : start-up 、 stop it nginx service
nginx -t # Check that the configuration file is configured correctly
nginx # start-up
cat /usr/local/nginx/logs/nginx.pid # To look at first nginx Of PID Number
kill -3 <PID Number >
kill -s QUIT <PID Number > # stop it
killall -3 nginx
killall -s QUIT nginx
Two 、 install MySQL service
1、 install Mysql Environment dependent packages
yum -y install
gcc
gcc-c++
ncurses \ # Dynamic library of graphic interaction function under character terminal
ncurses-devel \ #ncurses Development kit
bison \ # parsers
cmake #mysql Need to use cmake Compilation and installation
yum -y install gcc gcc-c++ ncurses ncurses-devel bison cmake
2、 Create a running user
useradd -M -s /sbin/nologin mysql
3、 Compilation and installation
cd /opt
tar zxvf mysql-boost-5.7.20.tar.gz

cd /opt/mysql-5.7.20/
cmake
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock
-DSYSCONFDIR=/etc
-DSYSTEMD_PID_DIR=/usr/local/mysql
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DWITH_EXTRA_CHARSETS=all
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_ARCHIVE_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1
-DMYSQL_DATADIR=/usr/local/mysql/data
-DWITH_BOOST=boost
-DWITH_SYSTEMD=1

make -j 4 && make install # Compilation and installation
4、 modify mysql The configuration file
vim /etc/my.cnf
[client]
port = 3306
socket=/usr/local/mysql/mysql.sock
[mysqld]
user = mysql
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
port = 3306
character-set-server=utf8
pid-file = /usr/local/mysql/mysqld.pid
socket=/usr/local/mysql/mysql.sock
bind-address = 0.0.0.0
skip-name-resolve
max_connections=2048
default-storage-engine=INNODB
max_allowed_packet=16M
server-id = 1
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,PIPES_AS_CONCAT,ANSI_QUOTES
5、 change mysql The primary group of the installation directory and configuration files
chown -R mysql:mysql /usr/local/mysql/
chown mysql:mysql /etc/my.cnf
6、 Set the path environment variable
echo ‘export PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH’ >> /etc/profile
source /etc/profile
7、 Initialize datalization
cd /usr/local/mysql/bin/
./mysqld
–initialize-insecure
–user=mysql
–basedir=/usr/local/mysql
–datadir=/usr/local/mysql/data
8、 add to mysqld system service
cp /usr/local/mysql/usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system/
systemctl daemon-reload
systemctl start mysqld.service
systemctl enable mysqld
9、 add to mysql Login password for
mysqladmin -u root -p password “abc123” ## to root Set the password to abc123, The prompt is the original password ( It's empty )
10、 Authorize remote login
mysql -u root -p
grant all privileges on . to ‘root’@‘%’ identified by ‘abc123’;
# grant root Users can log in remotely at all terminals , The password used is abc123, And all databases and all tables have operation permissions
show databases; # View the existing database 
quit sign out
3、 ... and 、 Installation configuration PHP Analyze the environment
1、 Install environment dependency package
yum -y install gd
libjpeg libjpeg-devel
libpng libpng-devel
freetype freetype-devel
libxml2 libxml2-devel
zlib zlib-devel
curl curl-devel
openssl openssl-devel
2、 Compilation and installation
cd /opt
tar jxvf php-7.1.10.tar.bz2
cd ./php-7.1.10/
./configure
–prefix=/usr/local/php
–with-mysql-sock=/usr/local/mysql/mysql.sock
–with-mysqli
–with-zlib
–with-curl
–with-gd
–with-jpeg-dir
–with-png-dir
–with-freetype-dir
–with-openssl
–enable-fpm
–enable-mbstring
–enable-xml
–enable-session
–enable-ftp
–enable-pdo
–enable-tokenizer
–enable-zip
make -j4 && make install
3、 Path optimization
ln -s /usr/local/php/bin/* /usr/local/bin/
ln -s /usr/local/php/sbin/* /usr/local/sbin/
4、 adjustment PHP The configuration file
PHP There are three profiles
php.ini( Master profile )
php-fpm.conf( Process service profile )
www.conf( Extended profile )
Adjust the main profile php.ini :


Adjust the process service profile php-fpm.conf :
cd /usr/local/php/etc
cp php-fpm.conf.default php-fpm.conf
vim php-fpm.conf
#17 Line uncomment “;”
pid = run/php-fpm.pid
Adjust the extended profile www.conf :
cd /usr/local/php/etc/php-fpm.d
cp www.conf.default www.conf
5、 start-up php-fpm
PHP-FPM(FastCGI Process Manager:FastCGI Process Manager ) It's a PHPFastCGI Manager , because Nginx The server can't handle dynamic pages , Need by Nginx Give the dynamic request to php-fpm Process
cd /usr/local/php/sbin/
php-fpm -c /usr/local/php/lib/php.ini
netstat -natp | grep 9000
6、 To configure Nginx Support PHP analysis
vim /usr/local/nginx/conf/nginx.conf
##65 Line uncomment modify
location ~ .php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
# take /scripts It is amended as follows nginx The working directory of is changed to /usr/local/nginx/html
include fastcgi_params;
}
systemctl restart nginx.service
7、 verification PHP Test page
vim /usr/local/nginx/html/index.php
<?php phpinfo(); ?>Browser access :http://192.168.80.77/index.php

8、 Verify that the database is working properly
mysql -u root -p
CREATE DATABASE bbs;
GRANT all ON bbs.* TO ‘bbsuser’@‘%’ IDENTIFIED BY ‘admin123’;
flush privileges;
show databases; # See what databases are
vim /usr/local/nginx/html/index.php
<?php $link=mysqli_connect('192.168.80.77','bbsuser','admin123'); if($link) echo "wangdachu!"; else echo "fail!!" ?>[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-7VForyXS-1658731635280)(C:\Users\YU\AppData\Roaming\Typora\typora-user-images\image-20220725142748517.png)]
Browser access :http://192.168.80.77/index.php
[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-iaiNWHC5-1658731635280)(C:\Users\YU\AppData\Roaming\Typora\typora-user-images\image-20220725142849510.png)]
Y ‘admin123’;
flush privileges;
show databases; # See what databases are
vim /usr/local/nginx/html/index.php
<?php $link=mysqli_connect('192.168.80.77','bbsuser','admin123'); if($link) echo "wangdachu!"; else echo "fail!!" ?>[ Outside the chain picture transfer in …(img-7VForyXS-1658731635280)]
Browser access :http://192.168.80.77/index.php
[ Outside the chain picture transfer in …(img-iaiNWHC5-1658731635280)]
边栏推荐
- Technology sharing | send requests using postman
- Question brushing record - linked list
- How to simulate the implementation of strcpy library functions
- Hdu-1159-commonsubsequence (LCS longest common subsequence)
- Archery database audit platform deployment
- 软件测试的生命周期(流程)
- File operation in C language
- MySQL主从
- 链表中结点的插入和删除
- Gerapy use
猜你喜欢

It is recommended to wear air conduction earphones, which do not need to wear in ear

Method of designing test cases

JS reverse question 100 - question 1

DNS正向解析实验

Technology sharing | common proxy tools for interface testing

shell脚本——“三剑客”之awk命令

DNS forward resolution experiment

Installation and configuration of unit test framework jest with typescript

Prometheus monitoring Nacos

技术分享 | 使用 cURL 发送请求
随机推荐
Question brushing record - linked list
Insertion and deletion of nodes in linked list
Technology sharing | how to simulate real use scenarios? Mock technology to help you
DNS domain name resolution service
QT使用MSVC编译器输出中文乱码问题
Installation and configuration of unit test framework jest with typescript
Test interview questions collection (V) | automated testing and performance testing (with answers)
Technology sharing | sending requests using curl
Using C language to realize three piece chess games
MySQL master-slave
设计测试用例的方法
PKU-2524-Ubiquitous Religions(并查集模板)
Which brand of air conduction earphones is better? These four should not be missed
Teach you three steps to complete the construction of the test monitoring system hand in hand
技术分享 | 使用postman发送请求
MySQL common commands
archery数据库审核平台部署
Array solution script
测试人生 | 二线城市年薪超40W?疫情之下涨薪100% + 是怎么做到的?
What kind of air conduction Bluetooth headset with good configuration is recommended