JOE DESIGNS

A dev shop in Albuquerque New Mexico.

Lighttpd / MySQL / PHP (FastCGI) / Fedora on Mosso Cloud Servers.

Filed under "general" on 4/20/09

Here is a brief walk-thru of setting up Lighttpd / MySQL / PHP (FastCGI) / Fedora on Mosso Cloud Servers. Setting up a cloud server with Mosso is easier than you'd think, its a lot like a dedicated server, and allows full root access. With this combination of web server tools your site will be up and running in no time at all.

I am currently migrating a site to the Mosso Cloud Servers. I figured someone may find this helpful if they find themselves in setting up a similar environment.

First build the cloud server in the Mosso control panel. Then you'll receive a detailed email with your server details. Once you have the email you can login to your server via SSH.

ssh root@{your-mosso-ip}

Create the structure for sites.

mkdir /home/domains
mkdir /home/domains/your-domain.com/
mkdir /home/domains/your-domain.com/docs
mkdir /home/domains/your-domain.com/logs

After the structure is in place, I copied over the site files into the /docs folder.

scp -r root@{old-server-ip}:/path/to/files /home/domains/your-domain.com/docs/

Now to install Lighttpd, PHP, MySQL

[root@your-server]: yum install lighttpd lighttpd-fastcgi php mysql mysql-server

That was easy. Now I am going to install emacs so I can configure lighttpd. I know there are other editors, I just prefer emacs. yum install emacs Note: Yum is a great tool for installing and updating software. Start configuration of lighttpd. I am just making some minor configuration to get a site up and running. Depending on your site / application needs you will need to tune lighttpd for best results. emacs /etc/lighttpd/lighttpd.conf I enabled several modules in the file. There are many available modules documented here.

server.modules              = (
                                "mod_rewrite",
                                "mod_alias",
                                "mod_access",
                                "mod_auth",
                                "mod_fastcgi",
                                "mod_simple_vhost",

Changed the following document-root variable to use /var/www/html

## a static document-root, for virtual-hosting take look at the                                               
## server.virtual-* options                                                                                   
server.document-root        = "/var/www/html"

Added this host to the virtual hosts section.

$HTTP["host"] =~ "(^|\.)your-domain\.com$" {
    server.document-root = "/home/domains/your-domain.com/docs/"
    accesslog.filename = "/home/domains/your-domain.com/logs/access_log"
}

Lets make sure our log folder for the site has the correct permissions

chown lighttpd.lighttpd /home/domains/your-domain.com/logs

Now lighttpd should be configured to run, so lets restart it.

[root@your-server]# /etc/rc.d/init.d/lighttpd restart
Stopping lighttpd:                                         [FAILED]
Starting lighttpd:                                         [  OK  ]
[root@your-server]#

Configure MySQL

emacs /etc/my.cnf

The only thing I'll change at this time is the data directory

datadir=/home/mysql

[root@your-server]# /etc/rc.d/init.d/mysqld restart
Stopping MySQL:                                            [FAILED]
Starting MySQL:                                            [  OK  ]
[root@your-server]#

MySQL is now running. You can now try running a test to see if your server is working.

[root@your-server]# touch /var/www/html/index.php
[root@your-server]# echo "<?php echo 'hello world'; ?>" > /var/www/html/index.php

In a browser goto your IP Address (http://{ipaddress}) and you should see your php script. You will need to configure a DNS system to route traffic to your server. I would suggest using dyndns.org I have always appreciated simple server configuration walk-thrus, and I hope someone will appreciate this one someday. Thanks!