当前位置:网站首页>Explanation of LNMP architecture source code compilation and installation with pictures and texts (with forum experiment)
Explanation of LNMP architecture source code compilation and installation with pictures and texts (with forum experiment)
2022-06-11 19:41:00 【[email protected]】
List of articles
1 install Nginx service
1. Turn off firewall , take Nginx Required packages to /opt Under the table of contents
systemctl stop firewalld # Turn off firewall
systemctl disable firewalld # Turn off the firewall and turn it on
setenforce 0 # Turn off system security
cd /opt # Switch to /opt Catalog
nginx-1.12.0.tar.gz

2. Install dependency packages
yum -y install pcre-devel zlib-devel gcc gcc-c++ make # Install the required development kit , To provide the corresponding libraries and header files, as well as the compilation environment and compiler

3. Create a running user 、 Group
(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 # Create program users , So as to control access accurately
#Nginx The service program runs as an anonymous user by default

4. Compilation and installation Nginx
cd /opt
tar zxvf nginx-1.12.0.tar.gz -C /opt/
cd nginx-1.12.0/
./configure \ # Use 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 && make install # Compile and install

5. Optimize the path
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/ # Let the system recognize nginx Operation command of
6. add to Nginx system service
vim /lib/systemd/system/nginx.service
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking # Background run type
PIDFile=/usr/local/nginx/logs/nginx.pid #PID file location
ExecStart=/usr/local/nginx/sbin/nginx # Start the service
ExecrReload=/bin/kill -s HUP $MAINPID # according to PID Overload configuration
ExecrStop=/bin/kill -s QUIT $MAINPID # according to PID Terminate the process
PrivateTmp=true
[Install]
WantedBy=multi-user.target # Start level
chmod 754 /lib/systemd/system/nginx.service
systemctl start nginx.service
systemctl enable nginx.service

2 install MySQL service
1. Will install mysql The required software package is transferred to /opt Under the table of contents
mysql-boost-5.7.20.tar.gz

2、 install Mysql Environment dependent packages
yum -y install \
ncurses \
ncurses-devel \
bison \
cmake

3. Create a running user
useradd -M -s /sbin/nologin mysql

4. 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 \ # Appoint mysql Installation path for
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \ # Appoint mysql The process listens to socket files ( Database connection file ) Storage path for
-DSYSCONFDIR=/etc \ # Specify the storage path of the configuration file
-DSYSTEMD_PID_DIR=/usr/local/mysql \ # Specifies the storage path of the process file
-DDEFAULT_CHARSET=utf8 \ # Specifies the default character set encoding , Such as utf8
-DDEFAULT_COLLATION=utf8_general_ci \ # Specifies the character set collation rules to be used by default
-DWITH_EXTRA_CHARSETS=all \ # Specify support for other character set encoding
-DWITH_INNOBASE_STORAGE_ENGINE=1 \ # install INNOBASE Storage engine
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \ # install ARCHIVE Storage engine
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ # install BLACKHOLE Storage engine
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \ # install FEDERATED Storage engine
-DMYSQL_DATADIR=/usr/local/mysql/data \ # Specify the storage path of the database file
-DWITH_BOOST=/usr/local/boost \ # Appoint boost The path of , If you use mysql-boost Integration package installation is -DWITH_BOOST=boost
-DWITH_SYSTEMD=1 # Generation facilitates systemctl Administrative document
make && make install



5. 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

6. 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

7. Set the path environment variable
echo 'export PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH' >> /etc/profile
source /etc/profile

8. Initialize database
cd /usr/local/mysql/bin/
./mysqld \
--initialize-insecure \ # Generate initialization password is empty
--user=mysql \ # Generate initialization password is empty
--basedir=/usr/local/mysql \ # Specify the installation directory of the database
--datadir=/usr/local/mysql/data # Specify the storage path of the database file

9. add to mysqld system service
cp /usr/local/mysql/usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system/ # be used for systemctl Service management
systemctl daemon-reload # Refresh recognition
systemctl start mysqld.service # Opening service
systemctl enable mysqld # Boot up
netstat -anpt | grep 3306 # Check the port

10. modify 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 )

