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:

  1. Part 1 - Updating Ubuntu
  2. Part 2 - Configure iptables
  3. Part 3 - Install and Configure OpenSSH
  4. Part 4 - Install nginx Web Server
  5. Part 5 - Installing MySQL
  6. Part 6 - Installing PHP5 with fastcgi
  7. Part 7 - Create the Virtual Host Website
  8. Part 8 - Install WordPress via Subversion

Related articles:

Reblog this post [with Zemanta]

Similar Posts:

If you found this post useful, why don't you buy me a cup of coffee to show your gratitude?