- NGINX Cookbook
- Tim Butler
- 290字
- 2021-07-03 00:04:23
How to do it...
To convert a WordPress site into a multisite, you need to add the configuration variable into your config file wp-config.php:
define( 'WP_ALLOW_MULTISITE', true );
Under the Tools menu, you'll now see an extra menu called Network Setup. This will present you with two main options, Sub-domains and Sub-directories. These are the two different ways the multisite installation will work. The Sub-domains option has the sites separated by domain names, for example, site1.nginxcookbook.com and site2.nginxcookbook.com. The Sub-directories option means that the sites are separated by directories, for example, www.nginxcookbook.com/site1 and www.nginxcookbook.com/site2.

There's no functional difference between the two, it's simply an aesthetic choice. However, once you've made your choice, you cannot return to the previous state.
Once you've made the choice, it will then provide the additional code to add to your wp-config.php file.
Here's the code for my example, which is subdirectory based:
define('MULTISITE', true); define('SUBDOMAIN_INSTALL', false); define('DOMAIN_CURRENT_SITE', 'wordpress.nginxcookbook.com'); define('PATH_CURRENT_SITE', '/'); define('SITE_ID_CURRENT_SITE', 1); define('BLOG_ID_CURRENT_SITE', 1);
Because NGINX doesn't support .htaccess files, the second part of the WordPress instructions will not work. Instead, we need to modify the NGINX configuration to provide the rewrite rules ourselves.
In the existing /etc/nginx/conf.d/wordpress.conf file, you'll need to add the following just after the location / directive:
if (!-e $request_filename) { rewrite /wp-admin$ $scheme://$host$uri/ permanent; rewrite ^(/[^/]+)?(/wp-.*) $2 last; rewrite ^(/[^/]+)?(/.*\.php) $2 last; }
Although the if statements are normally avoided if possible, in this instance, it will ensure the subdirectory multisite configuration works as expected. If you're expecting a few thousand concurrent users on your site, then it may be worthwhile investigating the static mapping of each site. There are plugins to assist with the map generations for this, but they are still more complex compared to the if statement.
- DB2 V9權威指南
- 嵌入式軟件系統測試:基于形式化方法的自動化測試解決方案
- 從程序員到架構師:大數據量、緩存、高并發、微服務、多團隊協同等核心場景實戰
- 從0到1:Python數據分析
- Learning OpenStack Networking(Neutron)(Second Edition)
- 運用后端技術處理業務邏輯(藍橋杯軟件大賽培訓教材-Java方向)
- 用案例學Java Web整合開發
- 運維前線:一線運維專家的運維方法、技巧與實踐
- Java 從入門到項目實踐(超值版)
- ASP.NET求職寶典
- Mastering VMware Horizon 7(Second Edition)
- Greenplum構建實時數據倉庫實踐
- Qt 5.12實戰
- Spring Boot 3:入門與應用實戰
- Building E-Commerce Solutions with WooCommerce(Second Edition)