11. 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
% Represents a wildcard arbitrary value
show databases; # View the existing database

3 Installation configuration PHP Analyze the environment
1. Will install PHP The required software package is transferred to /opt Under the table of contents
php-7.1.10.tar.bz2

2. 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

3. 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 && make install


4. Path optimization
ln -s /usr/local/php/bin/* /usr/local/bin/
ln -s /usr/local/php/sbin/* /usr/local/sbin/

5. 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
cp /opt/php-7.1.10/php.ini-development /usr/local/php7/php.ini
# Use... In the test environment php.ini-development file , And in the production environment php.ini-production file
vim /usr/local/php7/php.ini
--1170 That's ok -- modify
mysqli.default_socket = /usr/local/mysql/mysql.sock
--939 That's ok -- uncomment , modify
date.timezone = Asia/Shanghai
php -m # Verify the installed module


Adjust the process service profile
cd /usr/local/php/etc/
cp php-fpm.conf.default php-fpm.conf
vim php-fpm.conf
--17 That's ok -- Get rid of ";" notes
pid = run/php-fpm.pid

Adjust the extended profile
cd /usr/local/php/etc/php-fpm.d/
cp www.conf.default www.conf

6. start-up php-fpm
/usr/local/php/sbin/php-fpm -c /usr/local/php/lib/php.ini
netstat -anpt | grep 9000

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 /opt/php-7.1.10/sapi/fpm
cp php-fpm.service /usr/lib/systemd/system/php-fpm.service
systemctl restart php-fpm.service

7. To configure Nginx Support PHP analysis
vim /usr/local/nginx/conf/nginx.conf
--65 That's ok -- 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 Working directory of
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #$document_root On behalf of the current request root The value specified in the instruction
include fastcgi_params;
}
systemctl restart nginx.service

8. verification PHP Test page
vim /usr/local/nginx/html/index.php
<?php
phpinfo();
?>
Browser access
http://192.168.16.16/index.php


9. Verify that the database is working properly
mysql -u root -p
CREATE DATABASE bbs; # establish bbs library
show databases; # View Library
GRANT all ON bbs.* TO 'bbsuser'@'%' IDENTIFIED BY 'admin123';
to Create user later ,% All users
GRANT all ON bbs.* TO 'bbsuser'@'localhost' IDENTIFIED BY 'admin123';
flush privileges;
vim /usr/local/nginx/html/index.php # Replace the content of the original test page
<?php
$link=mysqli_connect('192.168.16.16','bbsuser','admin123');
if($link) echo "<h1>Success!!</h1>";
else echo "Fail!!";
?>
Browser access
http://192.168.16.16/index.php



4 Deploy Discuz! Community BBS Web application
cd /opt
unzip Discuz_X3.4_SC_UTF8.zip -d /opt/dis
cd /opt/dis/dir_SC_UTF8/
cp -r upload/ /usr/local/nginx/html/bbs/ # Upload site update package


Adjust the permissions of forum Directory
ps aux # The user name of the forum process is daemon
cd /usr/local/nginx/html/bbs/
chown -R daemon ./config
chown -R daemon ./data
chown -R daemon ./uc_client
chown -R daemon ./uc_server/data
or
chmod -R 777 ./config/
chmod -R 777 ./data/
chmod -R 777 ./uc_client/
chmod -R 777 ./uc_server/

Forum page access
http://192.168.16.16/bbs/install/index.php
database server :localhost ### It's built locally localhost, How not to fill in on this machine IP Address and port number
Database name :bbs
Database user name :bbsuser
Database password :admin123
Administrator account :admin
Administrator password :admin123
Visit the forum page :
http://192.168.16.16/bbs/index.php
http://192.168.16.16/bbs/admin.php




installation is complete 


5 fpm Parameter optimization
Nginx Of PHP If the implementation of parsing function is entrusted to FPM To deal with the , In order to improve the PHP Processing speed of , But for FPM Module to adjust the parameters , According to the memory and service load of the server , adjustment FPM Module parameters
vim /usr/local/php/etc/php-fpm.conf
pid = run/php-fpm.pid
vim /usr/local/php/etc/php-fpm.d/www.conf
--96 That's ok --
pm = dynamic #fpm Process startup mode , Dynamic
--107 That's ok --
pm.max_children=20 #fpm The maximum number of processes started by a process
--112 That's ok --
pm.start_servers = 5 # The number of processes started by default when starting in dynamic mode , Between the smallest and the largest
--117 That's ok --
pm.min_spare_servers = 2 # Minimum number of idle processes in dynamic mode
--122 That's ok --
pm.max_spare_servers = 8 # The maximum number of idle processes in dynamic mode
-----------------------------------------------------------------------------
kill -USR2 `cat /usr/local/php/var/run/php-fpm.pid` # restart php-fpm
perhaps systemctl start php-fpm.service
netstat -anpt | grep 9000
ps -elf | grep php-fpm


版权声明
本文为[[email protected]]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206111936500062.html
边栏推荐
- Picture bed: picgo+ Tencent cloud +typera
- Template and requirements of curriculum design of reinforced concrete structure in autumn 21 of Dagong [standard answer]
- POJ 1458 longest common subsequence (dynamic planning exercise)
- Flutter--Button浅谈
- 【高精度】X进制整数加法
- 干货!基于序列超图神经网络的信息扩散预测
- Raki's notes on reading paper: memory replace with data compression for continuous learning
- Yolov3 pytoch code and principle analysis (II): network structure and loss calculation
- WR | effect of micro nano plastic pollution in Jufeng formation of West Lake University on microbial flora and nitrogen removal function of Constructed Wetland
- AHB2APB_ Bridge design
猜你喜欢

AHB2Standard_handshake_bridge 设计

Use Mysql to determine the day of the week

谷歌提出超强预训练模型CoCa,在ImageNet上微调Top-1准确率达91%!在多个下游任务上SOTA!...

dried food! Information diffusion prediction based on sequence hypergraph neural network

Raki's notes on reading paper: learning fast, learning slow: a general continuous learning method

Qubicle notes: self set shortcut keys (attached with Lao Wang's self set shortcut key file)

In 2021, the global barite product revenue was about $571.3 million, and it is expected to reach $710.2 million in 2028

iMeta | 南科大夏雨组纳米孔测序揭示微生物可减轻高海拔冻土温室气体排放

What is the workflow of dry goods MapReduce?

基于 Vue + Codemirror 实现 SQL 在线编辑器
随机推荐
【Laravel系列7.5】事件系统
AHB2APB_bridge 设计
CMU 15-445 数据库课程第五课文字版 - 缓冲池
Off line operation of situation and policy (version) of Dayong in autumn 21 [standard answer]
【Bug解决】UnpicklingError: A load persistent id instruction was encountered, but no persistent_load.
Tensorflow---TFRecord文件的创建与读取
图床:PicGo+腾讯云+typora
iMeta | 南科大夏雨组纳米孔测序揭示微生物可减轻高海拔冻土温室气体排放
MySQL - transaction
CMU 15-445 database course lesson 5 text version - buffer pool
[C language questions -- 10 simple questions for leetcode]
干货!基于序列超图神经网络的信息扩散预测
30讲 线性代数第二讲 矩阵
556. next larger element iii- (31. next permutation) - two iterations
【高精度】X进制整数加法
Go语言入门(五)——分支语句
【求助】请问如何让微信公众号文章在外部浏览器中打开后还能显示下方的精选留言?
[laravel series 7.5] event system
Merge sort divide and conquer
SISO decoder for repetition (supplementary Chapter 4)