In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail how to configure wordpress with nginx. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
I have built Wordpress myself before, but at that time I used a third-party virtual host, and there may be dozens of websites on one machine. At that time, virtual machines were not physically isolated, and the occupation of resources by one website might lead to the downtime of all websites.
Recently, we have tried to build an independent wordpress on Aliyun ecs to record the construction process.
Originally I wanted to try to use apache as the container for wordpress and nginx as the reverse proxy to proxy directly to apache. However, after I used apache, I found a problem. I directly used nginx as a reverse proxy. After switching to apache, url pseudo-static seems to be inaccessible. It seems that I need to configure nginx location for each url. I feel too troublesome, so I give up.
Of course, there may be other solutions, but I didn't try, and then I checked that nginx can use third-party plug-ins to support php. Directly using nginx as a container also has advantages, it is relatively easy to deploy, and multiple websites can also be deployed directly through a single nginx container.
1. Domain name purchase
I won't say much about this. Go to the domain name platform to apply for a domain name.
2.mysql installation
I've talked about how to install mysql before, and you can see here for details. After the installation is complete, we need to set up a separate account for wordpress. Why should we set up a separate account? Mainly for security reasons, if wordpress is attacked and you use a root account, then all the tables in the database will be exposed.
/ / create wordpress users and set passwords. Passwords are recommended to be generated randomly with no less than 8 characters. The combination of uppercase and lowercase, numbers and special characters CREATE USER 'wordpress'@'%' IDENTIFIED BY' password';// gives wordpress all the operation permissions of this account, including GRANT all ON wordpress.* TO 'wordpress'@'%' such as select delete update insert create alter.
For more information on permissions, please see here.
3.nginx installation
Nginx is installed in yum mode, which is very simple.
Installation:
Yum-y install nginx
Start:
Systemctl start nginx.service
The installation of nginx is completed in two steps.
4. Install php
4.1 php installation
Yum-y install php
The installation of php is very simple. After the installation is complete, execute the following command to view and display the version, which means the installation is correct:
Php-v
4.2 php-fpm installation
In addition to php, we need to use two things, fast-cgi and php-fpm. So what are these two things? If you want to know more, you can see here, simply put, fpm is a manager of fastcgi. Before that, I didn't know that I needed to install fpm to parse the php file correctly, which took me a long time.
Yum install php-fpm;// to see if php-fpm-v is installed successfully; start php-fpm systemctl start php-fpm
Fpm occupies port 9000 by default.
5. Install wordpress
Wget https://wordpress.org/latest.tar.gz;// decompresses tar-xzf latest.tar.gz-C / var/www/html
After the decompression is completed, find the / wordpress/wp-config-sample.php file, and modify the database name, user name and password. The fields are as follows:
/ / * * MySQL settings-You can get this info from your web host * * / / * The name of the database for WordPress * / define ('DB_NAME',' your database name'); / * * MySQL database username * / define ('DB_USER',' your user name'); / * * MySQL database password * / define ('DB_PASSWORD',' your password'); / * * MySQL hostname * / define ('DB_HOST',' your host')
When the modification is complete, change the file name of wp-config-sample.php to: wp-config.php.
6. Configure nginx
Here is my configuration, which you can refer to:
# * Official English Documentation: http://nginx.org/en/docs/# * Official Russian Documentation: http://nginx.org/ru/docs/upstream php {# server unix:/tmp/php-cgi.socket; # points to the default port 9000 of fpm, server 127.0.0.1 Official English Documentation 9000;} server {listen 80; listen [:]: 80; server_name www.domain.com; root / web/www.domain.com/; index index.php Location ~\. Php$ {# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini include fastcgi.conf; fastcgi_intercept_errors on; fastcgi_pass php;} # Load configuration files for the default server block. Include / etc/nginx/default.d/*.conf;}
7. Security settin
About 20% of the websites in the world use wordpress system, which also causes wordpress to become the target of hackers. Security problems can not be ignored, whether for individuals or enterprises. Is there an easy way for ordinary users to quickly improve our security? I looked at several security plug-ins, and there is one that can help us improve our security strategy. The name of the plug-in is All In One WP Security & Firewall. This plug-in is relatively easy to use compared to the average user.
This is the end of this article on "how to configure wordpress with nginx". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.