How would you like to host your own web server right in your home using the same technology the pro’s use without paying one red cent! A dedicated server usually starts around $200 per month, but this step by step guide to installing your own dedicated server won’t cost you a cent, all you need is a old 1GHz or greater PC with 5GB of hard drive space (Flash Drives have that standard now), 512 Mib memory and a monitor resolution of 1024×768.

I installed the desktop version of Ubuntu, if you install the server version you would only need half of everything mentioned above, but I like the Desktop version (so will you).

If you’re not familiar with Ubuntu, then you’re going to love this! It can not only serve your websites, but runs a lot like Windows on the front end and comes complete with Open Office (a Microsoft Office look alike without the cost). The big difference between hosting your own site at home and paying for it, is that you don’t have the support staff, high speed connection and the guaranteed up-time – all items you need if you have a big website. Here is an excellent review of Peer1’s dedicated web server hosting which I use for a number of large sites.

When your finished with this guide, you’ll have installed a full fledged web server that can host any number of websites! I just put this together and wanted to get it up (more as a reminder to myself) and will refine it in the weeks to come – Although it’s complete right now, it’s more like an outline with notes rather than a polished guide, so bear with me.

In Windows, you have a DOS prompt (command prompt), in Ubuntu 10.10, you have a terminal window. When you run a command that requires root access (super user), you’ll get an error unless you add ‘sudo’ before the command, so keep this in mind – there are ways to turn this off, but it’s like this to protect you and disabling it can cause you problems down the road!

When you want to browse files (like file manager) and edit them, open up a terminal window and type in this command:

gksudo nautilus

If you don’t, you’ll get permission errors as you try to edit files!

Download the desktop version of Ubuntu 10.10 or Server, I used Desktop for this.

It’s a large file called an ISO image and will take awhile to finish – when it does, you’ll right click the file and choose ‘burn to cd / dvd’ – if you don’t have a DVD/CD recorder in your pc, you’ll need to download it from a computer that does have one.

Once you have created the disk, put it in the computer you want to FORMAT – NOTE, you’re going to blow away everything on the computer your using for the web server, so make sure you have saved any data you need BEFORE installing Ubuntu 10.10.

The install is straight forward and I don’t have docs right now, but will get this up as I have time. Just go along with all the defaults and you’ll be all set. Once you have Ubuntu 10.10 installed, take a few minutes and play around – you can’t hurt anything and you’ll love what you see!

Okay, time to install all the extra software to get your webserver up and running, such as MySQL, Firewall and FTP.

When you were playing around, did you notice the Software Center from the drop down menu? Take a look now, that is what you are going to use to install and uninstall applications. Warning, there are so many to choose from so resist the temptation and stick with what I have listed below – there will be plenty of time to install apps later.

Install GUFW (Firewall configuration – allows you to configure the UFW Firewall) – you don’t need to turn it on right now, just install it.

Install MySQL Server from the Ubuntu Software Center

Install the MySQL web administration tool phpmyadmin

Install php-gd (Graphics Library) if not installed

Install ProFTPD for file transfers
BTW: If a web directory doesn’t have permissions right, you can set them with:
sudo chmod -R 755 directory-name/

Visit
Check out the first section of Ubuntu’s installation guide and read the first part but make sure to CHANGE the default port in the default file in the etc/apache2/site-available to 81 from 80 if you want to run multiple sites on one IP address. (like this: ) – I need to refine this part…

In your new file (named after your website without the www) or the default file, make sure you have the top part looking like this:

< / virtualhost>< virtualhost *:80>
ServerAdmin youremail@somesite.com

DocumentRoot /var/www/website.com
ServerName website.com
ServerAlias *.website.com

Options FollowSymLinks
AllowOverride None
—-

Here is my complete file:

< virtualhost *:80>
ServerAdmin youremail@somesite.com

DocumentRoot /var/www/website.com
ServerName website.com
ServerAlias *.website.com

Options FollowSymLinks
AllowOverride None

Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all

ErrorLog ${APACHE_LOG_DIR}/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined

Alias /doc/ “/usr/share/doc/”

Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128

 

Notice the AllowOverride is set to all?

If you don’t change this, then wordpress permalinks will not work with Ubuntu and Apache2. Also, your .htaccess file won’t work should you create one. Note that if you are changing the default file, you need to restart Apache (easy to forget!).

If you still have a problem with WordPress Permalinks no working, then make sure you have the mod-rewrite module installed:
sudo apache2ctl -M
the command above gives you a listing of modules installed

sudo ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load
The command above loads the module.

Set firewall to block everything except ftp and web: port 80 and port 21 by going into System, Admin, Firewall Configuration, Click on Enabled, Add, Preconfigured – Allow, In, Service, then HTTP and FTP.

Hey, if a site is not working and you think you have everything all set – this happened to me – then issue this command from the terminal:
sudo a2dissite site-thats-not-working
then restart apache2 with this:
sudo /etc/init.d/apache2 restart

then issue
sudo a2ensite site-thats-not-working

and see if an error pops up and if so, fix the etc/apache2/site-available/site-thats-not-working file, then type:
sudo /etc/init.d/apache2 restart

If you forget your WordPress password, you can choose lost password when you’re logging into your site and the system will send it to you, however, if you receive this message:

The e-mail could not be sent.
Possible reason: your host may have disabled the mail() function…

Then you need to install postfix from a terminal window using this command:

sudo apt-get install postfix

Here is my answers to the prompt you’ll receive:

  • General type of mail configuration: Internet Site
  • NONE doesn’t appear to be requested in current config
  • System mail name: server1.example.com
  • Root and postmaster mail recipient:
  • Other destinations for mail: server1.example.com, example.com, localhost.example.com, localhost
  • Force synchronous updates on mail queue?: No
  • Local networks: 127.0.0.0/8
  • Yes doesn’t appear to be requested in current config
  • Mailbox size limit (bytes): 0
  • Local address extension character: +
  • Internet protocols to use: all

If you need to make changes after you have installed the program, simply enter this command in a terminal window:

sudo dpkg-reconfigure postfix

MySQL error? Let me know. Note: possible fix is: session.save_path = “/tmp” in php.ini?

That’s it for now, as I mentioned before, I’ll refine this more as time permits.

4 replies
  1. Jim says:

    Note: I didn’t need to change permissions as mentioned above on my Ubuntu.

    Some plugins may need this, so if you get an error like:
    “requires the function ‘curl_init’ in order to function properly.”
    then issue this command from a terminal window:
    sudo apt-get install php5-curl
    or
    install it using the Ubuntu Software Center and search for CURL module for php5 php5-curl

    Don’t forget to restart Apache2!

  2. Sieed says:

    FYI on fixing any permission issues,
    cd /home/www
    sudo chown -R nobody:nobody yoursite.com
    sudo chown -R www-data:www-data yoursite.com/wp-content
    sudo chmod 775 yoursite.com/wp-content/plugins
    sudo chmod 775 yoursite.com/wp-content/themes

    Note that when you install plugins to wp-content/plugins as a www-data user you may need to change the permissions so you made modification through the WordPress control panel:
    chown -R apache:wheel yoursite.com/wp-content

  3. WPMU says:

    This my default file mod:

    ServerName wp.localhost
    ServerAlias *.wp.localhost
    ServerAlias …………..
    DocumentRoot /var/www/localhost/test/wpmu/

    ErrorLog …
    LogLevel …
    CustomLog …

    SuexecUserGroup …
    Options +ExecCGI
    AddHandler fcgid-script .php
    FCGIWrapper … .php

    RewriteEngine On
    AllowOverride None

    # BEGIN WPSuperCache

    AddDefaultCharset UTF-8

    RewriteRule ^(.*) “/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html” [L]

    # END WPSuperCache

    # BEGIN WordPress
    RewriteRule ^index\.php$ – [L]

    RewriteRule . index.php [L]
    # END WordPress

    RewriteEngine On
    AllowOverride None

    # BEGIN supercache

    # END supercache

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *