This is the 29th day of my participation in the Gwen Challenge in November. Check out the details: The last Gwen Challenge in 2021

Before the body begins, say a few words.

Some time ago, the blog was attacked by traffic, fortunately the attack traffic is not very large, only the data of the visitor record table is missing. The server is currently using Apache server, can not withstand heavy traffic access, the server is also about to expire, a new server, configure a new nginx server. Here is my history of blood and tears. Of course, I just can let my website run up on the server, in the depth of such issues as running permissions, may not be involved at present, later encountered to supplement.

 

Install nginx1.1.6

This was introduced in the LAMP environment configuration and NGINX installation, but here is another method, which is almost the same.

1: install the nginx yum source

rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
Copy the code

 

2: Install nginx using yum

yum install -y nginx
Copy the code

3: Start nginx and set the startup to run automatically

Systemctl start nginx # start nginx # start nginxCopy the code

 

4: Uninstalls nginx

yum remove nginx
Copy the code

5: Check the running status of nginx

systemctl  status  nginx
Copy the code

6: View the nginx version

nginx -v
Copy the code

 

Now that nginx has been installed, enter your server’s IP address in your browser and the following screen will appear.

Here comes the biggest bug :(this is my biggest bug when configuring)

If you enter the IP address of the nginx server in the browser, the nginx server cannot be accessed.

Think of nothing but her sister. (No wonder I’m single)

Baidu did a search, but failed to find the answer. It was too troublesome to separate, so I tried to find an LNMP installation package, but it was not good to use. Finally, I found that port 80 of the newly bought server was not open. In the Nginx configuration file, the listener is listening on port 80, so it has been difficult to use. You can refer to it. At this point, the nginx installation is complete.

 

(2) : Install PHP7.2

I have PHP7.2 installed here, so if your project is compatible, it is not recommended to install PHP5.

1: install the PHP yum source

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
Copy the code

 

2: Check php7 yum

yum search php72w
Copy the code

 

3: select their own components to install, php72w.x86_64 and PHP72W-Fpm. X86_64 for the core program must be installed

yum install php72w.x86_64 php72w-fpm.x86_64 php72w-cli.x86_64 php72w-common.x86_64 php72w-gd.x86_64 php72w-ldap.x86_64 php72w-mbstring.x86_64 php72w-mcrypt.x86_64 php72w-mysql.x86_64 php72w-pdo.x86_64 php72w-pecl-redis.x86_64
Copy the code

 

4: Start PHP and set it to boot

Systemctl start PHP - FPM # start PHP - FPM #Copy the code

 

5: View the version and running status

PHP - FPM - v # to check the version of the ps - ef | grep PHP - FPM # to check the running statusCopy the code

 

There’s nothing to say about installing PHP. Just do it step by step.

 

(3) : modify nginx configuration

This requires modifying the nginx configuration file nginx.conf

Find file location command

whereis nginx.conf
Copy the code

 

There are two ways to modify this. If you are familiar with Linux commands, you can use Vim to modify the file directly on the server. Otherwise, once you find the file location, download the file and upload it to the server after you have modified it locally.

vi /etc/nginx/conf.d/default.conf
Copy the code

1: Find the line in the first location

index index.html index.htm; PHP index.html index.htm; # add index. PHPCopy the code

 

2: Uncomment the location below the FastCGI Server line and change it to look like this

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~.php${root /usr/share/nginx/html; # fastcgi_pass 127.0.0.1:9000; Fastcgi_index index. PHP; Fastcgi_param SCRIPT_FILENAME $$fastcgi_script_name document_root; The include fastcgi_params; }Copy the code
Service nginx service PHP -fpm start #Copy the code

 

3: Create the index. PHP file in the root directory of the website

vim /usr/share/nginx/html/index.php
Copy the code

Write whatever you want, I’m going to print phpInfo ();

 

Nginx and PHPFPM are successfully configured if the server IP address /index.php is accessible.

 

(4) : Install database Maraidb10.3

(1) Configure mariadb Yum

Vi/etc/yum. Repos. D/MariaDB. ‘in the file to add the following contents:

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
Copy the code

(2) Install MariaDB

yum install MariaDB-server MariaDB-client -y
Copy the code

(3) Start and stop the service

systemctl start mariadb
systemctl stop mariadb
Copy the code

(4) Set startup

systemctl enable mariadb
Copy the code

(5) Next, perform simple configurations related to MariaDB

mysql_secure_installation
Copy the code

The first is to set the password, will be prompted to enter the password first

Enter current password for root (Enter for None):< - Press Enter for the first timeCopy the code

Set the password

Set root password? [Y/n] < - Whether to set a password for user root, type Y and press Enter or press Enter. New Password: < - Set a password for user root. Re-enter New password: < - Enter the password againCopy the code

Other configuration

Remove anonymous users? [Y/n] < - Whether to delete anonymous users and press Enter Disallow root login Remotely? [Y/n] < - Whether to disable root remote login, press Enter, Remove test database and access to it? [Y/n] < - Whether to delete the test database, Reload privilege tables now? [Y/n] < - Whether to reload the permission table, press EnterCopy the code

 

Initialize MariaDB and test login

Mysql - uroot - ppasswordCopy the code

Add users and set permissions

Create user commands

mysql>create user username@localhost identified by 'password';
Copy the code

Commands to create and authorize users directly

mysql>grant all on *.* to username@localhost indentified by 'password';
Copy the code

Grant extranet login permission

mysql>grant all privileges on *.* to username@'%' identified by 'password';
Copy the code

Grant permissions and can authorize

mysql>grant all privileges on *.* to username@'hostname' identified by 'password' with grant option;
Copy the code

Refresh the permissions

flush privileges; /* Refresh permission */Copy the code

That’s pretty much it for simple user and permission configuration.

The Maraidb installation is complete.

 

If you don’t have a mysql table after installation, go to /var/lib/and delete the mysql folder

 

The CONFIGURATION of the LNMP environment is complete.

That’s how I configured it, I just wrote it down on my server.

For good suggestions, please enter your comments below.

Welcome to my blog guanchao.site

Welcome to applets: