Configuration database
Execute the following command to enter MariaDB.
mysql -uroot -p
-
Execute the following command to create the MariaDB database. For example "wordpress".
CREATE DATABASE wordpress;
-
Execute the following command to create a new user. For example, "user", the login password is 123456.
CREATE USER ‘user’@‘localhost’ IDENTIFIED BY ‘123456’;
-
Execute the following command to grant the user full permissions on the "wordpress" database.
GRANT ALL PRIVILEGES ON wordpress.* TO ‘user’@‘localhost’;
-
Execute the following command to set the root account password.
Note: MariaDB 10.4 has added the root account password-free login function on CentOS systems. Please perform the following steps to set your root account password and remember it.
ALTER USER root@localhost IDENTIFIED VIA mysql_native_password USING PASSWORD('输入您的密码');
-
Execute the following commands to make all configurations take effect.
FLUSH PRIVILEGES;
-
Execute the following command to exit MariaDB.
exit
Install and configure WordPress
Download WordPress
WordPress You can download the latest Chinese version of WordPress from the WordPress official website and install it. This tutorial uses the Chinese version of WordPress.
-
Execute the following command to delete the index.php file used to test the PHP-Nginx configuration in the root directory of the website.
rm -rf /usr/share/nginx/html/index.php
-
Execute the following commands in sequence, enter the /usr/share/nginx/html/ directory, and download and decompress WordPress.
cd /usr/share/nginx/html
-
Download the latest version of wordpress
wget https://cn.wordpress.org/wordpress-6.1.1-zh_CN.tar.gz
-
Unzip wordpress
tar zxvf wordpress-5.0.4-zh_CN.tar.gz
Modify WordPress configuration file
-
Execute the following commands in sequence, enter the WordPress installation directory, copy the wp-config-sample.php file to the wp-config.php file, and keep the original sample configuration file as a backup.
cd /usr/share/nginx/html/wordpress
cp wp-config-sample.php wp-config.php -
Execute the following command to open and edit the newly created configuration file.
Note: Press i to switch to edit mode, find the MySQL part of the file, and modify the relevant configuration information to configure the content in the WordPress database.
# vim wp-config.php
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');
/** MySQL database username */
define('DB_USER', 'user');
/** MySQL database password */
define('DB_PASSWORD', '123456');
/** MySQL hostname */
define('DB_HOST', 'localhost');
Verify WordPress installation
Go to the WordPress installation page to start configuring WordPress.
-
Enter http://domain name or public IP/wordpress folder of the cloud server instance in the browser address bar , for example:
https://www.jemooner.com/
-
Enter the following installation information according to the WordPress installation wizard prompts, click Install WordPress to complete the installation.
required information | illustrate |
---|---|
site title | WordPress website name. |
username | WordPress administrator name. For security reasons, it is recommended to set a name different from admin. Because this name is harder to crack than the default username admin. |
password | You can use a default strong password or a custom password. Do not reuse existing passwords and be sure to keep them in a safe location. |
your email | Email address to receive notifications. |
WordPress installation plug-in prompts that ftp service is required
The wordpress installation plug-in prompts that the ftp service is required. In fact, it is not really necessary to install the ftp service. Just modify the wordpress configuration.
Find the wp-config.php file in the WordPress installation directory and add the following code to the file:
define("FS_METHOD","direct");
define("FS_CHMOD_DIR", 0777);
define("FS_CHMOD_FILE", 0777);
Then give permissions to the WordPress installation directory:
chmod -R 777 wordpress安装目录
WordPress changes file upload restrictions
Wordpress upload files generally have a limit, usually 2M, which is not enough in some cases, so it is natural to increase its upload file limit size.
-
Find the php.ini configuration file
-
Configuration parameter meaning
upload_max_filesize(最大上传文件大小)
post_max_size(POST数据最大字节长度)
max_execution_time(最大执行时间,单位秒)
-
Then just modify the following values
upload_max_filesize = 50M
post_max_size = 50M
max_execution_time = 300
wordpress out of memory
The PHP memory limit defaults to 128. From the point of view of the problem, the default limit has been exceeded
FastCGI sent in stderr: "PHP message: PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 954368 bytes)
If we have access to the php.ini file, we can edit the value memory_limit to whatever we want. Then restart the php service
Installing WordPress does not have the button to install new plugins and themes
The wp-config.php file is configured not to allow file editing
solution:
Edit /var/www/html/wp-blog/wp-config.php
to delete or change the following configuration to false
# 禁止文件编辑
define( 'DISALLOW_FILE_EDIT' , true );
# 禁止文件模式
define( 'DISALLOW_FILE_MODS' , true );