Conor
Elite Member
- Nov 7, 2012
- 3,621
- 6,217
I had some free time today, so I thought I'd play around in Ubuntu (13.10), and see what I can do in LAMP. These steps can be transposed to Windows pretty easily though.
So what are we doing? Well, as an ego boost, and convenient way to organise your sites in localhost, we are going to be making custom domain names. The "proper" word for this is "Virtual Host". I felt like making wordpress.local my official place for local Wordpress testing, mockup designs, etc.
Of course, you can always just use a subfolder, but I think this is cooler.
So where to start? Make sure LAMP is installed. If not, run this:
Check. Next, you'll want to edit /etc/hosts, and add your chosen domain "wordpress.local" after "localhost".
It should look like this:
Notice how I have the www version of my domain listed there too. That's so it works, no matter whether I type www.wordpress.local, or not. You can just keep adding to this line, for every new domain you want to add. The extension isn't important. You could have yoloswag.parishilton if you wanted.
The next bit requires a bit of brain usage, so bear with me here. You want to run this command:
It just makes things work, don't ask me why. Google has a ton of answers.
Next, you want to run:
This will open your text editor, where the final bit of code can be pasted. Make sure to change Directory and DocumentRoot (/var/www/wordpress) to match the folder you wish to use for your site:
You can pretty much copy and paste this whole block of text, for every new domain you wish to create, after adding it to your hosts file. It's that easy.
Done and dusted. Now all we need to do is activate it, and restart apache:
And there you go. You can now go and add your index.php file, or install Wordpress in the directory you specified earlier. Navigate to http://wordpress.local in your browser, and you should be set!
I have experienced problems with some WP themes and plugins in the past, when it's installed in a subfolder, so that was my main inspiration for doing this. If you have any questions, I'll try find the answer for you. I'm in no way an expert with stuff like this, but I know how Google works.
For some extra reading, check these out:
http://gregrickaby.com/how-to-install-lamp-on-ubuntu/
http://ubuntuforums.org/showthread.php?t=1925236
http://www.techrepublic.com/blog/smb-technologist/create-virtual-hosts-in-a-wamp-server/
http://helpdeskgeek.com/windows-7/windows-7-hosts-file/
Finally, like I mentioned before, I was using Ubuntu 13.10 for this, so some of the codes may be a little bit different for your version of Linux. To get this working in Windows, your "hosts" file is located in \system32\drivers\etc\.
You will want to paste the big block of text in httpd-vhosts.conf, which can be accessed through your WAMP or XAMPP settings.
I'll stop talking now. I'm sure someone could figure out a way of making money with this
So what are we doing? Well, as an ego boost, and convenient way to organise your sites in localhost, we are going to be making custom domain names. The "proper" word for this is "Virtual Host". I felt like making wordpress.local my official place for local Wordpress testing, mockup designs, etc.
Of course, you can always just use a subfolder, but I think this is cooler.
So where to start? Make sure LAMP is installed. If not, run this:
Code:
sudo apt-get install lamp-server^
Check. Next, you'll want to edit /etc/hosts, and add your chosen domain "wordpress.local" after "localhost".
It should look like this:
Code:
127.0.0.1 localhost wordpress.local www.wordpress.local
Notice how I have the www version of my domain listed there too. That's so it works, no matter whether I type www.wordpress.local, or not. You can just keep adding to this line, for every new domain you want to add. The extension isn't important. You could have yoloswag.parishilton if you wanted.
The next bit requires a bit of brain usage, so bear with me here. You want to run this command:
Code:
sudo a2enmod vhost_alias
It just makes things work, don't ask me why. Google has a ton of answers.
Next, you want to run:
Code:
sudo gedit /etc/apache2/sites-available/newsite.conf
This will open your text editor, where the final bit of code can be pasted. Make sure to change Directory and DocumentRoot (/var/www/wordpress) to match the folder you wish to use for your site:
Code:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName wordpress.local
ServerAlias www.wordpress.local
DocumentRoot /var/www/wordpress
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/wordpress/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
Require all granted
</Directory>
</VirtualHost>
You can pretty much copy and paste this whole block of text, for every new domain you wish to create, after adding it to your hosts file. It's that easy.
Done and dusted. Now all we need to do is activate it, and restart apache:
Code:
sudo a2ensite newsite
sudo service apache2 restart
And there you go. You can now go and add your index.php file, or install Wordpress in the directory you specified earlier. Navigate to http://wordpress.local in your browser, and you should be set!
I have experienced problems with some WP themes and plugins in the past, when it's installed in a subfolder, so that was my main inspiration for doing this. If you have any questions, I'll try find the answer for you. I'm in no way an expert with stuff like this, but I know how Google works.
For some extra reading, check these out:
http://gregrickaby.com/how-to-install-lamp-on-ubuntu/
http://ubuntuforums.org/showthread.php?t=1925236
http://www.techrepublic.com/blog/smb-technologist/create-virtual-hosts-in-a-wamp-server/
http://helpdeskgeek.com/windows-7/windows-7-hosts-file/
Finally, like I mentioned before, I was using Ubuntu 13.10 for this, so some of the codes may be a little bit different for your version of Linux. To get this working in Windows, your "hosts" file is located in \system32\drivers\etc\.
You will want to paste the big block of text in httpd-vhosts.conf, which can be accessed through your WAMP or XAMPP settings.
I'll stop talking now. I'm sure someone could figure out a way of making money with this
Last edited: