Table of Contents
1. Environment preparation
2. Each service configuration
Summary
Home CMS Tutorial WordPress Detailed explanation of how to build a WordPress personal website based on centos7

Detailed explanation of how to build a WordPress personal website based on centos7

Jun 17, 2020 pm 01:34 PM
centos7 wordpress

The following column WordPress Tips will introduce you to the detailed method of building a WordPress personal website based on centos7. I hope it will be helpful to friends in need. !

Detailed explanation of how to build a WordPress personal website based on centos7

Foreword:

With the popularization of computer technology, more and more people are engaged in IT. But as you go deeper, you will find that you are on a pirate ship. It is really as deep as IT and the sea. From now on, girls are just passers-by. When you get closer and closer to the goal you have imagined, you will feel insignificant. , the knowledge in this industry is too profound and vast. Okay, without further ado, let’s start our topic: using wordpress to build a personal blog.

1. Environment preparation

Let’s first introduce the environment and the packages needed in the experiment

Environment:

I use The system is centos7.4

It is recommended to turn off selinux and the firewall policy affecting port 80

Package:

nginx (use the system Of course, you can also compile and install the packages in the default CD by yourself, but it is not recommended to build a personal blog because it is not necessary)

mariadb-server (The database uses maridb-server which is also in the local mirror of the system)

php-fpm (used to manage php programs, and nginx does not support php modules)

php-mysql (used to connect php to the database)

wordpress package, Official website address: https://wordpress.org/download/

wordpress theme: https://wordpress.org/themes/

# yum install nginx mariadb-server php-fpm php-mysql  -y
# systemctl enable nginx mariadb php-fpm   设置开机自启
Copy after login

2. Each service configuration

Nginx

There are two ways to write nginx configuration files, directly writing to the main configuration, and writing to the conf.d folder. The second one is used here, but there is actually no difference

# vim /etc/nginx/nginx.conf
在http配置段里添加
http {
    fastcgi_cache_path /var/cache/nginx/fcgi_cache levels=1:2:1 keys_zone=fcgicache:20m inactive=120s;          #特别注意:用来设置缓存的一些参数,当你要做多虚拟主机时一定要在重新设置以个并在server配置段里修改
}
这个主要是定义缓存的一些配置,可直接拿来用
# vim /etc/nginx/conf.d/blog.conf   #必须conf后缀
server {
        listen       80 ;     #监听地址
        server_name  blog.luckynm.cn ;   #域名
        root         /data/wordpress ;   #web的根路径
        index index.php index.html index.hml;   #默认索引
        location / {
                try_files $uri $uri/ /index.php?q=$uri&$args;
        }
        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;
                fastcgi_cache fcgicache;
                fastcgi_cache_key $request_uri;
                fastcgi_cache_valid 200 302 10m;
                fastcgi_cache_valid 301 1h;
                fastcgi_cache_valid any 1m;
        }
        location ~* ^/(status|ping)$ {        #用来查看网站的状态信息,可以不添加
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_param  SCRIPT_FILENAME  $fastcgi_script_name;
                include fastcgi_params;
        }
        location /files {            #用来在网页访问文件夹,相当于做了个文件夹映射,可根据个人情况添加
                root /data/wordpress;
                autoindex on;
                autoindex_exact_size off;
                autoindex_localtime on;
        }

}
nginx的配置基本就这些,如有疑问可以联系我
Copy after login

MySQL

Enter mysql on the command line to enter the database

You can do some security configuration for the database, but I won’t demonstrate it here

# mysql
MariaDB [(none)]> create user 'ningmeng'@'localhost' identified by 'XXXXXXX';  创建个给wordpress使用的连接数据库的账号
MariaDB [(none)]> create database wordpress;  创建数据库
MariaDB [(none)]> grant all privileges on wordpress.* to 'ningmeng'@'%';   给ningmeng用户授权
Copy after login

It is recommended to log in and test it after creating it

mysql -uningmeng -pXXXXXX
Copy after login

Php-Fpm

It has many parameters that can be set, and there are also many pitfalls. I will tell you here. Here are some things you need to pay attention to

# vim /etc/php-fpm.d/www.conf
user = nginx    #设置所属者所属组,不设置的话在装wordpress升级主题时有各种各样的权限问题
group = nginx 
pm = ondemand    #推荐使用这个模式,对他的详细介绍参考http://blog.luckynm.cn/?p=65
pm.max_children = 50    #这些都可以配置也可以默认,看情况
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.status_path = /status
pm.status_path = /status   #后面这三个是用来设置在web页面上查看服务器状态信息的,配合nginx种server段的配置使用
ping.path = /ping
ping.response = pong
Copy after login

Wordpress

Don’t start it after completing the previous steps, because there may be order problems when starting them

Transfer the downloaded wordpress package to the local area. You can create a new folder to store it or place it directly in the /root directory.

