At this point, you have a pretty nice server setup. Congrats! But, your server still doesn’t do anything useful. Let’s install some software.
A compiler is often required to install Python packages and other software, so let’s just install one up-front.
sudo aptitude install build-essential
sudo aptitude install mysql-server libmysqlclient-dev
Set root password when prompt asks you.
Verify that MySQL is running.
sudo netstat -tap | grep mysql
For connecting to MySQL, instead of the usual PHPMyAdmin, I now use Sequel Pro, a free app for Mac.
Before using MySQL in production, you’ll want to improve your MySQL installation security. Run:
This will help you set a password for the root account, remove anonymous-user accounts, and remove the test database.
Over time your MySQL tables will get fragmented and queries will take longer to complete. You can keep your tables in top shape by regularly running OPTIMIZE TABLE on all your tables. But, since you’ll never remember to do this regularly, we should set up a cron job to do this.
Open up your crontab file:
Then, add the following line:
@weekly mysqlcheck -o --user=root --password=<your password here> -A
Also, you can try manually running the above command to verify that it works correctly.
The excellent automysqlbackup utility can automatically make daily, weekly, and monthly backups of your MySQL database.
sudo aptitude install automysqlbackup
Now, let’s configure it. Open the configuration file:
sudo nano /etc/default/automysqlbackup
By default, your database backups get stored in /var/lib/automysqlbackup which isn’t very intuitive. I recommend changing it to a folder within your home directory. To do this, find the line that begins with BACKUPDIR= and change it toBACKUPDIR="/home/<your username>/backups/"
You also want to get an email if an error occurs, so you’ll know if automatic backups stop working for some reason. Find the line that begins with MAILADDR= and change it to MAILADDR="<your email address>".
Close and save the file. That’s it!
Install Python environment:
sudo aptitude install python-pip python-dev sudo pip install virtualenv
This creates a global “pip” command to install Python packages. Don’t use it, because packages will be installed globally. Instead, use virtualenv.
Create a new virtualenv Python environment with:
virtualenv --distribute <environment_name>
Switch to the new environment with:
cd <environment_name> source bin/activate
Note that the name of your environment is added to your command prompt.
Install Python packages with “pip” inside of virtualenv:
pip search <package_name> pip install <package_name>
This is the best Python workflow that I’ve found. Let me know if you know of a better way to manage Python packages and Python installations.
sudo aptitude install nginx
sudo aptitude install apache2
sudo aptitude install php5 libapache2-mod-php5 php5-mysql sudo service apache2 restart
sudo aptitude update sudo aptitude install python-software-properties python g++ make sudo add-apt-repository ppa:chris-lea/node.js sudo aptitude update sudo aptitude install nodejs
Follow instructions on 10gen’s site: Install MongoDB on Ubuntu.
sudo aptitude install redis-server