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. !
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.
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 设置开机自启
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前启动,要不然会提示找不到缓存文件夹
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!