当前位置:网站首页>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)]
边栏推荐
- What kind of air conduction Bluetooth headset with good configuration is recommended
- JS四则运算重新封装,解决精度丢失问题
- Insertion and deletion of nodes in linked list
- [realize the simple version of minesweeping games]
- What is the good brand of air conduction Bluetooth headset and the best brand recommendation of air conduction headset
- How to simulate the implementation of strcpy library functions
- OSI七层模型
- Hdu-1159-commonsubsequence (LCS longest common subsequence)
- Using C language to realize three piece chess games
- Which brand of air conduction earphones is better? These four should not be missed
猜你喜欢

KVM热迁移

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

Build php7 private warehouse

Compilation and preprocessing of C language

How to simulate the implementation of strcpy library functions

MySQL主主

修复故障扇区

MySQL master-slave

Common models in software development

Which brand of air conduction earphones is good and highly praised
随机推荐
FTP服务
mongo ssl 配置实战
Test interview questions collection (II) | test tools (with answers)
C language memcpy library functions and the role of memmove
CentOS7部署MySQL数据库服务器
Which is the best air conduction Bluetooth headset? Air conduction Bluetooth headset ranking
Hdu-1159-commonsubsequence (LCS longest common subsequence)
Common models in software development
HDU-1097-A hard puzzle(快速幂)
Using C language to realize three piece chess games
Question skimming record - hash table
KVM热迁移
File operation in C language
技术分享 | 实战详解接口测试请求方式Get、post
QT uses MSVC compiler to output Chinese garbled code
Ubuntu18.04搭建redis集群【学习笔记】
Lancher deployment practice
Ubuntu18.04+centos7 configure redis master-slave [learning notes]
QGraphicsView提升为QChartView
Iptables firewall