I've recently moved my websites from Django Dreamhost FastCGI due to poor performance to the 256 plan option from Slicehost . If you sign-up with Them, please use "inerte@gmail.com" to your referral. I have no idea how much They pay for referrals, But any money is good money ![]()
Here's my guide:
Painless registration Gave me the root password in 2 minutes. Write down your IP address and your root password somewhere so you will not forget it.
SSH (I've Used Putty ) to your server, authenticate, and execute the commands below. I've Decided to install PHP because I have domains using it. Also, it's Necessary for phpMyAdmin.
$ Apt-get install apache2 $ Apt-get install libapache2-mod-python2.4 $ Apt-get install mysql-server $ Apt-get install python2.4-MySQLdb $ Apt-get install php5 $ Apt-get install php5-mysql $ Apache2ctl restart $ / Etc/init.d/apache2 reload
$ Mysql-u root mysql> UPDATE mysql.user SET Password = PASSWORD ('your_root_mysql_password') WHERE User = 'root'; mysql> FLUSH PRIVILEGES; mysql> quit
It's just easier. I've Decided not to install the FTP server to upload my files. Instead, I've Used WinSFTP , the sftp client for Microsoft Windows. Download and install it. Open, paste Slice your IP address and browse to the / var / www / directory, upload ITS install phpMyAdmin and follow instructions.
$ Cd / usr/lib/python2.4/site-packages / $ Svn co http://code.djangoproject.com/svn/django/trunk/ django
Open WinSFTP again, browse to the / usr/lib/python2.4/site-packages / directory and upload your Django project.
ITS Edit settings.py file.
vi / usr/lib/python2.4/site-packages/your_django_project/settings.py I'll only show what You Have to Change, Besides whatever is needed for your project to work (like INSTALLED_APPS):
DATABASE_ENGINE = 'mysql' DATABASE_NAME = 'your_db_name' DATABASE_USER = 'your_db_user' DATABASE_PASSWORD = 'your_db_password'
I use the directory for media files called "web" on most of my projects:
Media_root = '/ var / www / your_domain.com / web /' MEDIA_URL = '/ web /'
You'll Also Have to change the TEMPLATE_DIRS tuple. Just put whatever you use. Here's mine for reference:
TEMPLATE_DIRS = (
# Put strings here, like "/ home / html / django_templates.
# Always use forward slashes, even on Windows.
'/ Usr/lib/python2.4/site-packages/my_django_project/templates/my_django_project /',
)
$ Mkdir / var / www / your_domain.com $ Mkdir / var/log/apache2/your_domain.com $ Vi / etc/apache2/sites-available/your_domain.com
Paste this text inside the file:
<VirtualHost *>
ServerName www.your_domain.com
ServerAlias your_domain.com
# The three lines below removes the www from the domain name. I do not like WWWS.
RewriteEngine On
RewriteCond% (HTTP_HOST) ^ www \. Your_domain \. With [CN]
RewriteRule (.*) http://your_domain.com $ 1 [R = 301, L]
DocumentRoot / var / www / your_domain.com
CustomLog / var/log/apache2/your_domain.com/access.log Combined
ErrorLog / var/log/apache2/your_domain.com/error.log
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE your_django_project.settings
PythonDebug Off
PythonPath "['/ usr/lib/python2.4/site-packages/django'] + sys.path"
# My own media directory (as Mentioned in the previous section)
<Location "/web/">
SetHandler None
</ Location>
# Necessary for Django's admin media files
<Location "/media/">
SetHandler None
</ Location>
</ VirtualHost>
Symlink your new domain configuration file to the correct directory:
ln-s / etc/apache2/sites-available/your_domain.com / etc/apache2/sites-enabled/your_domain.com Symlink Django's admin media files to your domain:
ln-s / usr/lib/python2.4/site-packages/django/django/contrib/admin/media / var / www / your_domain.com / media Edit Apache's configuration file to tell it your IP address:
vi / etc/apache2/apache2.conf Paste this before the # Include the virtual host configurations: line (before it's the last one):
ServerName your.slice.ip.address Edit Apache's log rotation to include your new domain:
vi / etc/logrotate.d/apache2 Paste this at the end:
/ Var/log/apache2/your_domain.com / *. log ( weekly missingok rotate 52 compress delaycompress notifempty create 640 root adm sharedscripts postrotate if [-f / var/run/apache2.pid], then / Etc/init.d/apache2 restart> / dev / null fi EndScript )
I've tried to install the DNS Server but not only I thought it's hard, Having a single point of failure is bad. So I've signed up with DNS Made Easy and I let Them manage this for me. It's super simple, after joining, add your domain to DNS Made Easy and write down the DNS server addresses. Wait Until the domain name is "created" (to me, it Varied from 30 minutes to 2 hours), and change the dns servers from your domain name registrar.
Restart Apache one more time:
$ Apache2ctl restart $ / Etc/init.d/apache2 reload
And we're done! With one caveat: We've checked out Django "trunk" directory into your Python's directory. That means the real lives the django directory below:
/ Usr/lib/python2.4/site-packages/django/django /
That Which means if you ever want to use Django's outside Apache mod_python, you'll Have to add the / usr/lib/python2.4/site-packages/django directory to your sys.path. Or, You Could checkout Django to somewhere else, and move the "real" django site-packages directory to / (and change the / etc/apache2/sites-available/your_domain.com) accordingly.
If you're HAVING problems, write something at the comments here and I will try to help you.