Delivered on time at 11:45 every Friday
My "88" Original
Because I am busy with my work recently, I don't have much time to think and write. So today I will steal a lazy job and post a practical article.
This article is very "dry", "dry" so that you just do it, almost without using your head.
This is because I set up a WordPress blog site a few days ago to synchronize articles on the public account.
In fact, I have had this idea for a long time, but the reason why I didn't start it is that in today's general environment, how much value does the blog have.
Later, I thought that if I only set up blogs and posts in some communities, the verticality of the content is a hard requirement. The technology community can only distribute technology, and the product community can only distribute product.
If you build your own blog site, you will be free to write whatever you want.
In addition, recently Baidu invested Zhihu, which makes me feel that search engines are short of content, especially those differentiated and personalized content.
So he immediately started to work. Blog address( //zacharyfan.com/ ), welcome to collect on the browser.
Back to the point, if you are already a veteran of WordPress, you can skip this article.
Because I haven't built it before, I fumbled about it, met some pits in the middle, and it took me a long time to solve them.
Usually I have a small habit. In order to avoid delay on the same problem in the future, we will habitually record some "difficulties" and corresponding solutions.
So this time I will enrich the whole process by the way and organize it into an article.
It is suggested that you can collect it. Maybe you need to use WordPress to build a website at any time. After all, there are thousands of websites built with it all over the world.
If the software version you choose is the same as mine, follow the steps I write below to ensure that you can successfully build a website within 30 minutes.
22 steps to complete station building
1. First //www.centos.org/ Download the latest version of centos (7.6.1810), either standard or minimal.
Of course, you can also select other operating system versions, but some of the following commands may not be directly copied and pasted for use.
2. After the operating system is installed, it is recommended to directly switch the default yum source to Alibaba Cloud's yum source for easier use.
curl -o /etc/yum.repos.d/CentOS-Base.repo //mirrors.aliyun.com/repo/Centos-7.repo
yum makecache
Then we can start loading wordpress family buckets. Brother Z chooses the combination of LNMP. Of course, you can also choose the combination of LAMP, but the following operations are different, and you need to adjust them yourself.
3. (Optional) If there is no nginx rpm package in yum, you need to add it manually.
rpm -ivh //nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
4. After adding Nginx packages, you can officially install Nginx.
yum install -y nginx
After the installation of nginx is completed, put it aside for the time being, and then install php.
5. Before installing PHP, you need to update the rpm package of PHP. Generally, the default rpm package version of PHP in the operating system is relatively old. Brother Z here is 5.4.16, and the latest version WordPress 5.2.2 selected by Brother Z requires a PHP version of 5.6.20 or above. (If the PHP version is incorrect, you will be prompted on the web page when you open the installed wordpress.)
rpm -Uvh //dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh //mirror.webtatic.com/yum/el7/webtatic-release.rpm
6. Then start installing PHP (don't miss 70w)
yum install php70w-fpm php70w-mysql -y
OK, now install the database.
7. In the latest rpm package list, the original MySQL has been replaced by mariadb. So, don't doubt, just install mariadb directly.
yum install mariadb-server -y
8. Start mariadb
systemctl start mariadb
9. Connect to mariadb. The default password is blank. (The usage is exactly the same as that of MySQL)
mysql -uroot -p
10. Create a database for wordpress. The name is up to you.
create database wordpress_db;
11. Set the user name and password for the newly created database. Brother Z sets wp_account and wordpress_password here. You can also adjust them yourself.
grant all privileges on wordpress_db.* to wp_account@localhost identified by wordpress_password;
flush privileges;
Here comes Wordpress, the main character.
12. In order to install the latest version of wordpress, go to the official website to download the latest version.
wget //cn.wordpress.org/latest-zh_CN.tar.gz
13. Brother Z is usually used to managing the file directory according to a unified standard, afraid that it will take time to find something later. So I created a www folder in the root directory to store the extracted wordpress directory.
mkdir /www
tar xf latest-zh_CN.tar.gz
mv wordpress/ /www/wordpress
The storage directory of wordpress is also useful. So if you haven't created a unified directory like Brother Z, you can record the current wordpress address first. However, Brother Z uniformly uses/www/wordpress later. Please pay attention to this.
14. Then you need to set the database address created before in the configuration file of wordpress. The default configuration file is only wp-config-sample.php. We need to copy a wp-config.php from it. This is the real configuration file.
cd /www/wordpress
cp wp-config-sample.php wp-config.php
vi wp-config.php
After opening wp-config.php, find the following location in the text content. Fill in the previous database information.
/**The name of the WordPress database*/
define(DB_NAME, wordpress_db);
/**MySQL database user name*/
define(DB_USER, wp_account);
/**MySQL database password*/
define(DB_PASSWORD, wordpress_password);
15. Open the nginx configuration file before you finish.
vi /etc/nginx/nginx.conf
Configure the information related to the WordPress website. It is good to copy the following configuration completely. Just pay attention to two changes.
[Your IP] Check it with ifconfig and replace it.
If you haven't created a new directory to store the wordpress root directory, the [/www/wordpress] configured after the root is the path you were asked to copy in advance.
server {
listen 80;
Server_name your ip;
index index.html index.php;
#Site Root
root /www/wordpress;
location / {
root /www/wordpress;
}
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
16. Finally, run php and nginx, and the environment is completed.
service php-fpm start
nginx
17. Then open //your IP address to see a welcome interface.
Open Phoenix News to view more HD pictures
18. A website will be automatically generated after filling in the information on the page.
The next step is to toss me around for a long time.
WordPress has a rich library of plug-ins and themes, so you are bound to install some new plug-ins and themes. But when you click Install, a form will appear asking you to fill in the ftp server information.
In fact, you can ignore it and search on the Internet. This is a new mode that was started after a certain version. Earlier versions of WordPress were downloaded and installed directly.
19. Therefore, we can adjust the mode to the direct installation mode. Go to the directory of wordpress and open wp-config.php again.
vi /www/wordpress/wp-config.php;
Add the following three lines at the end of the file content.
define("FS_METHOD","direct");
define("FS_CHMOD_DIR", 0777);
define("FS_CHMOD_FILE", 0777);
It's not over yet. In this case, if you click Install again, you will be prompted "Installation failed: unable to create directory"
20. At this time, you need to find the running user and user group of PHP. By default, it is in/etc/php fpm. d/www.conf.
vi /etc/php-fpm.d/www.conf
Find the user and group, and see what the corresponding values are.
Then do two more things.
21. First change the user of nginx to the same apache as here, which should be in the first line of nginx. conf by default.
vi /etc/nginx/nginx.conf
Restart nginx after modification.
nginx -s reload
22. Since themes and plug-ins are installed in the wordpress/wp content/directory, you should assign operation permissions to this directory. Otherwise, the default permission is root, which causes wordpress to be unable to create directories and files by itself.
chown -R apache:apache /www/wordpress/wp-content
So far, we have achieved great success. You can experience a large number of WordPress plug-ins and themes. Try them.
summary
I've always heard that it's easy to build a website with WordPress. But in practice, there will always be some small troubles.
You may also have a deep understanding of similar situations.
So, collect these 22 steps, and you may need to use it to build a website in the near future. At least it can save you some time.
By the way, you can collect my blog //zacharyfan.com A wave.