HTTPS WordPress build a personal blog step

Source: Internet
Author: User
Tags install wordpress certbot


WordPress Build personal Blog All Raiders



Overview



These days set up a blog of their own, using the WordPress



Because you want to get HTTPS, and then the online tutorials are not so comprehensive, and also found that the WordPress enabled HTTPS method is mostly too complex and unnecessary, so here will build their own process to share



Preparatory work



A server, needless to say,



Domain name, I am a two-level domain name to the blog is located in the directory, is the SSL certificate after the blog.xujifa.cn is directly to the two-level domain name



installation process



First, the database



Install MARIADB, of course MySQL is the same



You can use this command.sudo yum install mariadb mariadb-server



Password or something, log in to the database.


CREATE DATABASE WordPress; CREATE USER wordpressuser@localhost identified by ' password '; GRANT all privileges the wordpress.* to wordpressuser@localhost identified by ' password '; FLUSH privileges; EXIT;


The name inside is as good as you like to set it.



Second, Apache and PHP



Install Apache:sudo yum install httpd mod_ssl mod_rewrite



Install PHP:sudo yum install php php-mysql



Start Apache:sudo apachectl startwhen you need to reboot latersudo apachectl restart



Third, download WordPress



The latest version is 4.7.1, strongly recommend the use of English version, the beginning of the Chinese version of the interface after the problem, not sure is the Chinese version of the pot, but a little, the English version will be much faster than the Chinese version, do not know why, simply metaphysics.


wget https://wordpress.org/latest.tar.gz


And move this to the/var/www/html/directory.



Unzip


TAR-XZVF lastest.tar.gz


Then change the folder's user to Apache


sudo chown-r apache/var/www/html/

Problem:

If you encounter themes and plugins in the process of using WordPress, when prompted to require an FTP username and password, try to re-run the above authorization command


And then stop for a second. HTTPS OK and then go to WordPress, this will probably be better



Four, Https



With a free certificate issued by Let's Encrypt, it provides a tool called Certbot to help issue certificates, as follows


sudo yum install Python-certbot-apachesudo Certbot--apche


You will then be asked to fill in the URL, you can



However, it is important to note that this certificate is valid for 90 days, Certbot also support auto-renewal, execute the following command


sudo certbot renew--dry-run


This time through HTTPS access to your own site will find that there is already a small green lock.



If your blog is not placed in the root directory, for example, I hope


https://blog.xujifa.cn


The point is/var/www/html/blogthat this will require a little extra action.



Certbot will/etc/httpd/conf.d/generate thessl.conffile below, find this tag in this file,<VirtualHost _default\_:443>it will have attributes below,DocumentRootcancel its comment and change its value to the path you need, restart httpd, you can.



Now our website should be able to access through HTTP and HTTPS, a bit too shanbao, we want HTTP can be directed to HTTPS, before the installationhttpdof the same time installed amod_rewritemodule, now is the time to use it.



Open/etc/httpd/conf/httpd.confThe file, locate the<Document "/var/www/html">label, andAllowOverride Nonechange it toAllowOverride All.



Then in your blog directory (we extracted in the third step of the path) to create a.htaccessfile named, add the following, you can.


Rewriteengine on Rewritebase/rewritecond%{server_port}!^443$ rewriterule ^.*$ Https://%{server_name}%{request_uri} [ L,R=301]


Five, continue to install WordPress



Just in the third step, we will be WordPress unzip in the/var/www/html/directory, go to the directory, find thewp-config-example.phpfile, rename it aswp-config.php, modify the information about the database (or can also be set in the following steps through the Web page), and add these two sentences, to set the HTTPS


Define (' Force_ssl_admin ', true);d efine (' Force_ssl_login ', true);


Because WordPress used Google to provide some resources, such as fonts, was wall, so also need to change to domestic sources, where we use  of the resources provided, openwp-includes/script-loader.php, will begoogleapisall inside replaceduseso.



Vi. beginning of Use



Visit our blog through a browser, set up the database information on the first page (if you've done it in the previous step, you'll skip it), and then set your own username and password to start using it.



The main content of this blog is so much, the above steps if I did not miss what it should be enough.



If there is something wrong with the article or if there is something unclear, please comment, I will reply as soon as possible.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.