lnmp architecture to build wordpress

Build wordpress using lnmp architecture

1. lnmp architecture
1. Among the four components of the LNMP platform, each component is responsible for some key applications. After more than ten years of development, the compatibility, collaboration capabilities and stability of each component have been continuously improved. It is also constantly being enhanced, and a very excellent web application system can be built. The main functions of each component are as follows:
(1) Linux system: As the basis of the lnmp architecture, it provides an operating system for supporting web sites and can interact with other The stability and compatibility of the three components (the other three components also support Windows, UNIX and other operating systems).
(2). nginx website server: As the front end of the LNMP architecture, nginx is a powerful function.
(3). Mysql database server: As the back end of the LAMP architecture, it is a popular open source relational database system. In corporate websites, business In applications such as systems, various account information, product information, customer information, business data, etc. can be stored in the mysql database, and other open source programs can query and change this information through SQL statements.
(4), php/perl/python web programming language: As three programming languages ​​for developing dynamic web pages, it is responsible for interpreting dynamic web page files and providing a development and running environment for web applications. Among them, PHP is a widely used open source multi-purpose scripting language. It can be embedded in HTML and is especially suitable for web application development.

2. Application advantages of the LNMP platform
1. Each of the four components that constitute the LNMP platform has experienced decades of enterprise application testing. Each component is the leader in similar software, thus becoming a typical "gold" Partner", its main advantages are in the following aspects:
(1) Low cost: Each component is open source.
(2) Customizable: Has a large number of additional components and modules with scalable functions.
(3) Easy to develop: The page code is concise
(4) Easy to use: PHP, Perl, etc. are interpreted languages, and the various web programs developed do not need to be compiled.
(5) Security and stability: Benefit from the advantages of open source.
2. When building the LNMP platform, the installation order of each component is Llinx, nginx, mysql, and php. There is no strict order for the installation of nginx and mysql; while the installation of the PHP environment is generally placed last, responsible for communicating with the web server and database system to work together.

3. Deployment of LNMP platform

1. Prepare a linux environment

(1), Linux: centos7.4
(2), ip: 172.16.1.105
(3), close selinux
Insert image description here
Insert image description here
Insert image description here

2. Install nginx:1.20 on linux

(1), Nginx:1.20 download address: wget http://nginx.org/download/nginx-1.20.2.tar.gz
Insert image description here

(2), install nginx
vim /etc/yum.repos.d/local.repo #Write yum warehouse
[cdrom]
name=benet
baseurl=file:///media/cdrom
enabled=1
gpgcheck=0

mount /dev/cdrom /
media/cdrom/ #Mount CD
Insert image description here

yum -y install gcc gcc-c++ autoconf automake make pcre pcre-devel zlib zlib-devel pcre pcre-devel zlib zlib-devel openssl openssl-devel #Install nginx related environment packages

Explanation: yum -y install gcc gcc-c++ autoconf automake make # c compiler

yum install -y pcre pcre-devel # Parse regular pcre library
yum install -y zlib zlib-devel # Add support for gzip
yum -y install pcre pcre-devel zlib zlib-devel openssl openssl-devel # SSL
Insert image description here

(3) Unzip nginx and compile and install
tar xf nginx-1.20.2.tar.gz
cd nginx-1.20.2
Insert image description here

./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module #Compile and install the corresponding module function of nginx
make && make install
Insert image description here
Insert image description here

(4) Create a soft connection to nginx and start nginx
Insert image description here
Insert image description here

(5) Add firewall rules to run port 80
Insert image description here

Visit: http://172.16.1.105
Insert image description here
Insert image description here

3. Install mysql (database) on linux

(1) Download mysql
rpm -Uvh http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm #Download the yum source of mysql5.7
yum -y install mysql-community- server –nogpgcheck #yum install mysql service
Insert image description here

(2) Start mysql and set it to self-start
systemctl start mysqld #Start mysqld
systemctl enable mysqld #sSet to turn on self-start
systemctl daemon-reload #Reload the configuration file of a certain service
Insert image description here

4. Install PHP7.3.28

