WWDW Part II : Creating A New Site
Previously on WWDW
You set up a new server as shown in the previous post, now you have to add a new site to your server. You can have as many sites as you want at your server, just keep in mind the power of the server (memory, CPU, RAM etc.).
How to create a new site
To create a website on your server, you should create a folder for your website first. You can do that with simple command
sudo mkdir /var/www/{sitename}
After creating a new folder, you should set a correct permissions to the folder. This is extremly important step because if permissions are not set correctly rocketeer will not work (due to a lack of permissions). You should execute the following commands to set the right permissions
sudo chown -R root /var/www/{sitename} sudo chgrp -R www-data /var/www/{sitename} sudo chmod -R 775 /var/www/{sitename} sudo chmod g+s /var/www/{sitename}
Now you’ll have to configure apache vhost to register your newly created site in the apache config. The simplest way to do that is by copying and modifying the default config. This order will copy the apache default config into your new config
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/{sitename}.conf
Now you copied the default config and you have to edit it.
sudo nano /etc/apache2/sites-available/{sitename}.conf
This config file should look like this
<VirtualHost *:80> # email of server admin ServerAdmin your@email.com # main name for your server. your domain without the www ServerName your.domain # aliases for your server, most common is domain with www ServerAlias www.your.domain # path to your root folder DocumentRoot /var/www/{site_root_folder} # something something ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined <Directory /var/www/{site_root_folder}/>; AllowOverride FileInfo Options php_admin_flag save_mode off </Directory> </VirtualHost>
If everything worked fine, add the new site to apache running the following command
sudo a2ensite your.domain.conf
Finally, restart the apache to make things work 🙂
sudo service apache2 restart
A piece of advice
Windows hosts
If you don’t have the domain yet, you can access your site by modifying hosts file (found in C:\Windows\System32\drivers\etc) and adding this line to it
{your_server_ip_address} {sitename}
Sitename in the hosts record must be the same as the server name (or server alias) that you wrote at the site apache config (lines 6 and/or 9)
I see default apache page
If you see the default apache page then something is wrong in your apache site config file (/etc/apache2/sites-avalible/{sitename}.conf). Check the lines 13 and 18 to see if you entered site’s root directory correctly
What next?
At this point you successfully set up your server, and added a new site to it. Now you have to install and configure WordPress and rocketeer to make the deployment process easy. This is described in the next blog post: Rocketeer Configuration
Info
This blog post is a part of Windows WordPress Development Workflow (WWDW) blog posts’ series. All blog posts in the series are:
- WWDW Part I : Server Configuration
- WWDW Part II : Create A New Site
- WWDW Part III : Rocketeer
- WWDW Part IV : Enterwell’s way