WordPress Multisite Installation Guide
What is WordPress Multisite?
WordPress Multisite is a powerful feature that allows you to run and manage multiple WordPress websites from a single WordPress installation. With Multisite, you can create new sites instantly and manage them using the same username and password.
Advantages of Using WordPress Multisite
- Manage multiple sites from a single dashboard as the network administrator
- Each site can have its own admin users who can only manage their respective websites
- Install plugins/themes and activate them for multiple sites with one download
- Easier update management - you only need to update WordPress, plugins, or themes on one “master” installation
Disadvantages of Using WordPress Multisite
- All sites share the same resources - if the network goes down, all sites go down
- Traffic and server resource management can be challenging for beginners
- Security vulnerabilities - if one site gets hacked, all sites on the network may be affected
- Some WordPress plugins may not work properly on a multisite network
- Not all hosting providers adequately support WordPress multisite
WordPress Multisite Installation Steps
1. Requirements
- A working WordPress installation
- Access to edit
wp-config.php
and.htaccess
files - PHP and MySQL that meet WordPress requirements
2. Enable Multisite Feature
- Edit the
wp-config.php
file and add the following code before the line that says “That’s all, stop editing! Happy publishing.”
/* Multisite */
define( 'WP_ALLOW_MULTISITE', true );
- You can enable WordPress Multisite in a single command using this bash script:
sed -i "/\/* That's all, stop editing! Happy publishing. \*\//i \
\/* Multisite *\/\ndefine( 'WP_ALLOW_MULTISITE', true );\n" /path/to/wordpress/wp-config.php
- Just replace
/path/to/wordpress/
with your actual WordPress installation path.
3. Complete Multisite Network Setup
- Log in to your WordPress admin panel
- Go to Tools > Network Setup
- Choose your network structure:
- Subdomains: site1.example.com
- Subdirectories: example.com/site1/
- Enter a title for your network
- Verify your admin email address
- Click the “Install” button
4. Update Configuration Files
After completing the Network Setup, WordPress will provide you with code snippets to add to your wp-config.php
and .htaccess
files.
For wp-config.php
Add the provided code to your wp-config.php
file after the line you added in step 2.
For Subdirectory Installation:
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false); // false for subdirectories
define('DOMAIN_CURRENT_SITE', 'example.com'); // Change to your domain
define('PATH_CURRENT_SITE', '/'); // Change if WordPress is in a subdirectory
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
define('COOKIE_DOMAIN', false); // Recommended for local development
For Subdomain Installation:
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', true); // true for subdomains
define('DOMAIN_CURRENT_SITE', 'example.com'); // Change to your domain
define('PATH_CURRENT_SITE', '/'); // Change if WordPress is in a subdirectory
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
define('COOKIE_DOMAIN', false); // Recommended for local development
- You can add all multisite settings to your
wp-config.php
file in a single command using this bash script:
For Subdirectory Installation:
sed -i "/\/\* That's all, stop editing! Happy publishing. \*\//i \
\/\* Multisite \*\/\ndefine('WP_ALLOW_MULTISITE', true);\n\n\/\* Multisite Network Configuration \*\/\ndefine('MULTISITE', true);\ndefine('SUBDOMAIN_INSTALL', false);\ndefine('DOMAIN_CURRENT_SITE', 'example.com');\ndefine('PATH_CURRENT_SITE', '\/');\ndefine('SITE_ID_CURRENT_SITE', 1);\ndefine('BLOG_ID_CURRENT_SITE', 1);\ndefine('COOKIE_DOMAIN', false);\n" /path/to/wordpress/wp-config.php
For Subdomain Installation:
sed -i "/\/\* That's all, stop editing! Happy publishing. \*\//i \
\/\* Multisite \*\/\ndefine('WP_ALLOW_MULTISITE', true);\n\n\/\* Multisite Network Configuration \*\/\ndefine('MULTISITE', true);\ndefine('SUBDOMAIN_INSTALL', true);\ndefine('DOMAIN_CURRENT_SITE', 'example.com');\ndefine('PATH_CURRENT_SITE', '\/');\ndefine('SITE_ID_CURRENT_SITE', 1);\ndefine('BLOG_ID_CURRENT_SITE', 1);\ndefine('COOKIE_DOMAIN', false);\n" /path/to/wordpress/wp-config.php
- Make sure to replace
/path/to/wordpress/
with your actual WordPress installation path and adjust the domain and path settings according to your environment.
For .htaccess
- Replace the existing WordPress rules in your
.htaccess
file with the code provided by WordPress.
For Subdirectory Installation:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
</IfModule>
# END WordPress
For Subdomain Installation:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
</IfModule>
# END WordPress
- You can update your
.htaccess
file in a single command using this bash script:
For Subdirectory Installation:
sudo bash -c 'cat > /path/to/wordpress/.htaccess << "EOL"
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
</IfModule>
# END WordPress
EOL'
For Subdomain Installation:
sudo bash -c 'cat > /path/to/wordpress/.htaccess << "EOL"
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
</IfModule>
# END WordPress
EOL'
-
Not: Bu komut sudo şifrenizi soracaktır. Ayrıca,
.htaccess
dosyasını ana WordPress dizinine yazıyoruz, çünkü Multisite için ana dizindeki.htaccess
dosyasını düzenlemeniz gerekir, eklenti dizinindeki değil. -
Just replace
/path/to/wordpress/
with your actual WordPress installation path.
WordPress Alt Dizinde Kuruluysa:
Eğer WordPress bir alt dizinde kuruluysa (örneğin, /blog/
veya /wordpress/
), .htaccess
dosyasındaki RewriteBase
değerini buna göre ayarlamanız gerekir:
RewriteBase /wordpress/
5. Log Back In
After updating the configuration files, log out and log back in to your WordPress admin panel.
6. Network Administration
- After logging back in, you’ll see a new “My Sites” menu in the admin toolbar
- Go to My Sites > Network Admin to access the network dashboard
- From here, you can manage network settings, add new sites, and configure themes and plugins
7. Adding New Sites
- Go to My Sites > Network Admin > Sites
- Click the “Add New” button
- Enter the site address, title, and admin email
- Click “Add Site”
8. Managing Themes and Plugins
- Go to My Sites > Network Admin > Themes or Plugins
- Install themes or plugins as you normally would
- Use the “Network Enable” option to make themes or plugins available to all sites
Setting Up Wildcard Subdomains (For Subdomain Installation)
If you chose the subdomain option, you’ll need to set up wildcard subdomains on your server:
For Apache
- Make sure the Apache module
mod_rewrite
is enabled:
sudo a2enmod rewrite
sudo systemctl restart apache2
- Configure your virtual host to allow wildcard subdomains:
<VirtualHost *:80>
ServerName example.com
ServerAlias *.example.com
DocumentRoot /var/www/html/wordpress
<Directory /var/www/html/wordpress>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
For Local Development
- For local development, you’ll need to modify your hosts file:
# On Linux/Mac
sudo nano /etc/hosts
# Add these lines
127.0.0.1 example.test
127.0.0.1 site1.example.test
127.0.0.1 site2.example.test
- Or use a tool like dnsmasq to handle wildcard subdomains automatically:
# Install dnsmasq
sudo apt-get install dnsmasq
# Configure dnsmasq
sudo nano /etc/dnsmasq.conf
# Add this line
address=/.example.test/127.0.0.1
# Restart dnsmasq
sudo systemctl restart dnsmasq
Using Custom Domains for Each Site
WordPress multisite also allows you to set different domains for each website in your network using domain mapping:
- Install a domain mapping plugin like “WordPress MU Domain Mapping”
- Add the necessary DNS records for each domain to point to your server
- Map domains to specific sites in your network through the plugin settings
Troubleshooting
Common Issues and Solutions
404 Errors on Subsite Pages
- Ensure your
.htaccess
file is properly configured - Check that the
RewriteBase
value matches your WordPress installation path - Verify that
mod_rewrite
is enabled on your server
sudo a2enmod rewrite
sudo systemctl restart apache2
Redirect Loop or Improper Redirects
- Check the
wp-admin
rewrite rule in your.htaccess
file - For subdirectory installations, make sure you’re using:
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
- For subdomain installations, make sure you’re using:
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
Network Admin Not Accessible
- Verify that the multisite code in
wp-config.php
is correct - Check that
SUBDOMAIN_INSTALL
is set to the correct value (true for subdomains, false for subdirectories) - Make sure
DOMAIN_CURRENT_SITE
andPATH_CURRENT_SITE
are set correctly
Permission Issues
- Check file and directory permissions
- WordPress files should typically be 644 and directories 755
find /path/to/wordpress -type f -exec chmod 644 {} \;
find /path/to/wordpress -type d -exec chmod 755 {} \;
chmod 600 /path/to/wordpress/wp-config.php
Local Development Considerations
When developing a WordPress Multisite locally:
- Use a local development environment like XAMPP, MAMP, Local by Flywheel, or Docker
- For subdirectory installations, no special configuration is needed
- For subdomain installations, you’ll need to configure your hosts file or use a tool that supports wildcard subdomains
- Consider using a .local or .test TLD for local development
- Set
COOKIE_DOMAIN
to false in yourwp-config.php
file to avoid cookie issues
NOTE: You can use the wp.multisite.sh script to automate the WordPress Multisite setup process. This script will automatically convert your WordPress installation to a multisite configuration.