It is recommended to use the Chinese package wordpress. -4.9.4-zh_CN.tar.gz

# mkdir -pv /data   创建data目录,这个要和nginx中root定义的根要一致
# tar xvf wordpress-4.9.4-zh_CN.tar.gz -C /data/    解压到/data目录下
# chown -R nginx:nginx /data/wordpress    修改所属者所属组,不该没办法换主题升级插件,等一系列问题
# cd /data/wordpress
# mv wp-config-sample.php wp-config.php   设置配置文件
# vim wp-config.php
define('DB_NAME', 'wordpress');     WordPress数据库的名称
define('DB_USER', 'ningmeng');     MySQL数据库用户名
define('DB_PASSWORD', '970628');    MySQL数据库密码
define('DB_HOST', 'localhost');     MySQL主机
Copy after login

Start

systemctl start mariadb  php-fpm
systemctl start nginx  
注意:php-fpm一定要在nginx前启动,要不然会提示找不到缓存文件夹
Copy after login

Summary

The above is how we set up the blog For all content, you must pay attention to some configuration details during the construction process. Or maybe one parameter is not configured, and the entire architecture cannot be started. This article only represents my own opinions. Different systems have different configurations. I summarize Here are the common problems that friends may encounter, and share them with you here:

解决办法:都是权限的问题,在php-fpm的/etc/php-fpm.d/www.conf里修改所属者所属组,默认时apache

user = nginx  
group = nginx

问题描述:服务器内存小,mysql老自动停机

解决办法:   优化下pfp-fpm就好啦,本文中提到啦优化的方式,或参考:http://blog.luckynm.cn/?p=65

如果想要实现让nginx显示文件夹目录可参考:http://blog.luckynm.cn/?p=120
Copy after login

The above is the detailed content of Detailed explanation of how to build a WordPress personal website based on centos7. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP vs. Flutter: The best choice for mobile development PHP vs. Flutter: The best choice for mobile development May 06, 2024 pm 10:45 PM

PHP and Flutter are popular technologies for mobile development. Flutter excels in cross-platform capabilities, performance and user interface, and is suitable for applications that require high performance, cross-platform and customized UI. PHP is suitable for server-side applications with lower performance and not cross-platform.

How to change page width in wordpress How to change page width in wordpress Apr 16, 2024 am 01:03 AM

You can easily modify your WordPress page width by editing your style.css file: Edit your style.css file and add .site-content { max-width: [your preferred width]; }. Edit [your preferred width] to set the page width. Save changes and clear cache (optional).

How to create a product page in wordpress How to create a product page in wordpress Apr 16, 2024 am 12:39 AM

Create a product page in WordPress: 1. Create the product (name, description, pictures); 2. Customize the page template (add title, description, pictures, buttons); 3. Enter product information (stock, size, weight); 4 . Create variations (different colors, sizes); 5. Set visibility (public or hidden); 6. Enable/disable comments; 7. Preview and publish the page.

In which folder are wordpress articles located? In which folder are wordpress articles located? Apr 16, 2024 am 10:29 AM

WordPress posts are stored in the /wp-content/uploads folder. This folder uses subfolders to categorize different types of uploads, including articles organized by year, month, and article ID. Article files are stored in plain text format (.txt), and the filename usually includes its ID and title.

Where is the wordpress template file? Where is the wordpress template file? Apr 16, 2024 am 11:00 AM

WordPress template files are located in the /wp-content/themes/[theme name]/ directory. They are used to determine the appearance and functionality of the website, including header (header.php), footer (footer.php), main template (index.php), single article (single.php), page (page.php), Archive (archive.php), category (category.php), tag (tag.php), search (search.php) and 404 error page (404.php). By editing and modifying these files, you can customize the appearance of your WordPress website

How to search for authors in WordPress How to search for authors in WordPress Apr 16, 2024 am 01:18 AM

Search for authors in WordPress: 1. Once logged in to your admin panel, navigate to Posts or Pages, enter the author name using the search bar, and select Author in Filters. 2. Other tips: Use wildcards to broaden your search, use operators to combine criteria, or enter author IDs to search for articles.

What language is used to develop WordPress? What language is used to develop WordPress? Apr 16, 2024 am 12:03 AM

WordPress is developed using PHP language as its core programming language for handling database interactions, form processing, dynamic content generation, and user requests. PHP was chosen for reasons including cross-platform compatibility, ease of learning, active community, and rich library and frameworks. Apart from PHP, WordPress also uses languages ​​like HTML, CSS, JavaScript, SQL, etc. to enhance its functionality.

Which version of wordpress is stable? Which version of wordpress is stable? Apr 16, 2024 am 10:54 AM

The most stable WordPress version is the latest version because it contains the latest security patches, performance enhancements, and introduces new features and improvements. In order to update to the latest version, log into your WordPress dashboard, go to the Updates page and click Update Now.

See all articles