After we got an VM from Xunkongjian. We are going to install wordpress to verify everything is OK. This article going to explains this step by step.
Before install Wordpress, we need to install LAMP stack. In this senario, what we need to do is install Apache, MariaDB and PHP.
Login to your VM, launch these commands under root:
apt install apache2
Then open file
/etc/apache2/ports.conf, find the line which contains
Listen, Add the IPv6 address which you have.
Note: You can check your IPv6 address from the command
ip address and find the line inet6. If you don't have the IPv6 address, you can look at this article:
Then launch the following command to restart apache:
systemctl restart apache2
[YOUR_IPv6_ADDRESS] in your browser(with the square brackets). You are suppose to see the default apache page.
The next step is install PHP. Here we just install the basic PHP package. Run this command:
apt install php-cli libapache2-mod-php
Then use vim to create a new file in the following path:
Append this content:
Open file /etc/apache2/mods-enabled/dir.conf, you can see the content like:
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
Move the file name "index.php" to the place which just behind "DirectoryIndex", save and exit, then restart the Apache service.
Then open this address in your browser, you are suppose to see the default PHP page:
Install MariaDB through this command:
apt install mariadb-server
Them use the following commands to start mariadb service:
systemctl start mariadb
systemctl enable mariadb
Now we can test the mariadb installation:
If you get this output, it means the installation is successful:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 47
Server version: 10.3.18-MariaDB-0+deb10u1 Debian 10
Then we do some basic setting on that MariaDB:
MariaDB [(none)]> GRANT ALL ON *.* TO 'admin'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;
MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> exit
Now, any time you want to access your database as your new administrative user, you’ll need to authenticate as that user with the password you just set using the following command:
mariadb -u admin -p
Now you can exit MariaDB:
But before exit, we do some setting for the wordpress:
CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
GRANT ALL ON wordpress.* TO 'wordpressuser'@'localhost' IDENTIFIED BY 'password';
Now we have a table which named wordpress and a user wordpressuser with password.
Install Addtional PHP Component
apt install php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip php-mysql
We will restart Apache to load these new extensions in the next section. If you are returning here to install additional plugins, you can restart Apache now by typing:
sudo systemctl restart apache2
Additional Apache Configuration
Before install WordPress itself, we need to do some additional apache configuration.
Open the Apache configuration file for your website. Note that if you have an existing Apache configuration file for your website, this file's name will be different. The default file is "/etc/apache2/sites-available/000-default.conf". Change the variable value DocumentRoot:
Currently, the use of .htaccess files is disabled. WordPress and many WordPress plugins use these files extensively for in-directory tweaks to the web server's behavior.
To allow .htaccess files, you'll need to add a Directory block pointing to your document root with an AllowOverride directive within it. Add the following block of text inside the VirtualHost block in your configuration file, being sure to use the correct web root directory:
When you are finished, save and close the file.
Before implementing the changes you've made, check to make sure that you haven't made any syntax errors:
sudo apache2ctl configtest
If your configuration file's syntax is correct, you'll see the following in your output:
If this command reports any errors, go back and check that you haven't made any syntax errors in your configuration file. Otherwise, restart Apache to implement the changes:
sudo systemctl restart apache2
Next, we will download and set up WordPress itself.
Download and Install WordPress
First we need to download and unzip WordPress, you can go to the
tmp dir and execute the following commands:
tar zxvf wordpress-5.0.4-zh_CN.tar.gz
Important Note: The official domain of wordpress is wordpress.org. So the standard way is download wordpress from https://wordpress.org/latest.tar.gz or https://cn.wordpress.org/latest-zh_CN.tar.gz But if you are in China, you should use the link https://download.wp.com.cn/wordpress-5.2.4-zh_CN.tar.gz. Otherwise you may unable to get wordpress in your VM. See here to find more information: https://wordpress.org/support/topic/is-wordpress-org-restricting-vitis-from-china-region/
Before we move these files into our document root. We need to add a dummy .htaccess file so that this will be available for WordPress to use later. Create the file by typing:
Then copy over the sample configuration file to the filename that WordPress actually reads:
cp /tmp/wordpress/wp-config-sample.php /tmp/wordpress/wp-config.php
Then, copy the entire contents of the directory into your document root. Notice that the following command includes a dot at the end of the source directory to indicate that everything within the directory should be copied, including hidden files (like the .htaccess file you created):
sudo cp -a /tmp/wordpress/. /var/www/wordpress
With that, you've successfully installed WordPress onto your web server and performed some of the initial configuration steps. Next, we'll discuss some further configuration changes that will give WordPress the privileges it needs to function as well as access to the MariaDB database and user account you created previously.
Connect Wordpress and MariaDB
After installed the Wordpress, the next step is modify the database connection settings in the file
/var/www/wordpress/wp-config.php. You need to adjust the database name, the database user, and the associated password that you've configured within MariaDB.
The other change you must make is to set the method that WordPress should use to write to the filesystem.
. . .
/** MySQL database username */
/** MySQL database password */
. . .
Save and close the file when you are finished. Finally, you can finish installing and configuring WordPress by accessing it through your web browser.
Now that the server configuration is complete, we can complete the installation through the web interface.
In your web browser, navigate to your server's domain name or public IP address: