Centos 7.X WordPress blog website detailed tutorial FTP/PHP/mysql/Apache environment construction

This tutorial is applicable to the server system centos 7.x, the php installation version is 7.4, and the mysql installation version is 5.7.

1. mysql installation

1.1 Install three tools

yum install wget
yum install vim
yum install unzip

1.2 Download and install msql

Download the installation package online:

wget https://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm

Install the installation package:

rpm -ivh mysql57-community-release-el7-8.noarch.rpm

1.3 Install mysql service

Enter /etc/yum.repos.d/the directory:

cd /etc/yum.repos.d/

Install mysql server:

yum -y install mysql-server

At this time, an error may be reported due to a key problem: Pblic key for mysql-community-common... Failing package is: mysql.... Just update the secret key at this point:

rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022

Perform the installation again:

yum -y install mysql-server

Start mysql:

systemctl start mysqld

1.4 Change password

Get initial password:

grep 'temporary password' /var/log/mysqld.log

 You can see that my initial password is: VN>iPrs2Qg>d

Log in to mysql (just enter the initial password above in the password input option):

mysql -u root -p

Set the password policy level to low (the original setting requires uppercase and lowercase letters and symbols):

set global validate_password_policy=LOW;

Change password (12345678 is the modified password):

ALTER USER 'root'@'localhost' IDENTIFIED BY '12345678';

1.5 Create WordPress database

Create a database (here I name the created database tgq)

CREATE DATABASE tgq CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

Create a database user (username is set to: tgq_user, password is set to: 123456)

create user 'tgq_user'@'localhost' identified by '123456';

Grant user permissions:

grant all privileges on tgq.* to 'tgq_user'@'localhost' identified by '123456';

Exit the database:

exit;

2. Install Apache

2.1 Install and start apache

Install Apache:

yum install httpd

Start Apache:

apachectl start

Check Apache status:

systemctl status httpd

 2.2 Set up startup

Set up startup:

systemctl enable httpd

Check whether it has been added:

systemctl list-unit-files | grep httpd

3. PHP installation

3.1 Install and enable EPEL and REMI libraries

Install EPEL and REMI libraries:

yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm

Enable REMI library:

yum -y install yum-utils
yum-config-manager --enable remi-php74

3.2 Install PHP

Install php:

sudo yum install php php-cli php-mysql php-gd php-zip php-mbstring php-xml  php-imagick

Check the php version:

php -v

 3.3 Apache loads PHP

Edit the httpd.conf file:

vim /etc/httpd/conf/httpd.conf

Move the keyboard to the bottom of the file, press i to enter editing mode, and paste the following code at the bottom:

LoadModule php7_module modules/libphp7.so 

After insertion, it looks like this:

 Press ESC to exit editing, press shift and : keys, enter wq (save and exit).

3.4 Verify PHP

Write test file:

echo "<?php phpinfo(); ?>" > /var/www/html/phpinfo.php

Enter IP/phpinfo.php in the browser to see if the following page can be displayed:

 4. Install FTP

4.1 Install FTP

Online installation:

yum install -y vsftpd
yum install -y ftp

Start the service and set it to start automatically at boot:

systemctl start vsftpd
systemctl enable vsftpd

4.2 Add users

Add user (here my username is: tgq):

useradd tgq

Set password (enter after entering, then enter again):

passwd tgq

Grant permissions:

chmod 777 /var/www
sudo chown -R tgq: /var/www

4.3 FileZilla transfer files

 As shown in the figure above, select FTP for the protocol. Enter the IP of your server on the host. Encrypt it to only use plaintext FTP. The username and password are the username and password created in 4.2, and you can enter.

5. Install WordPress

5.1 Download and upload WordPress

Enter the website: Download | WordPress.org China Simplified Chinese , download the WordPress package.

It is recommended to decompress the package and then directly compress the contents in the package, so that the contents can be decompressed directly to the folder we need.

Here, upload the compressed package to -> /var/www/html through filezilla or other ftp tools:

Decompress the uploaded compressed package (for example, the compressed package name is wordpress.zip):

cd /var/www/html
unzip wordpress.zip

 5.2 Access and configure WordPress through domain name

At this time, if the domain name has been resolved to the server IP, you can access the configuration by entering the domain name.

Enter in the configuration and enter the mysql database name, username and password you set on the database page. If an error occurs, you can modify the wp-config.php file in var/www/html and change the database corresponding options, as shown below:

Of course, don’t forget to give this folder read and write permissions:

chmod -R 777 /var/www/html

Once the installation is successful, you will see this page.

Guess you like

Origin blog.csdn.net/qq_35379989/article/details/130502340