search
HomeCMS TutorialWordPressDetailed explanation of how to build a WordPress personal website based on centos7

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   设置开机自启

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的配置基本就这些,如有疑问可以联系我

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用户授权

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

mysql -uningmeng -pXXXXXX

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

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主机

Start

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

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

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
This article is reproduced at:csdn. If there is any infringement, please contact admin@php.cn delete
Can I learn WordPress in 3 days?Can I learn WordPress in 3 days?Apr 09, 2025 am 12:16 AM

Can learn WordPress within three days. 1. Master basic knowledge, such as themes, plug-ins, etc. 2. Understand the core functions, including installation and working principles. 3. Learn basic and advanced usage through examples. 4. Understand debugging techniques and performance optimization suggestions.

Is WordPress a CMS?Is WordPress a CMS?Apr 08, 2025 am 12:02 AM

WordPress is a Content Management System (CMS). It provides content management, user management, themes and plug-in capabilities to support the creation and management of website content. Its working principle includes database management, template systems and plug-in architecture, suitable for a variety of needs from blogs to corporate websites.

What is the WordPress good for?What is the WordPress good for?Apr 07, 2025 am 12:06 AM

WordPressisgoodforvirtuallyanywebprojectduetoitsversatilityasaCMS.Itexcelsin:1)user-friendliness,allowingeasywebsitesetup;2)flexibilityandcustomizationwithnumerousthemesandplugins;3)SEOoptimization;and4)strongcommunitysupport,thoughusersmustmanageper

Should I use Wix or WordPress?Should I use Wix or WordPress?Apr 06, 2025 am 12:11 AM

Wix is ​​suitable for users who have no programming experience, and WordPress is suitable for users who want more control and expansion capabilities. 1) Wix provides drag-and-drop editors and rich templates, making it easy to quickly build a website. 2) As an open source CMS, WordPress has a huge community and plug-in ecosystem, supporting in-depth customization and expansion.

How much does WordPress cost?How much does WordPress cost?Apr 05, 2025 am 12:13 AM

WordPress itself is free, but it costs extra to use: 1. WordPress.com offers a package ranging from free to paid, with prices ranging from a few dollars per month to dozens of dollars; 2. WordPress.org requires purchasing a domain name (10-20 US dollars per year) and hosting services (5-50 US dollars per month); 3. Most plug-ins and themes are free, and the paid price ranges from tens to hundreds of dollars; by choosing the right hosting service, using plug-ins and themes reasonably, and regularly maintaining and optimizing, the cost of WordPress can be effectively controlled and optimized.

Is WordPress still free?Is WordPress still free?Apr 04, 2025 am 12:06 AM

The core version of WordPress is free, but other fees may be incurred during use. 1. Domain names and hosting services require payment. 2. Advanced themes and plug-ins may be charged. 3. Professional services and advanced features may be charged.

Is WordPress easy for beginners?Is WordPress easy for beginners?Apr 03, 2025 am 12:02 AM

WordPress is easy for beginners to get started. 1. After logging into the background, the user interface is intuitive and the simple dashboard provides all the necessary function links. 2. Basic operations include creating and editing content. The WYSIWYG editor simplifies content creation. 3. Beginners can expand website functions through plug-ins and themes, and the learning curve exists but can be mastered through practice.

Why would anyone use WordPress?Why would anyone use WordPress?Apr 02, 2025 pm 02:57 PM

People choose to use WordPress because of its power and flexibility. 1) WordPress is an open source CMS with strong ease of use and scalability, suitable for various website needs. 2) It has rich themes and plugins, a huge ecosystem and strong community support. 3) The working principle of WordPress is based on themes, plug-ins and core functions, and uses PHP and MySQL to process data, and supports performance optimization.

See all articles

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)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use