How to Host Multiple WordPress Websites on One Server with Apache

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys what's up this is tony teaches tech i'm tony and in this video i'm going to show you how to host multiple websites on a single apache server specifically we're going to be looking at having multiple wordpress websites on the apache server don't worry if you're not going to use wordpress the same concept still applies regardless of whatever type of application you're trying to host so let's hop on into it right here i already have two websites site1.xyz and site2.xyz host it on the same server for all you know i could be lying though let's just do a quick ping to see if they are indeed on the same ip address level ping site1.xyz that comes back with this ip address and we'll ping site 2.xyz and it comes back with the same exact ip address well that's great but i want to actually go through the steps of setting up the both of these websites actually let's set up a third website on the same ip address so let's log in via ssh to this ip address which by the way if you're interested the these websites are hosted on a linux vps virtual private server whoops i did not spell ssh wrong i did not spell ssh right um yeah these are hosted on linux one click installs of a lamp server linux apache mysql php if you want to learn how to do that i'll put a video in the description and somewhere on this video that you're watching right now okay so we're on the server we're logged in as root and the first thing you want to do is just check out the var www directory which is where most by default most websites are all the files where the websites are living and you can see right here i have site one in site two and inside here we have let's just look in site one we have a wordpress directory in that wordpress directory we have all the basic wordpress files so let's go ahead and repeat that we have site one site two let's make a directory called site three dot xyz we'll go into that folder go into site 3.xyz there's nothing there because we just created the folder and what we want to do is get the latest version of wordpress on our computer and you can do that on on this server and you can do that with wget wordpress.org latest.tar.gz that's going to pull down that archive file and what we want to do next is to unpack that archive so we're going to type type in tar xz vf in the name of that archive that's going to unpack everything into a folder called wordpress and actually remove the archive file and go into the wordpress directory and you'll see those same set of files we'll do some configuration in here in a bit but first i want to set up our database we can do that with my sql and this is of course again assuming that you have a lamp server linux apache mysql php all those basic web hosting technologies installed on your server so just type in mysql if you're root you won't have to type in a password but if you're not root then you might have to do the username and password so here we're in the mysql command prompt i'm going to use my cheat sheet over here and copy and paste the command to create our database so we'll go through this create database named wp under course site underscore site three we're going to use the default character set of utf-8 collate utf-8 underscore unicode underscore ci so that looks good hit enter to execute that we have now created that database and let's make a user for that database and give him some privileges him or her so you can type grant all on this database dot star which means all tables on this database to this user as long as he's on the local host which is you know this ip address not coming from externally somewhere identified by this password which is comically unsecure pw okay so we'll execute that that looks good and the last thing we want to do is to flush the privileges so you can type flush privileges semicolon hit enter and that's all we need to do for the database we now have a empty database ready to go ready to hook up to wordpress so let's take care of that next in here again we have our wordpress configuration files what we want to do is copy this where is it the wordpress config sample.php file and that's just there for you to like get started we want to copy make a copy of that and make our actual wordpress config file so we're going to copy the sample into a file called wp-config.php go ahead and do that and then open the file after you're done with that so i'm going to use the vim text editor in this case and if you need help with vim i'll have a tutorial for you on that so just click in one of the corners up here and we'll go down to this my sequel settings section and we want to fill out a couple of these pieces of information with the values that we just provided to the database so our pa our database is wp underscore site three our user is wp underscore site three underscore user our password is that unsecure pw and we can leave everything else the same the only other thing going to change in this file is the the assault section here and this is just some extra security which i'm not going to go into explaining but basically remove those default values copy this url that they give you here and this is going to paste it into a web browser and this is going to give you some random characters for all of these different values and all we're going to do is go back into the terminal and paste those in where those default values were so you can save this file and go back to the command line and now we have basically linked up the mysql database to the wordpress install so they should all be working we'll test that out in a bit but let's take care of the web server aspect of this the apache aspect of this setup we can do that by going into the etc apache 2 directory and in here you'll see the basic install of apache let's go into the sites available directory and here you'll see i have my site 1 configuration file in my site 2 configuration file let's take a look at the site 1 configuration file it's a very simple file there's no optimization security anything like that it's just defining this virtual host on port 80. the server name which is site1.xyz is the domain name this could be google.com example.com that's where that goes and then the document root is at var www.site1.xyz wordpress so that is where we just saw that where we just came from on our file system so and we'll just look at site too quick it's going to be the exact same thing except everything is changed from site 1 to site 2. so for our third website what i'm going to do is copy site 2 and make a new file called site3.com and all we have to do in site3.conf is change all instances of site2 to site3 everywhere in this file so now we have a file with our server name of site3.xyz and our document root at this file system path so go ahead and save that and the next thing i want to do is just real quick i'll back out of here the site's available so there's these two directories oops cd dot dot okay so these two directories there's the sites available directory and the site's enabled directory so right now we have these sites available we have site one site two and site three but we have only enabled site one in site two so in order to enable site three we have to use the a to en site command which is the apache tooth enable site command and we're just going to type in site3.conf and that looks good it says we'll have to run this command to enable that that configuration change but let's just double check in here in sites enabled and we should now yep we now see site three in here so let's go ahead and reload the apache too and if we get out of here and open up a new tab i think we should be ready to go to this website site3.xyz and there it is we have a fresh installation of wordpress we'll call this site 3 the username admin the password that's fine i'll just copy that onto my clipboard put in my email here tony at tony teaches.tech now this is not going to be a permanent website so i'll click that and we'll log in so we got admin the password log in and there we go we have our wordpress admin dashboard i'm gonna go into the default sample post that they have here and change it from their hello world to welcome to site three just for consistency and we'll go back out to the actual website there you go we have site three dot x y z welcome to site three we have site two site one all on the same hosting platform all on the same ip address we'll we'll configure that or we'll confirm that one last time we'll ping site three dot z and we should see that same exact ip address and we do which is perfect that's what we set out to do guys if you have any questions about hosting multiple websites on apache let me know in the comments below if something wasn't clear don't don't hesitate to ask i'll be more than happy to help you out that's what i'm here for that's what this channel is all about so if that's something you're interested in consider subscribing this channel and if you do i will see you in the next one okay guys one last thing that i thought would be helpful in this video is to show you some of the behind the scenes that i failed to mention so this is my linode dashboard i have the ip address that we were working at this is the server that i have hosted site 1 site 2 and site three on so that's where that came from and then over here i have the domain names that i'm using so i own all of these domain names i got them from namecheap and site1.xyz let's go just look at that for a second here if you click on manage you'll see that the name servers i'm using is the basic dns servers which you can find under this tab here and you'll see that all i did was i pointed the a record for the default website which is just site1.xyz at that ip address and i did the same thing for the www version of the website at that same i p address so i i'm just anticipating some questions in the comments below so that's why i wanted to go over how you link your actual domain name to that ip address and where that ip address came from so that's it thank you guys for watching give it a thumbs up if you liked it i'll see you in the next one [Music]
Info
Channel: Tony Teaches Tech
Views: 11,502
Rating: undefined out of 5
Keywords: how to host multiple websites on one server, host multiple wordpress websites on one server, host multiple websites one one ip address, using apache to host multiple websites on one server, host multiple websites apache, apache multiple sites on one server, apache multiple domains, host multiple websites on one server apache, run multiple websites on one server, apache multiple websites, apache multiple virtual hosts, host multiple websites on one server apache ubuntu
Id: lGSRDV2IQhw
Channel Id: undefined
Length: 12min 8sec (728 seconds)
Published: Fri Aug 14 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.