Technology blog::Life hacks::Linux::Hardware::Gaming

Apache Administration on Linux

Get that web server working!

By , Written on in Linux

Apache Administration on Linux

398 words, estimated reading time 2 minutes.

A few quick tips and cheat sheets for administering apache on a Linux server.
 
Introduction to Linux Series
  1. Linux Tips for Beginners
  2. Beginners guide to Reading and Finding Files in Linux
  3. Using Grep to Search for Text in Linux
  4. Understanding Linux File Permissions
  5. How to Archive, Compress and Extract files in Linux
  6. Linux Piping and Redirection
  7. Linux Hardlinks and Softlinks
  8. Basic Data Recovery in Linux
  9. Essential Guide to Working with Files in Linux
  10. Apache Administration on Linux
  11. MySql Administration on Linux

Restart Apache on Linux

You can restart the Apache web server by entering the following command:

sudo /etc/init.d/apache2 restart

 

Change the Apache DocumentRoot

Website configs are stored within /etc/apache2/sites-available/ and a symbolic link is created within /etc/apache2/sites-enabled. Generally you store all your website configs in sites-available and create/remove links in sites-enabled as required.

sudo pico /etc/apache2/sites-available/default

Change the document root (default is /var/www)

Restart Apache for changes to take effect.

 

Adding Virtual Hosts

To add virtual hosts to Apache, all you need to do is create a config in /etc/apache2/sites-available/.

The config files should look similar to this:

<VirtualHost 192.168.0.5>>
        ServerName virtual.hostname.com
        DocumentRoot /usr/www/path/to/files
</VirtualHost>

To enable the new site run:

sudo a2ensite <config name>

To disable a site run:

sudo a2dissite <config name>

The next thing to do is to enable virtual hosts in your Apache configuration. The simplest way to do this is to create a file called /etc/apache2/conf.d/virtual.conf and include the following content in it:

#
#  We're running multiple virtual hosts.
#
NameVirtualHost *

 

Enable mod_headers on Apache

For customization of HTTP request and response headers, you should enable mod_headers on Apache.

sudo a2enmod headers

 

Increase PHP File Upload Size

The default PHP installation will restrict you to a maximum of 2 MB however there are many instances this needs to be increased. This can be done by modifying the PHP.ini file.

sudo pico /etc/php5/apache2/php.ini

There are two settings to be changed. Locate and modify the following lines.

upload_max_filesize = 2M
post_max_size = 8M

You will need to restart Apache for changes to take effect.

 

Installing Xdebug

The Xdebug extension helps you debugging your script by providing a lot of valuable debug information.

This can be quickly installed in Ubuntu using the following command:

sudo aptitude install php5-xdebug

You can verify successful installation by calling:

php -v

If successful you should see something like the following:

PHP 5.3.2-1ubuntu4.2 with Suhosin-Patch (cli) (built: May 13 2010 20:01:00)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with Xdebug v2.0.5, Copyright (c) 2002-2008, by Derick Rethans

For more information, please see this article which also covers using XDebug to analyse PHP performance.

Last updated on: Saturday 17th June 2017

Did you Like this Post? Why not Like us on Facebook?

 

Further Reading
Comments

There are no comments for this post. Be the first!

Leave a Reply

Your email address will not be published.