arrow_upward

Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Installing Wordpress Mulitsite
#1
Hello All,

So I have been working through all of the bugs of this install to get thing exactly correct, so fellow designers and developers can follow along and setup a Wordpress Multisite Network to easily create and manage sites for clients along with theme and plugin development. Before we begin, we will need some things in place before we can get to the meat and potatoes of the tutorial.

Prerequisites:
 - Ubuntu Server 18.04
 - Apache2 (Your LAMP stack including Apache and SQL)
 - PHP 7.4.11

Setting up Ubuntu Server:

If you are installing a fresh install of Ubuntu proceed through the setup and when prompted to select an install package, you can choose the Apache2 (LAMP Stack), make sure to hit the spacebar to select the install package prior to hitting the enter button.

1. Check to see if UFW has the Apache application profile: 
sudo ufw app list

You should see the available options include: Apache, Apache Full, Apache Secure
2. Allow incoming HTTP/HTTPS traffic to your server:
sudo ufw allow in "Apache Full"

Using your public IP address you can check to see if Apache was correctly configured, you can visit http://PUBLIC.IP.ADDRESS and you should see the default Apache2 Ubuntu Default Page. If you are unable to see this page make sure to start the server if it has not been started already sudo systemctl start apache2

3. Install MySQL Server
You will now need to install the MySQL server so you can being creating databases. This setup will install the initial server with a root user and you will be able to set the password for the root user along with securing the server with the secure installation. First run:
sudo apt install mysql-server

You will see a list of packages that will need to be installed, type Y to confirm and then the installation will continue. After the installation has completed, you will now need to run this built in script to remove any harmful defaults and lock down your SQL Server.

sudo mysql_secure_installation

The secure installer will then ask you a list of questions, all of which you can answer Y too. The next step will ask you to select a password validation policy level, where 0 is none at all and 3 is maximum security, you will need a super strong password. With my installation, I set the level to 1, that way you need a secure password, but it does not have to be wickedly strong. You will then setup and confirm the password for root@localhost.

4. Installing PHP
Using the following command you can install PHP and it's components for displaying dynamic content and connecting to the MySQL server.

sudo apt install php libapache2-mod-php php-mysql

Once the scripts install, restart the apache server: sudo systemctl restart apache2

Now that the server is restarted, you can upgrade from the stock PHP version in Ubuntu (PHP 7.0) to the most recent version, 7.4.11. Run the following scripts to add the PPA repository for PHP 7.4.
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php7.4

With PHP 7.4 installed, you will now need to run these commands to install the needed PHP modules followed by deactivating PHP 7.0 and activating PHP 7.4 then restarting Apache.
sudo apt install php7.4-{mysql,common,xml,xmlrcp,curl,gd,imagick,cli,dev,mbstring,opcache,soap,zip,intl}
sudo a2dismod php7.0
sudo a2enmod php7.4
sudo systemctl restart apache2

5. Upgrading phpMyAdmin & Adding a Symbolic Link
Now we have PHP updated, we need to update phpMyAdmin, the stock version included in the LAMP stack is out of date and some of the functions are depreciated. This will give you the most up to date version of phpMyAdmin which is compatible with PHP 7.0+ and MySQL 5.0+.

Navigate back to your system root and change to the directory /usr/share and remove the current phpmyadmin folder

sudo rm -rf ./phpmyadmin/

Followed by downloading phpMyAdmin, unpacking it and renaming the directory

sudo wget https://files.phpmyadmin.net/phpMyAdmin/5.0.3/phpMyAdmin-5.0.3-english.tar.gz
sudo tar -xvf phpMyAdmin-5.0.3-english.tar.gz
sudo mv ./phpMyAdmin-5.0.3-english/ ./phpmyadmin/
sudo rm -rf phpMyAdmin-5.0.3-english.tar.gz

Now that we have the update downloaded, you will need to change the config.sample.inc.php into config.inc.php and then add a blowfish secret key that will enable cookies for phpMyAdmin.

cd phpmyadmin
cp ./config.sample.inc.php ./config.inc.php
sudo nano config.inc.php

Key down to the line asking for the blowfish key and then generate it and insert from this site: https://phpsolved.com/phpmyadmin-blowfis...generator/

Once you have it entered press ctrl+X and save the changes.

6. Setting up Virtual Hosts
Now that your Apache server is mostly set up, you can now begin to create the public_html folder which will host the Wordpress install. This is where you would connect up your domain by modifying the DNS settings with your cPanel or Domain Registrar. You can set up and give the proper permissions to the public_html folder by running the commands below.

cd ../../../
sudo mkdir /var/www/public_html
sudo chown -R $USER:$USER /var/www/public_html
sudo chmod -R 755 /var/www/public_html

Now that the public_html directory is made, you will need to create a virtual host file that will allow Apache to serve the content when you and others access your site. Run these commands to create a new configuration file. Make sure to change YOURDOMAIN to your domain name. Ie. tbelldesign.conf

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/YOURDOMAIN.conf
sudo nano /etc/apache2/sites-available/YOURDOMAIN.conf

Change the following details to match your domain:
ServerName YOURDOMAIN
ServerAlias www.YOURDOMAIN
DocumentRoot /var/www/public_html

