Basic Slicehost Slice Setup Part 7 - Create the Virtual Host Website
This is part seven of our series on configuring a Slicehost slice. Today is going to be another heavy day.
Step Seven – Create the Website
Create Directory Structure
mkdir -p /home/<username>/public_html/<domain.name>/{public,private,log,backup}
where <username> is your username in the VPS and <domain.name> is the name of the domain that you are creating.
Create Default Index Page
In /home/<username>/public_html/<domain.name>/public/, create an index.php file as a placeholder. I generally create the standard phpinfo page:
<?php
phpinfo();
?>
Create the vhost File
Open /etc/nginx/sites-available/<domain.name> in a text editor as root:
sudo nano /etc/nginx/sites-available/<domain.name>
where <domain.name> is the website that you are creating.
Add the following as the content, replacing <domain.name> and <username> accordingly:
server {
listen 80;
server_name <domain.name>;
#rewrite ^/(.*) http://www.<domain.name> permanent;
access_log /home/<username>/public_html/<domain.name>/log/access.log;
error_log /home/<username>/public_html/<domain.name>/log/error.log;
location / {
root /home/<username>/public_html/<domain.name>/public/;
index index.php;
# wordpress fancy rewrites
if (-f $request_filename) {
break;
}
if (-d $request_filename) {
break;
}
rewrite ^(.+)$ /index.php?q=$1 last;
}
location ~ .*\.php[345]?$ {
include /etc/nginx/fcgi.conf;
fastcgi_pass 127.0.0.1:10005;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/<username>/public_html/<domain.name>/public$fastcgi_script_name;
}
}
server {
listen 80;
server_name www.<domain.name>;
access_log /home/<username>/public_html/<domain.name>/log/access.log;
error_log /home/<username>/public_html/<domain.name>/log/error.log;
location / {
root /home/<username>/public_html/<domain.name>/public/;
index index.php;
# wordpress fancy rewrites
if (-f $request_filename) {
break;
}
if (-d $request_filename) {
break;
}
rewrite ^(.+)$ /index.php?q=$1 last;
}
location ~ .*\.php[345]?$ {
include /etc/nginx/fcgi.conf;
fastcgi_pass 127.0.0.1:10005;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/<username>/public_html/<domain.name>/public$fastcgi_script_name;
}
}
Enable the Website
sudo ln -s /etc/nginx/sites-available/<domain.name> /etc/nginx/sites-enabled/<domain.name>
Restart nginx
sudo /etc/init.d/nginx stop
sudo /etc/init.d/nginx start
Part 8
Tomrrow is the final installment on this series. We are finally going to get Wordpress up and running.
Basic Slicehost Slice Setup Series List:
- Part 1 - Updating Ubuntu
- Part 2 - Configure iptables
- Part 3 - Install and Configure OpenSSH
- Part 4 - Install nginx Web Server
- Part 5 - Installing MySQL
- Part 6 - Installing PHP5 with fastcgi
- Part 7 - Create the Virtual Host Website
- Part 8 - Install WordPress via Subversion
Related articles:
- Understanding the Different Types of Web Hosting
- Advantages of Sharing a Virtual Private Server
- To Succeed With Your Blog, Use Successful Hosting
- What is a Virtual Private Server?

One Response to “Basic Slicehost Slice Setup Part 7 - Create the Virtual Host Website”
-
Tom Thompson Says:
February 25th, 2009 at 12:39 pmThis has been an interesting series but I don’t like having to do that configuration stuff by hand any more.
We use Virtualmin Pro which does most of it for you automatically including FTP, PHP, Perl, and a bunch of other stuff.
There is also Virtualmin GPL which works well but isn’t as polished as Pro.

![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=7cd902a2-fba7-4be2-8266-d7c0b3e3941e)
