- Installing Linux Step by Step
- Linux Tips for Beginners
- Beginners guide to Reading and Finding Files in Linux
- Using Grep to Search for Text in Linux
- Understanding Linux File Permissions
- How to Archive, Compress and Extract files in Linux
- Linux Piping and Redirection
- Linux Hardlinks and Softlinks
- Basic Data Recovery in Linux
- Apache Administration on Linux
- MySql Administration on Linux
- Switching from Windows to 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.
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:
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.