Now exit and write the changes then run the following commands to enable your new conf and disable the default conf.

sudo a2ensite YOURDOMAIN.conf
sudo a2dissite 000-default.conf
sudo systemctl restart apache2

Now that you have your new virtual host setup, you will need to create a symbolic link to your public_html so that when you visit http://YOURDOMAIN/phpmyadmin/ you can login to phpMyAdmin and have all of the great features this visual database manager has to offer.

sudo ln -ls /etc/phpmyadmin/ /var/www/phpmyadmin/

Now visit http://YOURDOMAIN/phpmyadmin/ to make sure that you can see the login page and log in with your root@localhost username (root) and the password you setup during the MySQL secure install. If you are unable to access phpmyadmin, make sure to chown and chmod the directory.

7. Install Wordpress
Now that you have Apache, PHP, MySQL and phpMyAdmin installed and configured you can now download Wordpress to your public_html folder and begin the installation process.

cd /var/www/public_html
sudo wget https://wordpress.org/latest.tar.gz
sudo tar -xvf latest.tar.gz
cd ./wordpress
sudo mv -R ./* ../
cd ../
rm -rf wordpress/

Then make sure to chmod everything so it is writable by the installer

sudo chmod -R 755 ./

Now the Wordpress is moved to public_html you can begin the installation by visiting http://YOURDOMAIN and following the directions.

Once you have successfully installed Wordpress, you can edit your wp-config.php to then begin the installation of Multisite Network.

sudo nano wp-config.php

Add the following code right above /*Finish adding code, happy editing*/

define('WP_ALLOW_MULTISITE' , true);

Close and write the changes

Next login to WP-Admin using the credentials you have set up, and begin to remove the stock plugins and the default themes, minus Twenty Twenty. Then head on over to Settings>Permalink and change the option to Post Name. Once those are removed, you can then go to Settings> Create a Wordpress Network of Site. Follow the recommendations of the the installation of the network. I recommend using the subdirectory method and disabling the subdomain method of adding sites. With it installed, you will now be able to create development sites, add network themes and plugins along with more network admin users.

Edit: Subdomain Setup
To have a subdomain set up where your wordpress network would look like site1.YOURDOMAIN and site2.YOURDOMAIN you will need to set up a wildcard subdomain either in cPanel or with your domain registrar. In cPanel you would go to Domains>Sub Domains and create a subdomain with the following information.

* .YOURDOMAIN
/var/www/YOURDOMAIN/public_html/wildcard

Then in your DNS settings you will need to have the wildcard domain (*.YOURDOMAIN) point towards your server.

If you're not using cPanel, you can login to your domain registrar and edit your DNS settings and set up the same configuration but it will look something like this:

Name               TTL          Class          Type          Record
*.YOURDOMAIN       14400         IN             A            YOURSERVERIP
www.*.YOURDOMAIN   14400         IN             A            YOURSERVERIP

Thank you to @fitkoh for this recommendation.

I would like to thanks Post4VPS and @cubedata for the amazing server, allowing me to get Tyler Bell Design Co. Development up and running. You can see the results of the Multisite Network by visiting http://dev.tbelldesign.co and http://dev.tbelldesign.co/eventpros/ to see how one network can host a plethora of sub sites. Good luck and happy development! If you have any questions feel free to ask them below!
Thank you to CubeData and Posts4VPS for the services of VPS 8.
#2
Nice tutorial, and the dev part of your site loads nicely.

The tutorial also looks well written and easy to follow (although I don't use phpmyadmin, it would be redundant in my current setup).

One possible improvement you could make would be to install phpmyadmin in something other than a default directory, which would minimize risk of intrusion.

As an extension of this tutorial, or as in idea for another one in the future, would be to do a subdomain multisite network tutorial in addition to/instead of the subdirectory method.
#3
(10-12-2020, 12:12 AM)fitkoh Wrote: Nice tutorial, and the dev part of your site loads nicely.

The tutorial also looks well written and easy to follow (although I don't use phpmyadmin, it would be redundant in my current setup).

One possible improvement you could make would be to install phpmyadmin in something other than a default directory, which would minimize risk of intrusion.

As an extension of this tutorial, or as in idea for another one in the future, would be to do a subdomain multisite network tutorial in addition to/instead of the subdirectory method.

Thank you for the feedback! I can look into the subdomain options, I have not played with them and just with how fickle the mod_rewrite settings for Wordpress are I have always shot for the subdirectory option. As for phpMyAdmin, you can set allowed IP Addresses so if you are not using it from localhost you can set it for your public IP address to minimize security vulnerabilities.
Thank you to CubeData and Posts4VPS for the services of VPS 8.


Possibly Related Threads…
Thread
Author
Replies
Views
Last Post
1,565
09-06-2019, 07:02 PM
Last Post: Manal

person_pin_circle Users browsing this thread: 1 Guest(s)
Sponsors: VirMach - Host4Fun - CubeData - Evolution-Host - HostDare - Hyper Expert - Shadow Hosting - Bladenode - Hostlease - RackNerd - ReadyDedis - Limitless Hosting