Unmanaged hosting often comes with very competitive price compared to managed hosting environment, however, the drawback of which, is the steep learning curve for server noobs that unfortunately includes me. It’s meant for technically proficient ones after all.
This simple tutorial will walk you through the steps needed to set up a working web server that’s ready to serve websites from a bare bone Linux distro (Ubuntu, in this case). It serves to be a survival guide of unmanaged hosting for novice Linux server administrators while at the same time documents my findings and learned tips for myself.
We will take Ubuntu 9.04 (Jaunty) for example. Though all things are done at a Mosso 256 MB Cloud Server, 99% of them should work without a problem at other unmanaged hosting providers as long as the Linux distribution is identical. After this tutorial, you will have a working VPS or dedicated hosting server with update to date softwares and beginner security, in addition to necessary software packages to run and manage a LAMP web server: FTP, Apache 2, PHP 5.2.6 and MySQL.
Here we go. Suppose you have made the decision to go with one of the Linux distros of which I’d suggest Ubuntu and installed a plain version of it from the hosting control panel, now:
- You will be given a bare IP address, of course, when you have finished installing the Linux distro from the contrl panel provided by your hosting company. Download PuTTY and set it up to connect to your hosting server of that IP as the root via SSH. The root password should also have been revealed or emailed to you.
- Change the root password to a new one.
- Customize the default SSH listening port of 22 to a custom one.
- Build up necessary iptables firewall rules.
- Customize shell environment and make the prompt ls command listings a little more colorful so it’s more readable.
- Enable vi code highlighting (enabled by default in Ubuntu) and change the dark blue color for comments to a lighter blue.
- Update the software source lists in Ubuntu by:
aptitude updateAnd set the proper locales:
- Upgrade the current distro to its latest:
aptitude safe-upgradeFollowed by:
- Install the essential tools and packages for development, the build tools:
aptitude install build-essential
- Install MySQL:
aptitude install mysql-server mysql-clientThe installation will prompt you twice for the root password.
- Install Apache:
aptitude install apache2 apache2.2-common apache2-mpm-prefork apache2-utils libexpat1 ssl-certChange server name in the Apache configuration:
vi /etc/apache2/apache2.confAnd add the following directive at the end of the file:
ServerName kingChange ‘king’ to whatever you’ll name your own server. For beginner SSH users, nano would be a better choice for its intuitive editing capabilities. After restarting Apache web server gracefully by not interrupting connected clients:
apache2ctl gracefulYou should be able to view the demo web page at http://(your server IP address).
- Install PHP5:
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
- Turn off server signature:
nano /etc/apache2/conf.d/securityAnd change:
- Change the hostname of your server. Open and edit /etc/hostname:
vi /etc/hostnameTo a top level domain you have registered for your website. And add it in /etc/hosts:
vi /etc/hostsIn this way:
- Reboot by:
shutdown -r now
- Install the mail module for your hosting server, Postfix, so the php function mail() works:
aptitude install postfix telnet mailxJust choose ‘Internet Site’.
- Install FTP daemon service so you can FTP stuff to your server as any user.
- Install rsync so that you can easily synchronize and backup files between 2 remote hosting servers:
aptitude install rsync