HowTo setup multiple Instances of WordPress

Before the first things:

Disclaimer: I am just writing what I did, you should decide for yourself if it is a good idea to copy it. I am not responsible for any damages or wasted time from following these instructions.

First things first: I am lazy, so I just write everying lowercase, except the beginning (sometimes). Just that you know… 😉 Another thing: This Post probably looks like shit… I can write raw html (no problem) but i have no idea how to use wordpress. Im writing it just in a textbox and i am not sure if i could simply use markdown and because i already want to be done with this post i wont try right now…

So… after having to create a new instance of wordpress on my server again after a week of not having to do it (and forgetting everything that i did) i decided that i could use this instance of wp to write it down – at least for me or for my friends who are interested. fortunately i already wrote the process down in a chat, because a friend asked me (about 20 minutes after i finished installing a second instance of wordpress myself) how to do it – which was fortunate at that time as well as now for me.

After the long introduction i will begin straight away:

My (maybe relevant) setup:

  • a debian-system and apache2 as webserver
  • multiple (sub)domains with a records to the same ip and a virtualhost setup on that server

My goal(s):

  • having multiple (in theory infinite) instances of wordpress running in parallel WITHOUT that wordpress-network-stuff
    • why not? -> because i didnt like the tutorials for that (that usually means they didnt work for me)
  • every wordpress instance should have its own (sub)domain (obviously)
  • i want to use the same mysql username and password BUT a different database, because im lazy
    • the idea is: if my super-safe random password for the mysql-user gets hacked i will be fucked anyway (because they would probably have hacked something else to get to that point) and i want to be able to install a shitload of instances without having to remember a mysql username and pw for everyone

You have to think a little bit by yourself: Just copying the following lines WILL NOT WORK!

You have to think a little bit by yourself: Just copying the following lines WILL NOT WORK!

You have to think a little bit by yourself: Just copying the following lines WILL NOT WORK!

What to do:

(The following commands are for your terminal on the server to which you should be connected)

Things with a “$”-symbol in front are variables that you probably should change.

MySQL-Stuff

sudo mysql -u$yourusername -p$yourpassword -h$hostofyourdatabase (probably localhost)
create database $yourdatabasename;
GRANT ALL ON $yourdatabasename.* TO 'wordpress_user'@'localhost' IDENTIFIED BY '$yourpassword';
FLUSH PRIVILEGES;
quit

Now you should have a new database for the wordpress_user that you are already using with the password that you are already using.

WordPress-Stuff

  • Go into your webserver-folder (probably /var/www)
  • make a new folder with a good name (if possible), i will call it “wpfolder”
    • find a better name for it than me
  • enter your $wpfolder
    • make sure you have write-permissions in your wpfolder
  • wget https://wordpress.org/latest.zip (Link maybe broken)
  • 7z x latest.zip

Now you should have a folder called “wordpress” in $wpfolder.

The next thing you should do is to edit the wp-config.php. As i said before: I am lazy so i copied it from my other wp-instance:

  • sudo cp /var/www/$myotherwordpressfolder/wordpress/wp-config.php /var/www/$wpfolder/wordpress/

You have to edit the following line:
define( 'DB_NAME', 'wordpress_db' );

  • Change ‘wordpress_db’ to ‘$yourdatabasename’

As you use the user and password of the other instance you dont have to change anything there…

Thats it, basically… To get it running one has to configure a vhost and restart apache – I will probably explain that in another post.