Getting started

From LinodeWiki

Jump to: navigation, search

Please see the article in the Linode Library on Getting Started for more information and additional resources.

This is a guide for someone who has little to no experience with Linux or hosting ones own server - someone who is moving from shared hosting. Since this is based on my own experience, I will talk about the LAMP stack.

Contents

[edit] Operating System

It is recommended to use a 32 bit OS when you have low memory, since 64 bit uses more memory (main advantage to 64 bit is that it can address over 4GB of memory, which is not needed unless you have one of the largest Linodes). Ubuntu is the more popular choice. You can choose that or Debian. Use the administrative interface on Linode to install the operating system on your node.

Pretty much everything from here on is handled through the terminal (the command line interface). So download Putty if you are a Windows user. Use your root password and Putty to log in (or SSH) into your server.

[edit] Basic Setup

After you are logged in, enter these commands

  • apt-get update
  • apt-get install make (May be required for APC installation later)
  • apt-get install cron (Required if you plan to run scheduled jobs on your server - like automatic periodic database backups)
  • Now create a new user - you don't have to do everything as root. Enter the command adduser joe to create a new user with username joe. Set the password for joe using passwd joe
  • Now it will be joe doing all the admin work although he is not root. He will do that using the command sudo. To add joe to the list of people who can use sudo, enter the command visudo and this opens a file in the vi editor (tutorial). In this file, add the line joe ALL=(ALL) ALL below the line root ALL=(ALL) ALL. Save the file and exit.

[edit] Installing Apache

Enter this command: apt-get install apache2 apache2.2-common apache2-mpm-prefork apache2-utils libexpat1 ssl-cert

After installation:

  • Change the files /etc/apache2/mods-available/autoindex.load and autoindex.conf so that directory listings are not displayed automatically. (skip this step if you don't care)
  • To enable mod_rewrite – a2enmod rewrite (and then restart apache) (skip if you don't want to use mod_rewrite)

[edit] Installing MySQL

apt-get install mysql-server (Don't worry - this will automatically install the client also.) To start the MySQL server, enter the command /etc/init.d/mysql start. And remember the root password that you select.


[edit] Installing an FTP server

You probably want to use FTP to transfer files. To install FTP, apt-get install proftpd. To start your FTP server so that you can make FTP connections, enter the command etc/init.d/proftpd

Hint: You should NOT use FTP, as it's very insecure. Resort to SFTP instead!

[edit] Installing PHP and the APC accelerator

  • apt-get install php5 libapache2-mod-php5 - will install PHP. Now restart Apache and test with phpinfo() to see if PHP was installed correctly.
  • If you want to install APC (highly recommended), the easiest way is to install PEAR and PECL. You also need apache2-threaded-dev. Enter these commands:
    • apt-get install apache2-threaded-dev php5-dev php-pear
    • pecl install apc
    • In /etc/php5/apache2/php.ini add the line extension=apc.so
    • Restart Apache and check phpinfo() again to see if APC installed correctly.

[edit] Setting up name-based virtual hosting

[edit] Installing phpMyAdmin

It is a good idea to install phpmyadmin.

  • apt-get install phpmyadmin
  • Navigate to http://youripaddress/phpmyadmin and log in as root using the MySQL root password you selected. Create the databases you want and the users you want.

Note that you will not be able to use JDBC connections right off the bat from remote servers. So if a connection request is made to MySQL server from the same server, it will be accepted but not remotely. For remote connections, you can set up a tunnel using Putty like so:

  • In Putty go to SSH -> Tunnels. Type Source port 1234 and Destination 127.0.0.1:3306. Select radio buttons Local and Auto and click Add. Now go to Putty -> Session and log in. This creates a secure tunnel between your remote host (your PC) and the server. Now you can use MySQL GUI clients on your PC to connect to the MySQL server on Linode by using the alias 127.0.0.1 port 1234.

[edit] Setting up email

I did not bother to learn email management. Postfix and exim are recommended. To enable your server to send mails (recommended because most apps send emails):

  • apt-get install mailx
  • dpkg-reconfigure exim4-config - This will make you choose some configuration options for how mail should be handled. Choose Internet site and for security purposes, allow only mail relays from localhost.
  • If you are using GoDaddy to register the domain name and simply want to create email forwarders for joe@example.com to go to joe@yahoo.com then in your MX records (in the DNS Manager interface on Linode.com) enter mailstore1.secureserver.net (preference 10) and smtp.secureserver.net (preference 0). There is supposed to be a trailing dot on names for MX servers but Linode does that for you automatically so don't worry about it. Note that these values are for GoDaddy only so don't use them if your domain is not registered with GoDaddy. Then use GoDaddy's admin interface to set up mail forwarding.

[edit] Linux cheat sheet

  • Getting a list of packages and their status (ii is installed):
    • dpkg -l
  • Zip an entire directory to a single file
    • tar -zcvf outputfilename.tgz directoryname (you can use this to zip and then transfer the web server files from your current host)
    • To unzip tar -zxpf filename.tgz
  • MySQL dump
    • Take a backup mysqldump -u USERNAME -pPASSWORD dbname > filename (note that there is no space between -p and PASSWORD)
    • To restore the database from the backup – mysql -u username -p dbname < filename
Personal tools