Author: The little princess is in a very good mood
The content of this article is suitable for people like me who have no experience in building WordPress and know nothing about "building a website". What this article highlights is what a Xiaobai should do, including his writing style, which is mainly to restore his mental journey at that time. Of course, I will also make a concise version at the end of the article.
With Alibaba Cloud's lightweight application server, you can install WordPress applications in one step, but the real pitfall is just beginning. For example, applying for domain names, adding certificates, filing, etc
As a rule, let's first review the history of the SSL certificate related problems I encountered after installing WordPress using Alibaba Cloud lightweight application servers.
Mental version
It took me a lot of time to get the SSL certificate free of charge, and the website was also accessed using HTTPS encryption. But when I opened my WordPress excitedly, I saw a mess. The original theme I carefully selected could not be shown at all, and the website became a pure text form.
As a white man, my first reaction was that I had problems with my previous operations. I did not hesitate to restore the previously modified files, and everything was normal after HTTP access. The problem remains after the HTTPS access is changed after the re operation. Then I realized that it was not my previous operation mistake... Of course, this time I directly chose the third online search!
But I didn't know what the problem was or what keywords to search for. It took me a lot of time. In my understanding, the conclusion is that the theme style and image links in WordPress contain http addresses, which cannot be displayed under HTTPS encrypted access, and must be modified. The modification methods include database related operations that I can neither understand nor know where.
Fortunately, after comparing several tutorial versions, we have sorted out such a solution:
1、 Use WinSCP to access the server file directory and directly find the/data/wwwroot/wordpress/wp includes/functions.php file for editing.
2、 Edit the functions.php file:
Find code:
require ABSPATH . WPINC . / option.php;
Copy and paste the following code below:
add_filter(script_loader_src, agnostic_script_loader_src, 20,2);
function agnostic_script_loader_src($src, $handle) {
return preg_replace(/^(http|https):/, $src);
}
add_filter(style_loader_src, agnostic_style_loader_src, 20,2);
function agnostic_style_loader_src($src, $handle) {
return preg_replace(/^(http|https):/, $src);
}
The final effect is as follows:
Click Save in the upper left corner.
3、 Use WinSCP to access the server file directory and directly find the/data/wwwroot/wordpress/wp-config.php file for editing.
4、 Edit the wp-config.php file:
Find code:
*
* @package WordPress
*/
Copy and paste the following code below:
$_SERVER[HTTPS] = on;
define(FORCE_SSL_LOGIN, true);
define(FORCE_SSL_ADMIN, true);
The final effect is as follows:
Click Save in the upper left corner.
5、 Enter the lightweight application server background and restart the server to make the above changes take effect. Then enter the WordPress background and modify the WordPress address (URL) ② and site address (URL) ③ to //your domain name (originally //your domain name or IP address) in Settings ① - General.
Attachment 1: Don't forget to add your domain name. Don't just write //as shown in the figure, and think it's done... The correct form should be similar //example.com In this way. Wrong writing, saving is a big hole
Attachment 2: If you only read this article, I'm afraid you forgot the problem of domain name resolution. Please note that this is the third article, and there are two previous articles. If it is really a little white like me, please read it from the beginning before operating.
6、 Save the changes, and then enter the lightweight application server background to restart the server.
If you enter WordPress at this time and no theme style or picture is displayed, you can switch to another theme temporarily first and then switch back.
Concise version
Locate the/wp includes/functions. php file; Add a piece of code to solve the problem of missing theme style (you still need to see the previous mental chapter for details of graphics and text and code).
Locate the/wp-config.php file; Add a piece of code to solve the background login problem (you still need to see the previous mental chapter for details of graphics and text and code).
Enter the WordPress background, and modify the WordPress address (URL) and site address (URL) to //your domain name (originally //your domain name or IP address) in Settings - General.
Some remarks
Many online tutorials mention that installing a really simple ssl plug-in into WordPress can be a more perfect solution. However, as a Xiaobai, I can only install the plug-in, but I don't know how to use it. I don't actually use the plug-in, but I can still solve the problems I have encountered. So we will study it when necessary, and update it at that time.