当前位置:网站首页>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)]
边栏推荐
- Hdu-2036-reform spring breeze blowing all over the ground (polygon area template)
- 网络——传输层(详细版)
- Iptables firewall
- It is recommended to wear air conduction earphones, which do not need to wear in ear
- Technology sharing | how to do Assertion Verification in interface automated testing?
- What's a good gift for Tanabata? Niche and advanced product gift recommendation
- 技术分享 | 接口测试价值与体系
- Ubuntu18.04 set up redis cluster [learning notes]
- KVM热迁移
- QT uses MSVC compiler to output Chinese garbled code
猜你喜欢

VMware Workstation 配置net模式

Technology sharing | sending requests using curl

网络——传输层(详细版)

Technology sharing | how to simulate real use scenarios? Mock technology to help you

技术分享 | 接口测试常用代理工具

Source code analysis of countdownlatch of AQS
![[C language] dynamic memory management](/img/bb/2ec65b38e85f53269dc03d885d70f4.png)
[C language] dynamic memory management

C language memcpy library functions and the role of memmove

技术分享 | 接口测试价值与体系

Using C language to realize three piece chess games
随机推荐
Build php7 private warehouse
Elastic common high frequency commands
Ubuntu18.04搭建redis集群【学习笔记】
技术分享 | 使用 cURL 发送请求
FTP service
DNS域名解析服务
Hdu-2036-reform spring breeze blowing all over the ground (polygon area template)
Which is the best and most cost-effective air conduction headset recommended
防火墙——iptables防火墙(四表五链、防火墙配置方法、匹配规则详解)
HDU-1159-CommonSubsequence(LCS最长公共子序列)
Si Han talks about the professional development of testers
测试面试题集锦(五)| 自动化测试与性能测试篇(附答案)
修复故障扇区
浅谈Cookie和Session
Common models in software development
PKU-2739-Sum of Consecutive Prime Numbers(筛素数法打表)
Test interview questions collection (II) | test tools (with answers)
Test interview questions collection (III) | computer network and database (with answers)
FTP服务
Network - network layer