In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
The knowledge of this article "how to configure the multi-site function of WordPress in the Nginx environment" is not understood by most people, so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to configure the multi-site function of WordPress in the Nginx environment" article.
Wordpress's multi-site feature allows you to install a wordpress program to implement multiple sites (that is, a set of programs that can bind multiple domain names or subdomains).
Each site has its own themes, plug-ins, articles, and pages.
This greatly reduces the hassle of maintaining and updating multiple wordpress installers
Moreover, each site can be independent of each other and do not affect each other.
There are two ways of wordpress multisite: subdirectories and subdomain names. Here we mainly introduce subdomain names.
In other words, based on the primary domain name, we will create a subdomain name, such as http://shop.jb51.com.
At the same time, we can map this subdomain to a first-level domain name such as http://shop.com
For visitors, the access is a separate first-level domain name.
1. Prepare
Wordpress introduces its multi-site function page: site network management page
Next, we prepare several domain names, as follows:
Site 1: www.jb51.com (primary domain name), which is the domain name used to install wordpress
Site 2: blog.jb51.com, second-level domain name
Site 3: news.com, mapped second-level domain name news.jb51.com
Site 4: shop.com, mapped second-level domain name shop.jb51.com
Note: do not modify the domain name in the background after wordpress installation, even if you change the domain name from www to no www, or vice versa, it may cause redirected you too many times. Error
Then, log in to the domain name service provider's resolution page and set all the a records of the above domain names to the server ip installed by wordpress.
You can also test it on your local computer. You can directly modify the hosts file and add the following line:
127.0.0.1 www.jb51.com blog.jb51.com news.com shop.com
2. Nginx configuration
Create a new configuration file under the nginx configuration directory, as follows:
$sudo vi / etc/nginx/conf.d/jb51.conf
The content is:
Server {listen 80 access_log off;log_not_found off; serveraccounname www.jb51.com blog.jb51.com news.com shop.com;root / usr/share/nginx/wordpress;index index.php;location / {try_files $uri $uri/ / index.php?$args;} location ~ / favicon.ico {access_log off;log_not_found off;} location ~\. Php$ {try_files $uri/ index.php;include fastcgi_params;fastcgi_pass 127.0.1 Fastcgi_param script_filename $document_root$fastcgi_script_name;} access_log / var/log/nginx/$host-access.log;error_log / var/log/nginx/wpms-error.log;}
Here we use the $host variable to allow nginx to generate a separate access log for each domain name.
Such as: news.com-access.log and shop.com-access.log.
But the error log cannot use the $host variable, so all errors are recorded in one file.
Restart the nginx server:
$nginx-s reload
3. Install wordpress
Follow the normal installation steps for wordpress to install wordpress.
4. Enable the multi-site feature
Open the wp-config.php file with a text editor and add the following line before the comment: "/ * all right! please do not continue editing. Please save this file. Have a nice use! * /":
/ * multisite settings * / define ('wp_allow_multisite', true)
We will edit this file a few more times next.
Log in to the wordpress backend after saving, click: tools > Network Settings, select subdomain name, network title and network administrator mailbox for any input.
Then the terminal is installed.
After a moment, two code blocks appear in the interface, prompting to add the wp-config.php and .htaccesss files, respectively.
We use nginx here, so we don't need to worry about the .htaccess part.
Open the wp-config.php file and comment: "/ * all right! please do not continue editing. Please save this file. Have a nice use! * /", add the following lines:
Define ('multisite', true); define (' subdomain_install', true); define ('domain_current_site',' www.jb51.com'); define ('path_current_site',' /'); define ('site_id_current_site', 1); define (' blog_id_current_site', 1); log out of the wordpress admin panel, and log in again.
Log out of the wordpress backstage and log in again.
Open my site > Network Management > site in the upper left corner of the panel.
Click the add New button, open the add New site form, and add three subdomains: blog, news, and shop in turn.
After adding, select all sites, edit the news.jb51.com and shop.jb51.com subdomains, and the site title is News and Mall, respectively.
Change the site address (url) to: news.com and shop.com, respectively.
Once this is done, we can visit blog.jb51.com, which is already a separate site with independent resources.
But to be able to access news.com and shop.com, you need to move on.
5. Set up domain name mapping
Open my site > Network Management > plug-in in the upper left corner of the panel.
Install the wordpress mu domain mapping plug-in here, search directly or download the installation, and then enable it.
Then copy the sunrise.php file under the plug-in directory (directory wp-content/plugins/wordpress-mu-domain-mapping) to the wp-content directory.
Open the wp-config.php file and comment: "/ * all right! please do not continue editing. Please save this file. Have a nice use! * /", add the following line:
Define ('sunrise',' on')
Save, then return to the browser and open my site > Network Management > Settings in the upper left corner of the panel in the background.
Then select domain mapping, and modify the domain options as shown below:
And save it.
The function of the configuration here is to redirect all secondary domain names (such as news.jb51.com) to their respective external domain names (such as news.com), including the management page (/ wp-admin).
Next, we will map the first-level domain name to each site id.
By default, the site id is not displayed in the background, so we use the easiest way to get the background to display the site id directly.
This method is to use wordpress's must-use plugin.
Create a mu-plugins directory under the wp-content directory, and then create a file called wpms_blogid.php under the new directory
The content of this php file is:
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.