Ubuntu VDS Guide
From OCS Support Wiki
Contents |
[edit] Introduction
So, you've got your freshly setup Ubuntu VDS from OCS Solutions and you're ready to install software on it! This guide will show you how to install the most commonly requested software. You will need to make an SSH connection to your VDS and login as root to perform these actions.
[edit] What's Already Installed
When we setup your Ubuntu VDS, we configure some things by default. We configure all of the default repositories and add the restricted ones as well for the full collection of installable software. In addition, we install packages like:
- rkhunter - The "Root Kit Hunter" for Linux. Facilitates scanning the OS for rootkits and other nefarious activity.
- quota - Allows you to set a disk space limit for your users
- postfix - The Postfix mail server is configured with a mostly "out of the box" working configuration and is secured against open relay.
- ntp - Automatically syncs the system clock to keep it in sync. Only installed and needed on Xen VDS's (OpenVZ uses the host system clock).
- wget and curl - These utilities allow you to download software packages easily for installation and are required for most setups.
This list isn't complete, many Linux software packages are installed by default. Right "out of the box" you'll find many common Linux programs installed. We use the default install of Ubuntu Server. At the time of this writing, the version we use on virtual dedicated servers is 6.06 LTS (the LTS indicating long term support, meaning that updates will be provided for 5 years).
[edit] A Note About Memory
If you have a VDS with a low memory quota (256 MB or less), you may experience some errors installing certain large packages. To work around these issues, try stopping large processes first, like MySQL or Apache. To do so, run:
/etc/init.d/mysql stop /etc/init.d/apache2 stop
You can restart these processes by replacing stop with start and running the above commands again.
To monitor your memory usage on OpenVZ based VDS instances, please refer to Determing Free RAM on OpenVZ.
[edit] Apache
Installing Apache in Ubuntu is easy. Simply run:
apt-get install apache2 webalizer logrotate -y a2enmod proxy_balancer a2enmod actions /etc/init.d/apache2 restart
This will install Apache with a few additional but commonly used modules loaded. Once started, content by default will be served from /var/www.
Keep in mind that if you are planning to put only one Ruby on Rails website and plan to use Lighttpd or Mongrel, you may not want to install Apache.
[edit] PHP
You can install PHP on Ubuntu with the following command:
apt-get install libapache2-mod-php5 -y
This will install a very basic configuration of PHP with only the essential modules installed.
[edit] Additional Modules
You will probably want many of the common PHP modules installed. To install additional modules, run:
apt-get install php5-xsl php5-xmlrpc php5-uuid php5-pspell php5-mysql \ php5-mhash php5-mcrypt php5-json php5-imap php5-gd php5-dev php5-curl php5-cli php-pager -y
[edit] phpMyAdmin
Additionally, if you want to install phpMyAdmin for administering MySQL databases, you can run:
apt-get install phpMyAdmin
This installs phpMyAdmin into the /var/www directory, making it accessible by going to http://1.2.3.4/phpMyAdmin (replace 1.2.3.4 with your IP address).
[edit] Ruby
One of the most requested and popular languages at OCS (we love it ourselves)! Here's how to install it:
apt-get install ruby irb rdoc ri ruby1.8-dev vim-ruby eruby libapache-mod-ruby \ libmysqlclient14-dev libmysql-ruby librmagick-ruby libfcgi-ruby1.8 libopenssl-ruby -y
Make sure you copy all of the above in one line. This will install Ruby, Ruby's MySQL module, Ruby's ImageMagick module (called RMagick), and a few other popular plugins that it is best to install via apt-get rather than through Ruby Gems.
[edit] Rubygems
You will also want to install the Ruby Gems package manager. To do so, run:
wget http://www.ocssolutions.com/scripts/install-gem chmod +x install-gem ./install-gem rm -f install-gem
Once the gem command is installed you can install popular add-ons like Ruby on Rails.
[edit] Ruby on Rails
If you want to install Ruby on Rails, run:
gem install rails -y
[edit] Other Popular Gems
We also recommend installing some common gems (other than the RMagick, OpenSSL, and other assorted gems installed during the Ruby installation instructions below), such as:
gem install payment -y gem install mongrel -y gem install capistrano -y gem install json -y gem install paypal -y gem install uuidtools -y gem install gruff -y gem install feedtools -y gem install rfacebook -y
[edit] MySQL
MySQL is a popular open source SQL database server. It can be installed on Ubuntu very easily by running:
apt-get install mysql-server -y
This will also start the server. It will have no root password by default, so we recommend you set one. To do so, type:
mysqladmin -u root password NEWPASSWORD
Replace NEWPASSWORD with the password you want to use. You may also want to put this in your .my.cnf file so that you can type the mysql command and instantly connect to the database server without having to type the password, and for automating backups. To do so, type:
echo "[mysql] user = root password = NEWPASSWORD [mysqldump] user = root password = NEWPASSWORD" > ~/.my.cnf chmod 0600 ~/.my.cnf
Replace NEWPASSWORD with the password you set for the root user. To test this, you should be able to type:
mysql
and the database server load, prompting you for SQL commands.
[edit] PostgreSQL
Installing PostgreSQL on Ubuntu is simple. Simply run:
apt-get install postgresql-8.1 postgresql-dev libpg-perl libdbd-pg-perl -y
If you want the extensions for Ruby and PHP, run:
apt-get install php5-pgsql libpgsql-ruby -y
[edit] Subversion
There couldn't be anything simpler to install on Ubuntu than Subversion. Just run:
apt-get install subversion -y
Commands like this demonstrate the simplicity and power of Ubuntu and Debian's package management system.
[edit] Lighttpd
Installing Lighttpd is easy, but we recommend disabling it from startup unless you're going to have Lighttpd handle all of your Rails sites and you don't plan on running Apache. To install it, run:
/etc/init.d/apache2 stop apt-get install lighttpd -y /etc/init.d/lighttpd stop chmod -x /etc/init.d/lighttpd /etc/init.d/apache2 start
If you are planning on using Lighttpd and only Lighttpd, before you run the above commands make sure Apache isn't installed (you can use apt-get remove apache2 just to make sure) and then you can omit the lines after /etc/init.d/lighttpd)
[edit] Webmin
Webmin is an amazingly complete control panel to let you graphically administer your server. While it doesn't do everything, it will generally get you a good way through most configuration tasks without even touching the command line.
That said, we must use the command line to install it, so run:
echo "/bin/false" >> /etc/shells mkdir -p /usr/local/webmin cd /usr/local/webmin wget http://superb-west.dl.sourceforge.net/sourceforge/webadmin/webmin-1.370.tar.gz tar xfz webmin-1.370.tar.gz mv webmin-1.370/* . rm -Rf webmin-1.370 rm -f webmin-1.370.tar.gz ./setup.sh
Setup will ask you some questions. On all of them except the user and password you want to just accept the defaults (hit ENTER). On the username, put "root", and for the password put your root password. Make sure you enable SSL when prompted.
Then go to https://IP:10000/. Replace IP with the IP of your server. When prompted for user and password, enter root for the user and your root password. Once you're successfully logged in, go to "Webmin Users" and click "root". In the pickdown box after the password area pick "Unix Authentication" and click "Save" at the very bottom of the page. Now if you change your root password on the server, it will be reflected in your Webmin login as well.
