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.

sudo apt-get install apache2

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.

sudo nano /etc/apache2/apache2.conf

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.

sudo service apache2 restart

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

sudo nano /etc/apache2/sites-available/example.com

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

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

<VirtualHost *:80>
  # 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
</VirtualHost>

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

Now enable the site using this command

sudo a2ensite mydomain.com

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

Comment Using Facebook

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 […]

Fusion Gear Designer Cases

Top Posts

  • Yahoo new home pages and how to get back to the old home page
  • How to Download Google Chrome on Win 2K
  • Recover deleted files with Pandora Recovery

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