How to host multiple sites in a single Wordpress installation on
Ubuntu 14.04This document describes how to install and configure
WordPress MU with the latest version in market of WordPress 4 on
Ubuntu 14.04. WordPress started in 2003 with a single bit of code
to enhance the typography of everyday writing and with fewer users
than you can count on your fingers and toes. Since then it has
grown to be the largest self-hosted blogging tool in the world,
used on millions of sites and seen by tens of millions of people
every day. This tutorial explains the process of installing
WordPress 4.0 on Ubuntu 14.04 in the form of a simple-to-follow
guide.1 Preliminary NoteThis tutorial is based on Ubuntu 14.04
server, so you should set up a basic Ubuntu 14.04 server
installation before you continue with this tutorial. The system
should have a static IP address. I use192.168.0.100as my IP address
in this tutorial andserver1.example.comas the hostname. You must
have a LAMP server installed in Ubuntu 14.04 as mentioned in
thetutorialto continue further.2 Database initializationI will
create the database for the WordPress 4.0 as follows:mysql -u root
-pHere we are addingdatabase=wordpressdb
user=wordpressuserandpassword=wordpresspassword:CREATE DATABASE
wordpressdb;CREATE USER wordpressuser@localhost IDENTIFIED BY
'wordpresspassword';GRANT ALL PRIVILEGES ON wordpressdb.* TO
wordpressuser@localhost;Further moving ahead:FLUSH
PRIVILEGES;exitRestart servicesservice apache2 restartservice mysql
restart3 Installation of WordPress 4.0We will first make a
directorytempin which I will the download the latest version of the
WordPress as follows:mkdir tempcd tempwget
http://wordpress.org/latest.zipWe need to install unzip as by
default it is now installed:apt-get install unzipFurther moving
ahead if you wish to work with images, install plugins and site
updation with SSH credentials then we will installphp5-gd
libssh2-phpapt-get updateapt-get install php5-gd libssh2-phpunzip
the WordPress zip file in the following created folder:unzip -q
latest.zip -d /var/www/html/Now give appropriate permissions in the
directorychown -R www-data.www-data /var/www/html/wordpresschmod -R
755 /var/www/html/wordpressFurther we need to manually create the
uploads directory beneath the wp-content directory at our document
root. This will be the parent directory of our content:mkdir -p
/var/www/html/wordpress/wp-content/uploadsWe need to allow the web
server itself to write to this directory. We can do this by
assigning group ownership of this directory to our web server. This
will allow the web server to create files and directories under
this directory, which will permit us to upload content to the
server. Proceed like this:chown -R :www-data
/var/www/html/wordpress/wp-content/uploadsNow we need to copy it to
the default configuration file location to get WordPress to
recognize the file. The sample configuration file is available
at/var/www/html/wordpress:cd /var/www/html/wordpress/cp
wp-config-sample.php wp-config.phpnano wp-config.php[...]
// ** MySQL settings - You can get this info from your web host
** ///** The name of the database for WordPress */define('DB_NAME',
'wordpressdb');
/** MySQL database username */define('DB_USER',
'wordpressuser');
/** MySQL database password */define('DB_PASSWORD',
'wordpresspassword');
[...] Change values as you gave at the time of database
initialization.3.1 Multiple site configurationNow we will proceed
with the multiple site configuration, for this we need to add these
lines to ourwp-config.phpfile just above the/* Thats all, stop
editing! Happy blogging. */ line.nano
/var/www/html/wordpress/wp-config.php/* Multisite
*/define('WP_ALLOW_MULTISITE', true);/* That's all, stop editing!
Happy blogging. */Now we will activate the apache Mod_Rewrite
module:a2enmod rewriteNow we will change the default virtual host
file for Apache as follows:nano
/etc/apache2/sites-enabled/000-default.conf[...]
Options Indexes FollowSymLinks MultiViews AllowOverride All
Order allow,deny allow from all
Restart Apache2 to make the services affective:service apache2
restartAfter that we will be installing the Wordpress 4 within
browser.4 Web installationOpen a browser of your choice and go to
the URLhttp://192.168.0.100/Wordpress:Select language and
pressContinue:
Now give the values as I gave in my caseSite Title =
Wordpress-testsiteAdmin Email = [email protected] =
adminAdmin password = howtoforgeConfirm Admin Password =
howtoforgeThe above values will differ in you case, you can give
any values of your choice. After giving the values pressInstall
WordPress:
Now we will proceed towards the login page by pressingLogIn:
Give the credentials as you selected at the time of web
WordPress installation. This will be your default welcome window of
WordPress.
You can check the WordPress version in browser as:
4.1 Multiple sites configurationNow gotoTools-->Network
setup
Give the entries as followsNetwork Title =Wordpress-testsite
multisiteNetwork admin email [email protected] pressInstallIt
will yield the following window:
Add the following to your wp-config.php file in
/var/www/html/wordpress/ above the line reading /* Thats all, stop
editing! Happy blogging. */:nano
/var/www/html/wordpress/wp-config.phpGive the entries as per the
your output after the multisite installation. In my case it
was:[...]/* Multisite */define('WP_ALLOW_MULTISITE',
true);define('MULTISITE', true);define('SUBDOMAIN_INSTALL',
false);define('DOMAIN_CURRENT_SITE',
'192.168.0.100');define('PATH_CURRENT_SITE',
'/wordpress/');define('SITE_ID_CURRENT_SITE',
1);define('BLOG_ID_CURRENT_SITE', 1);/* That's all, stop editing!
Happy blogging. */[...] Note: In my case I am using 192.168.0.100
which will be different in your caseAdd the following entries to
your.htaccessfile in/var/www/html/wordpress/, replacing other
WordPress rules:nano /var/www/html/wordpress/.htaccessRewriteEngine
OnRewriteBase /wordpress/RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-adminRewriteRule
^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]RewriteCond
%{REQUEST_FILENAME} -dRewriteRule ^ - [L]RewriteRule
^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2
[L]RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]RewriteRule .
index.php [L]Now relogin to the WordPress. After successfully
setting up the Multisite Network, you need to switch to the Network
Dashboard to configure network settings, add new sites, and do lots
of other things. Take your mouse over to My Sites menu in the admin
toolbar, a flydown popup will appear. Click onNetwork
Admin-->Dashboard.
It will direct you to the Dashboard of the WordPress
multisite.
Now you can create new site by clickingSites-->Add New
Just add the values as per your requirement.
Congratulations! You now have a fully functional WordPress 4.0
instance with multiple site network on your Ubuntu 14.04 :)