Dotlayer
  • News
  • Startups
  • Tutorials
  • SEO
  • Marketing
  • Interviews
No Result
View All Result
Dotlayer
  • News
  • Startups
  • Tutorials
  • SEO
  • Marketing
  • Interviews
No Result
View All Result
Dotlayer
No Result
View All Result

How to Host Multiple Websites with a Single WordPress Installation with Mysql on CentOS 7

February 12, 2017
in Tutorials
0 0
Share on FacebookShare on Twitter

In this post, we describe how to install and configure multiple WordPress sites with the latest WordPress version on CentOS 7 in a single WordPress instance. A little background of WordPress, WordPress started in 2003 by Matt Mullenweg with a single bit of code to enhance the typography of blogging. 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 CentOS 7.0 in the form of a simple-to-follow guide. We will be using CentOS 7.0 server, so you should set up a basic CentOS 7.0 server installation before you continue with this tutorial. The system should have a static IP address. I use 198.162.1.1 as my IP address in this tutorial and multisite.wpbullet.com as the hostname. You must have a LAMP server installed with CentOS 7.0 as mentioned in the tutorial to continue further.

1. Database Setup

We will start by creating the database for the WordPress 4.0 installation as follows:

mysql -u root -p

Here we are adding database=wordpressdb user=wordpressuser and password=wordpresspassword:

CREATE DATABASE wordpressdb;
CREATE USER wordpressuser@localhost IDENTIFIED BY 'wordpresspassword';
GRANT ALL PRIVILEGES ON wordpressdb.* TO wordpressuser@localhost;
FLUSH PRIVILEGES;
exit

2. Installation of WordPress 4.0

We will first make a directory temp in which I will the download the latest version of the WordPress as listed below. Also, we 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:

mkdir temp
cd temp
yum install wget unzip net-tools
wget http://wordpress.org/latest.zip
unzip -q latest.zip -d /var/www/html/
chown -R apache:apache /var/www/html/wordpress
chmod -R 755 /var/www/html/wordpress
mkdir -p /var/www/html/wordpress/wp-content/uploads
chown -R :apache /var/www/html/wordpress/wp-content/uploads
cd /var/www/html/wordpress/
cp wp-config-sample.php wp-config.php
nano wp-config.php

At this point we set up the config file for the wordpress folder

[...]

// ** 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');

[...] 

Further moving ahead if you wish to work with images, install plugins and site update with SSH credentials then we will install:

3. Multiple site configuration

Now we will proceed with the multiple site configuration, for this we need to add these lines to our wp-config.php file just above the /* That’s 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. */

[...]

4. Apache Mod Rewrite Configuration

We will modify the apache virtual host file for WordPress to get it allowed for .htaccess overrides. For this we will edit the virtual host file and add the entries as:

...]
 # Further relax access to the default document root:

    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
     AllowOverride All


[...]

Change the value from AllowOverride None to AllowOverride All, next restart the service:

service httpd restart

.htaccess File Update

Now we will create .htaccess file in document root, it will allow Apache to rewrites:

touch /var/www/html/wordpress/.htaccess

We need the web server to be the group owner though, so we should adjust the ownership as follows:

chown apache /var/www/html/wordpress/.htaccess

If you want WordPress to automatically update this file with rewrite rules, you can ensure that it has the correct permissions to do so by using:

chmod 664 /var/www/html/wordpress/.htaccess

If you want to update this file manually for the sake of a small security gain, you can allow the web server only read privileges by typing:

chmod 644 /var/www/html/wordpress/.htaccess

In this case, we are using the permission 644.
Now proceed to the web installation of WordPress 4.0. Go to the URL http://multisite.wpbullet.com/wordpress/wp-admin/install.php:

Now give the values as I gave in my case

Site Title = WordPress-testsite
Admin Email = [email protected]
Username = admin
Admin password = wpbullettest
Confirm Admin Password = wpbullettest

The above values will differ in your case, you can give any values of your choice. After giving the values press InstallWordpress:

ShareTweetPin
Next Post

Using fail2ban to Secure WordPress by Automatically Blocking Repeated Login Attempts

Next Post

Using fail2ban to Secure Wordpress by Automatically Blocking Repeated Login Attempts

You might also like

Calendarific Unveils New Pricing Plans

Calendarific Unveils New Pricing Plans

July 27, 2023
CurrencyBeacon vs. Currency Freaks, Fixer.io, and OpenExchangeRates: Which API is Best?

CurrencyBeacon vs. Currency Freaks, Fixer.io, and OpenExchangeRates: Which API is Best?

June 17, 2023
Mint Linux vs Ubuntu: Which is Right For You?

Mint Linux vs Ubuntu: Which is Right For You?

March 12, 2022
Net Neutrality: What is it and Why Should You Care?

Net Neutrality: What is it and Why Should You Care?

March 12, 2022
Solid State Drives – Why You Should Buy One Today

Solid State Drives – Why You Should Buy One Today

March 12, 2022

Machine Learning Algorithms Every Beginner Should Know

January 25, 2022
  • Terms of Service
  • Privacy Policy
  • Careers

© 2021 Dotlayer.com

No Result
View All Result
  • About Us
  • Advertise
  • Blog
  • Careers
  • Contact
  • Contact Us
  • Get Featured
  • Home Layout 1
  • Home Layout 2
  • Home Layout 3
  • Privacy Policy
  • Security
  • Services
  • Subscribe To Dotlayer
  • Terms of Service
  • Write For Us

© 2021 Dotlayer.com

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In