How to setup a Linux web server using the command line, Part 2 : Installing Server Applications

#
# Linux (Ubuntu) web server application installations
#

Now that we have basic security and firewall on our new Linux server, as set up in Part 1, let’s quickly install all the essential Web 2.0 applications we are going to need.# on remote server

# set locale

sudo locale-gen en_US.UTF-8
sudo /usr/sbin/update-locale LANG=en_US.UTF-8 

# update package manager (aptitude)

sudo aptitude update
sudo aptitude safe-upgrade
sudo aptitude full-upgrade 

# install essential builds

sudo aptitude install build-essential 

# install and configure mysql

sudo aptitude install mysql-server mysql-client libmysqlclient15-dev libmysql-ruby1.8 -y
sudo nano /etc/mysql/my.cnf
——-
key_buffer = 1M
max_allowed_packet = 1M
thread_stack = 64K
thread_cache_size = 4
sort_buffer = 64K
net_buffer_length = 2K
skip-innodb
——-
sudo /etc/init.d/mysql restart
which mysql
> /usr/bin/mysql

# install ruby

sudo aptitude install ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8 libreadline-ruby1.8 libruby1.8 libopenssl-ruby -y
sudo ln -s /usr/bin/ruby1.8 /usr/bin/ruby
sudo ln -s /usr/bin/ri1.8 /usr/bin/ri
sudo ln -s /usr/bin/rdoc1.8 /usr/bin/rdoc
sudo ln -s /usr/bin/irb1.8 /usr/bin/irb
ruby -v
> ruby 1.8.6 (2007-09-24 patchlevel 111) [i486-linux]
which ruby
> /usr/bin/ruby 

# install rubygems

mkdir ~/sources
cd ~/sources
wget http://rubyforge.org/frs/download.php/34646/rubygems-1.2.0.tgz
tar xzvf rubygems-1.2.0.tgz
cd rubygems-1.2.0
sudo ruby setup.rb
sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
sudo gem update
sudo gem update –system
gem -v
> 1.2.0
which gem
> /usr/bin/gem 

# install rails

sudo gem install rails
rails -v
> Rails 2.1.0
which rails
> /usr/bin/rails 

# install imagemagick, rmagick library, freetype library, and xml-core

sudo aptitude install imagemagick librmagick-ruby1.8 librmagick-ruby-doc libfreetype6-dev xml-core -y 

# test installations using inline ruby console

irb
>> require ‘mysql’
#=> true
>> require ‘rubygems’
#=> true
>> require ‘RMagick’
#=> true
>> exit 

# install postfix and subversion

sudo aptitude install postfix subversion -y 

# install apache

sudo aptitude install apache2 apache2.2-common apache2-mpm-prefork apache2-utils libexpat1 ssl-cert 

# restart apache (you’ll use this command a lot to make sure apache survives your changes)

sudo /etc/init.d/apache2 reload 

# install php

sudo aptitude install libapache2-mod-php5 php5 php5-common php5-curl php5-dev php5-gd php5-imagick php5-mcrypt php5-memcache php5-mhash php5-mysql php5-pspell php5-snmp php5-sqlite php5-xmlrpc php5-xsl
# restart apache
sudo /etc/init.d/apache2 reload 

# install perl

sudo aptitude install libapache-dbi-perl libapache2-mod-perl2 libdbd-mysql-perl libdigest-sha1-perl
# restart apache
sudo /etc/init.d/apache2 reload 

# install apache subversion support

sudo aptitude install libapache2-svn
# restart apache
sudo /etc/init.d/apache2 reload 

# enable ssl for apache and other apache modules needed

sudo a2enmod dav
sudo a2enmod dav_svn
sudo a2enmod perl
sudo a2enmod proxy
sudo a2enmod proxy_balancer
sudo a2enmod proxy_http
sudo a2enmod rewrite
sudo a2enmod ssl 

# restart apache

sudo /etc/init.d/apache2 force-reload 

# create self-signed ssl certificate

sudo make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/ssl/certs/selfsigned.pem 

# apache configuration

sudo nano /etc/apache2/apache2.conf
——-
# at the bottom
ServerName ubuntu
NameVirtualHost *:80
<IfModule mod_ssl.c>
NameVirtualHost *:443</IfModule>
——- 

# edit default vhost site

sudo nano /etc/apache2/sites-available/default
# see apache2_sites-available_default text file 

# reload apache

sudo /etc/init.d/apache2 force-reload 

# install mongrel and mongrel_cluster

sudo gem install mongrel mongrel_cluster 

# install sqlite3

sudo aptitude install sqlite3 libsqlite3-dev
sudo gem install sqlite3-ruby 

# install capistrano

sudo gem install capistrano 

# reload apache, just to make sure it says “…done.”

sudo /etc/init.d/apache2 force-reload 

Done!Now on to Part 3 where we setup simple apache vhost configuration files for our websites…

Leave a Comment

You must be logged in to post a comment.