Technology Bites

  • Home
  • Tech
    • Software
    • Browsers
    • Google
    • Internet
    • Windows
  • Mobile
    • Android
    • Apple
    • Windows Phone
  • Products
    • Phones
    • Tablets
  • TIP US
You are here: Home / Software / Installing Apache webserver on Ubuntu VPS

Installing Apache webserver on Ubuntu VPS

The next step after setting up and securing VPS server is installing the software stack that is required for hosting websites. I am going to install Apache as web server, you can follow or install Nginx.

Installing Apache is easy just enter the below command. I have disabled root login and using a user account with admin privileges to manage server, that is why sudo is appended in the command line. If you are using root login then don’t enter sudo.

[shell]sudo apt-get install apache2[/shell]

After installing Apache you need to change some settings for better performance. Apache2 configuration is stored in apache2.conf file, previous apache versions used httpd.conf as config file, that is deprecated in apache2.

Open apache config file for editing with the following command.

[shell]sudo nano /etc/apache2/apache2.conf[/shell]

You need to change the values for MinSpareServers, MaxSpareServers, MaxClients and MaxRequestserChild according to your needs as a starter. Alternatively you can use .htaccess files to override apache configuration directives.

After you are done save changes to the file by pressing Ctrl + X and pressing Y.

Restart Apache for the change in settings to take effect.

[shell]sudo service apache2 restart[/shell]

Next you need to create directories for hosting files and need to create vhost files for domain names. We will see that later.

vhosts files can be created with the following command

[shell]sudo nano /etc/apache2/sites-available/example.com[/shell]

A typical vhost file for individual domains will look like this. Change the directory paths to domain name to reflect your setup.

[shell]# domain: mydoamin.com
# public: /var/www/hosts/mydomain.com/htdocs


# Admin email, Server Name (domain name), and any aliases
ServerAdmin webmaster@mydomain.com
ServerName www.mydomain.com
ServerAlias mydomain.com

# Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php
DocumentRoot /var/www/hosts/mydomain.com/htdocs

# Log file locations
LogLevel warn
ErrorLog /var/www/hosts/mydomain.com/log/error.log
CustomLog /var/www/hosts/mydomain.com/log/access.log combined
[/shell]

After creating the file save with Ctrl+x and by pressing y.

Now enable the site using this command

[shell]sudo a2ensite mydomain.com[/shell]

Restart apache for the changes to take effect.

Other articles in this series

Dedicated VPS Server with Linode
How to install PHP and APC on Ubuntu VPS
Useful .htaccess tips and tricks

Share this:

  • Tweet

Related

About Ram

I am a blogger and Technology Enthusiast. I write about software, tech news, gadgets. You can reach me at ram@teknobites.com, follow me on Google+ or on Twitter

« Shorter URLs for SkyDrive files with bit.ly support
Samsung received 9 million pre orders for Galaxy S III »

Trackbacks

  1. Links 19/5/2012: Mandriva Linux Freed, New Linux Mint RC | Techrights says:
    May 19, 2012 at 3:44 pm

    […] Installing Apache webserver on Ubuntu VPS […]

  2. Installing Apache webserver on Ubuntu VPS | bender says:
    May 27, 2012 at 3:29 am

    […] The next step after setting up and securing VPS server is installing the software stack that is required for hosting websites. I am going to install Apache as web server, you can follow or install Nginx. Read more here […]

  3. How to install PHP and APC on Ubuntu VPS • Technology Bites says:
    June 19, 2012 at 12:10 pm

    […] VPS Server with Linode Installing Apache webserver on Ubuntu VPS Useful .htaccess tips and […]

Top Posts

  • Sync Flickr Photos with Local Folders
  • MSN launches new home page
  • Yahoo new home pages and how to get back to the old home page
  • Razr M Launcher + Circle Widgets for ALL Android Devices (ICS/JB)
  • Microsoft PDF Plugin for Office 2007
  • HTC M8 might come in late March with on-screen buttons
  • Microsoft tool makes it easy to move from Evernote to OneNote
  • Amazon launches Prime Video service in India
  • Lenovo Smart Band HW01 with OLED display launched at Rs 1999
  • Contact

About Us · Archive · Disclaimer & Privacy Policy · TIP US · Copyright © 2025 · Technology Bites