当前位置:网站首页>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)]
边栏推荐
- Which is the best and most cost-effective air conduction headset recommended
- 技术分享 | 服务端接口自动化测试, Requests 库的这些功能你了解吗?
- Create, traverse and search nodes as required for single linked list
- iptables防火墙
- 技术分享 | 使用 cURL 发送请求
- File operation in C language
- Hdu-1159-commonsubsequence (LCS longest common subsequence)
- DNS正向解析实验
- How to describe a bug and the definition and life cycle of bug level
- HDU-1097-A hard puzzle(快速幂)
猜你喜欢

VMware Workstation 配置net模式

How to describe a bug and the definition and life cycle of bug level

Build php7 private warehouse
![[explain in detail how to realize Sanzi chess step by step]](/img/17/68ef51ec2be0c86019461116ecaa82.png)
[explain in detail how to realize Sanzi chess step by step]

MySQL master-slave

DNS正向解析实验

JS逆向100题——第1题

Technology sharing | send requests using postman

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

JS reverse question 100 - question 1
随机推荐
HDU-1159-CommonSubsequence(LCS最长公共子序列)
[realize the simple version of minesweeping games]
软件测试(概念篇)
QT使用MSVC编译器输出中文乱码问题
FTP service
On cookies and session
Question skimming record - hash table
Array to linked list
Cocos2d-x learning notes Tile Map tiledmap
MySQL主主
数组转链表
技术分享 | 服务端接口自动化测试, Requests 库的这些功能你了解吗?
Mongo SSL configuration practice
HDU-5805-NanoApe Loves Sequence(思维题)
Archery database audit platform deployment
Pku-2739-sum of constructive prime numbers
What kind of air conduction Bluetooth headset with good configuration is recommended
Ubuntu18.04+Centos7配置redis主从【学习笔记】
Question brushing record -- binary tree
Technology sharing | common proxy tools for interface testing