Recently, we have installed and deployed the lamp environment and installed the wordpress blog by using the CentOS 6.4 64 bit ECS (cloud server) instance of the basic environment provided by Alibaba cloud for free. Here we record the experimental process and some small details (such as how to point the domain to a subdirectory), After learning, it will be very easy for you to configure a WordPress website from scratch.
Next, we will start the installation and deployment of lamp in Apache + MySQL + PHP language environment, as well as the installation and basic configuration of WordPress.
(each step has a screenshot and explanation, I believe novices can understand it as soon as they read it)
Before building, please resolve your domain name to the public IP address of the cloud server. Novices can choose “novice guide”, as shown in the figure below:
Here are the steps to build a website:
1、 Log in to the cloud server
Here we choose to use the remote terminal tool to connect, and the CMD command line tool that comes with windows is OK.
First, enter the following command to check whether the SSH tool is installed in the system:
As shown in the figure above, the SSH tool has been installed. If not, you can download and install openssh.
Then use the following command to connect to your cloud server (if your cloud server port 22 and 3389 are open)
ssh [email protected] (here is your public IP)
2、 Install Apache HTTP service
1. Input command to install Apache service and extension package
yum -y install httpd httpd-manual mod_ssl mod_perl mod_auth_mysql
2. After the installation, start the Apache service.
systemctl start httpd.service
3. Access your IP address in the browser
Http: // < public address of cloud server >To test whether the Apache service is installed successfully.
As shown in the figure above, Apache installation is successful.
3、 Install MySQL database
1. Let’s download and install the official MySQL Yum repository
yum -y install mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql-community-server
As shown in the figure above, MySQL is installed successfully.
2. Start MySQL database
systemctl start mysqld.service
3. Let’s check the running status of MySQL (active indicates that it has been turned on)
systemctl status mysqld.service
4. Check the initial password of MySQL. We need to log in later
grep “password” /var/log/mysqld.log
5. Log in to the database (at this time, the interface also does not display the password, just input the password)
mysql -uroot -p
6. Next, let’s modify the default password of MySQL. For example, our password is set to newpassword1
ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘NewPassWord1.’;
7. Then, we create the WordPress database. For example, here I set the database name to WordPress, and you can modify it to what you want.
create database wordpress;
8. After creation, we can check whether the creation is successful. Check with the following command
9. Enter exit to exit the database.
4、 Install PHP language environment
1. Install PHP environment
yum -y install php php-mysql gd php-gd gd-devel php-xml php-common php-mbstring php-ldap php-pear php-xmlrpc php-imap
- Create PHP test page
echo “” > /var/www/html/phpinfo.php
3. Then open the browser and visit
Http: // < public address of cloud server > / phpinfo.php
As shown in the figure above, the PHP language environment is installed successfully.
5、 WordPress installation and configuration
1. Enter the command below to install WordPress.
yum -y install wordpress
As shown in the figure above, the installation is complete.
2. Modify wp-config.php to point to an absolute path
Let’s switch to the / usr / share / WordPress directory first
Then modify the path (i.e. create a soft link)
ln -snf /etc/wordpress/wp-config.php wp-config.php
3. We can check the modified directory structure and use the “ll” command
4. Next, create a WP blog folder in the root directory of Apache / var / www / HTML（ This folder will be used to hold your WordPress website program. Of course, you can also customize the name of the folder. Take WP blog as an example.)
5. Move all the files in the current directory WordPress to / var / www / HTML / WP blog.
mv * /var/www/html/wp-blog/
6. Next, modify the wp-config.php configuration file.
Replace the following three parameter values with the following command (or you can manually modify the data in the wp-config.php configuration file)
database_ name_ Here is the name of the database created in the previous step. This example is WordPress.
username_ Here is the user name of the database. This example is root.
password_ Here is the login password of the database. This example is newpassword1.
Before the replacement, it was like this:
Enter the command to replace the following three parameter values:
sed -i ‘s/database_name_here/wordpress/’ /var/www/html/wp-blog/wp-config.php
sed -i ‘s/username_here/root/’ /var/www/html/wp-blog/wp-config.php
sed -i ‘s/password_here/NewPassWord1./’ /var/www/html/wp-blog/wp-config.php
7. Check whether the configuration file information is modified successfully
cat -n /var/www/html/wp-blog/wp-config.php
As shown in the figure below, you can see that the information has been modified successfully
8. Restart Apache service
systemctl restart httpd
6、 Test and install WordPress
1. Open the browser and visithttp://< Public IP > of cloud server / WP blog / WP admin / install.php
Enter the WordPress initialization configuration interface
2. Fill in relevant information
Site Title: site name, for example: Hello ADC.
User name: administrator user name, for example: admin.
Password: access password, for example: [email protected]%j .
Your email: email address. It is recommended to be a real and valid address. If not, you can fill in the virtual email address, but you will not be able to receive information, for example: [email protected] .
Because we have already modified the database information in the configuration file, we don’t need to fill in the database here, so the installation is completed directly.
3. Log in to the background login user name and password we set, then you can log in to the WordPress management background.
Here our wordpress blog is installed.
However, our blog address at this time is
Http: // < public IP of cloud server > / WP blog/Some friends want to change the blog address to:
Http: // < public IP address of cloud server >, that is, our main domain name can be accessed directly.
This is also a small problem that I want to talk about. There are several specific ways to modify it. Here is the simplest way:
First, open your WordPress background and change the site address to:
Http: // < public IP address of cloud server >Or your domain name（ I haven’t bound the domain name yet, so I’ll use the IP address for demonstration
Then, copy index. PHP from the subdirectory of your website to the root of the website.
Here is to copy index.php from / var / www / HTML / WP blog to / var / www / HTML /
Finally, edit the index. PHP in your root directory (that is, the copy of / var / www / HTML / index. PHP)
Change the “/ WP blog header. PHP” in the last line to “/ WP blog / WP blog header. PHP”, then save and exit.
The specific modification method is officially introduced by WordPress. The method is shown in the figure below, which is the one I used above.
At this point, we open our main domain name
Http: // < public IP address of cloud server >, you can visit our website.
OK, that’s the end of the tutorial. Because every step has a screenshot, so the content is a little long, I hope to help you. Especially novice friends, according to the tutorial step by step, there should be no big problem.