(1) Install the dependency packages needed to support the PHP environment
yum install -y libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt -devel readline readline-devel libxslt libxslt-devel sqlite-devel oniguruma-devel
Insert image description here

(2) Download PHP7.3.28, unzip, compile and install
wget https://www.php.net/distributions/php-7.3.28.tar.gz #Download the php source code package
mkdir -p /usr/local/php7. 3 #Create directory
Insert image description here

tar xf php-7.3.28.tar.gz #Extract
cd php-7.3.28/ #Switch to the php directory
Insert image description here

./configure -prefix=/usr/local/php7.3 -with-zlib-dir -enable-mbstring -enable-soap -enable-calendar -with-curl -disable-rpath -enable-inline-optimization -with-bz2 -with-zlib -enable-sockets -enable-sysvsem -enable-sysvshm -enable-pcntl -enable-mbregex -enable-exif -enable-bcmath -with-mhash -with-pdo-mysql -with-mysqli -with-openssl -with-fpm-user=nobody -with-fpm-group=nobody -enable-ftp -with-gettext -with-xmlrpc -with-xsl -enable-opcache -enable-fpm -with-iconv
#配置变量
Insert image description here

make all install #Compile and install (it takes a long time to wait patiently)Insert image description here

make test #Check the compilation results (it takes a long time to wait patiently)
cp /usr/local/php7.3/etc/php-fpm.conf.default /usr/local/php7.3/etc/php-fpm.conf
cp / usr/local/php7.3/etc/php-fpm.d/www.conf.default /usr/local/php7.3/etc/php-fpm.d/www.conf
#Copy configuration file
Insert image description here
Insert image description here

#Create user nginx
useradd nginx -s /usr/sbin/nologin
Insert image description here

#Start php-fpm
/usr/local/php7.3/sbin/php-fpm
View service php-fpm
Insert image description here

5. Configure nginx

Lines 35 to 77 configure

server {
    listen       80;
    server_name  localhost;
    #access_log /usr/local/nginx/logs/wordpress/access2.log main;
    #error_log /usr/local/nginx/logs/wordpress/error2.log;
    root /wordpress/wordpress/blog/;
    error_page 500 502 503 504 /50x.html;
    location test/ {
    rewrite ^test(.*)$ wp-admin$1 last;
    }
    #access_log  logs/host.access.log  main;

    location / {
        root   /wordpress/wordpress/blog/;
        index  index.php index.htm index.html;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }
    rewrite /wp-admin$ $scheme://$host$uri/ permanent;
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
    root /wordpress/wordpress/blog/;
    fastcgi_pass 127.0.0.1:9000;
    #fastcgi_pass 127.0.0.1:9001;   # 配置一个php不需要这一行
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    }

Insert image description hereInsert image description here

Check the configuration file for errors nginx -t
Nginx -t
Insert image description here

Reload nginx configuration
nginx -s reload
Insert image description here

6. Configure mysql (database)

(1) Get the initial password of root
grep 'temporary password' /var/log/mysqld.log
Insert image description here

(2) Initialize the database
mysql_secure_installation

Insert image description here
Insert image description here
Insert image description here

(3) Log in to mysql and create a database and account and grant permissions (my password is Abc!123,)
mysql -uroot -p #Log in to the database
Insert image description here

create database wordpress; #Create database wordpress
create user admin@“%” identified by “Abc!123,”; #Create user admin, password: Abc!123, grant all privileges
on wordpress.* to admin@“%” identified by “Abc!123,”; #Authorize admin
flush privileges; #Refresh permissionsquit
#Exit
Insert image description here

7. Download wordpress and unzip it

(1) Download wordpress to /wordpress/
wget -P /wordpress https://cn.wordpress.org/wordpress-6.0-zh_CN.zip
Insert image description here

(2) Unzip and move the content to wordpress/blog/
cd /wordpress
unzip wordpress-6.0-zh_CN.zip
mkdir -p ./wordpress/blog
mv ./wordpress/* ./wordpress/blog/
Insert image description here

(3) Visit the page http://172.16.1.105/wordpress
Insert image description here

Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here
Insert image description here

Guess you like

Origin blog.csdn.net/m0_57207884/article/details/130044568