Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the methods of building wordpress personal website based on centos7

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

What this article shares with you is about the methods of building wordpress personal website based on centos7. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

I. Environmental preparation

Let's first introduce the packages needed in the environment and the experiment.

Environment:

I'm using centos7.4 's system.

It is recommended to turn off selinux and firewall policies that affect port 80.

Package:

Nginx (use the package in the CD that comes with the system by default, of course, you can compile and install it yourself, but it is not recommended to set up a personal blog because it is not necessary)

Mariadb-server (the database uses maridb-server which is also in the local image of the system)

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

Php-mysql (used to connect php to 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 setting self-boot 2. Configuration of each service

Nginx

There are also two ways to write the configuration file of nginx, either directly in the main configuration or under the conf.d folder. The second is used here, but there is no difference.

# vim / etc/nginx/nginx.conf add http {fastcgi_cache_path / var/cache/nginx/fcgi_cache levels=1:2:1 keys_zone=fcgicache:20m inactive=120s to the http configuration section # Special note: some parameters used to set the cache must be reset and modified in the server configuration section when you want to do more virtual hosts. This is mainly to define some configuration of the cache, which can be directly used # vim / etc/nginx/conf.d/blog.conf # must be conf suffix server {listen 80; # listener address server_name blog.luckynm.cn # Domain name root / data/wordpress; # Root path of # web # default index location / {try_files $uri $uri/ / index.php?q=$uri&$args;} location ~ *\ .php$ {fastcgi_pass 127.0.0.1 web 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) ${# is used to view the status information of the website. You can not add fastcgi_pass 127.0.0.1 fastcgi_pass 9000; fastcgi_param SCRIPT_FILENAME $fastcgi_script_name; include fastcgi_params } location / files {# is used to access the folder on the web page, which is equivalent to making a folder mapping. You can add root / data/wordpress; autoindex on; autoindex_exact_size off; autoindex_localtime on;}} nginx according to your personal situation. This is basically the configuration. If you have any questions, please contact me.

MySQL

Enter mysql on the command line to enter the database

If you can do some more security configuration for the database, there will be no demonstration here.

# mysqlMariaDB [(none)] > create user 'ningmeng'@'localhost' identified by' XXXXXXX'; create an account MariaDB [(none)] > create database wordpress; create database MariaDB [(none)] > grant all privileges on wordpress.* to 'ningmeng'@'%'; authorize ningmeng users

It is recommended to log in and test it after it has been created.

Mysql-uningmeng-pXXXXXX

Php-Fpm

It has a lot of parameters to set, but also a lot of holes, here we will tell you what we need to pay attention to.

# vim / etc/php-fpm.d/www.confuser = nginx # set the group to which you belong. If not, there are various permission problems when installing the wordpress upgrade theme group = nginx pm = ondemand # it is recommended to use this mode. For more information on it, please see http://blog.luckynm.cn/?p=65pm.max_children = 50 #. These can be configured or defaulted. Depending on the situation, pm.start_servers = 5pm.min_spare_servers = 5pm.max_spare_servers = 35pm.status_path = / statuspm.status_path = / status # the last three are used to set up to view server status information on the web page, and use ping.path = / pingping.response = pong with the configuration of nginx server segment.

Wordpress

Do not start after completing the previous steps, as there may be a sequence problem when they start.

Upload the downloaded wordpress package locally, and you can create a new folder to store it or directly put it in the / root directory.

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

# mkdir-pv / data create the data directory, which should be consistent with the root defined by root in nginx. Decompress the tar xvf wordpress-4.9.4-zh_CN.tar.gz-C / data/ to the / data directory and modify the group to which the chown-R nginx:nginx / data/wordpress belongs. It should not be impossible to change the theme upgrade plug-in. A series of questions such as # cd / data/wordpress# mv wp-config-sample.php wp-config.php setup profile # vim wp-config.phpdefine ('DB_NAME',' wordpress') WordPress database name define ('DB_USER',' ningmeng'); MySQL database user name define ('DB_PASSWORD',' 970628'); MySQL database password define ('DB_HOST',' localhost'); MySQL host

Start

Systemctl start mariadb php-fpmsystemctl start nginx Note: php-fpm must be started before nginx, otherwise it will prompt that the cache folder summary cannot be found.

These are all the contents of our blog. In the process of building, we must pay attention to some configuration details. Maybe one parameter is not matched, and the whole architecture cannot rise. This article only represents my own opinion. Different systems have different configurations. I summarize the problems that may be encountered by my friends, and share them with you here:

Solution: it's all about permissions. Modify the group you belong to in php-fpm / etc/php-fpm.d/www.conf. By default, apacheuser = nginx group = nginx problem description: server memory is small, mysql old automatic shutdown solution: pfp-fpm is fine under optimization, and the optimization method is mentioned in this article. Or reference: http://blog.luckynm.cn/?p=65 if you want to achieve so that nginx display folder directory can refer to: http://blog.luckynm.cn/?p=120 above is based on centos7 to build wordpress personal website methods, editor believes that there are some knowledge points may be seen or used in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report