Yum install LNMP

Time:2020-9-23

Yum install LNMP + WordPress

Basic configuration

Xserver1 decompresses and opens the virtual machine configuration IP

Mount image

# mkdir /opt/centos

# mount CentOS-7-x86_64-DVD-1511.iso /opt/centos/

Configure local Yum source file

# mv /etc/yum.repos.d/* /media/

# vi /etc/yum.repos.d/local.repo

[centos]
name=centos
baseurl=file:///opt/centos
gpgcheck=0
enabled=1
[lnmp]
name=lnmp
baseurl=file:///root/lnmp
gpgcheck=0
enabled=1

Turn off the firewall

# setenforce 0

# systemctl stop firewalld

Install and configure LNMP

Installation services

# yum install -y nginx mariadb mariadb-server php-fpm php-mysql

Create directory

# mkdir /www

# chown nginx:nginx /www/

Edit nginx file

# vi /etc/nginx/fastcgi_params

 

fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_ param  SCRIPT_ FILENAME    $document_ root$fastcgi_ script_ Name; / / add this line
fastcgi_param  REQUEST_URI        $request_uri;

 

# vi /etc/nginx/conf.d/default.conf

location / {
Root / WWW; / / change page directory
        index  index.php index.html index.htm ; / / add index.php
    }

Location ~ \. PHP ${/ / remove the comment in front of this section
Root / WWW; / / change directory
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        include        fastcgi_params;
    }

Start service

# systemctl start nginx

View service status

# systemctl status nginx

Edit PHP file

# vi /etc/php-fpm.d/www.conf

User = nginx / / modify users and groups

group = nginx

Start service

# service php-fpm start
Redirecting to /bin/systemctl start  php-fpm.service

View service status

# systemctl status php-fpm

Initialize database

# systemctl start mariadb

# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we’ll need the current
password for the root user.  If you’ve just installed MariaDB, and
you haven’t set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none): press enter by default
OK, successfully used password, moving on…
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y
New password: enter the database root password
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 … Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
 … Success!
Normally, root should only be allowed to connect from ‘localhost’.  This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] n
 … skipping.
By default, MariaDB comes with a database named ‘test’ that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
 – Dropping test database…
 … Success!
 – Removing privileges on test database…
 … Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
 … Success!
Cleaning up…
All done!  If you’ve completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
 
View service status
# systemctl status mariadb

Enter database

# mysql -uroot -p000000

Authorization can log in to the database as root on any client machine

> grant all privileges on *.* to [email protected]’%’ identified by ‘000000’;

Create database

> create database wordpress;

Exit database

View port

# yum install -y net-tools

# netstat -ntpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN      3458/php-fpm: maste
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      3854/mysqld         
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      3449/nginx: master  
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1422/sshd           
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      2025/master         
tcp6       0      0 :::22                   :::*                    LISTEN      1422/sshd           
tcp6       0      0 ::1:25                  :::*                    LISTEN      2025/master     

Deploy WordPress

Unzip file

# yum install -y unzip

# unzip wordpress-4.7.3-zh_CN.zip

Modify configuration file

# mv wordpress/* /www/

# cp /www/wp-config-sample.php /www/wp-config.php

# vi /www/wp-config.php

//* * MySQL settings – specific information from the host you are using * *//
/**The name of the WordPress database*/
define(‘DB_NAME’, ‘wordpress’);

/**Mysql database user name*/
define(‘DB_USER’, ‘root’);

/**Mysql database password*/
define(‘DB_PASSWORD’, ‘000000’);

/**MySQL host*/
define(‘DB_HOST’, ‘192.168.100.10’);

/**Default text encoding when creating data tables*/
define(‘DB_CHARSET’, ‘utf8’);

/**Database collation type. Do not change if you are not sure*/
define(‘DB_COLLATE’, ”);

 

Web access IP

Set the title of WordPress to your own name