Jump to content
Aerosol

Apache Web server - installation and configuration

Recommended Posts

Apache HTTP server is one of the most popular web servers today. It's free and open-source, and can be run on most modern operating systems, unix and linux like. Also, there's a version for Windows and other platforms. It has a lot of different features that make it very extensible and useful for many different types of websites. It can be used for personal web pages and also for large enterprise sites.

Apache Web Server is often used in combination with the database engine like MySQL, the HyperText Preprocessor (PHP) or some other scripting language like Python or Perl. This is often called LAMP wich means (Linux, Apache, MySQL and PHP) and offers a powerful platform for development and deployment of Web-based applications.

Install apache with apt-get

To install apache2 web server, You can simply use apt-get packet manager. To do this You will also need access to your root account.

LinuxBox# sudo apt-get install apache2
[sudo] Password for root:
.
.
After this operation, 10MB of additional disk space will be used.
Do You want to continue [Y/n]?

( That's it ! )

Apache Configuration

By default all configuration files can be found under /etc/apache2. The default Apache2 configuration file is /etc/apache2/apache2.conf. You can configure the port number, document root, modules, log files, virtual hosts, etc.

To change default Document root, simply edit the “DocumentRoot /var/www/” line in /etc/apache2/sites-available/default file. This tels the Apache where to look for files that make the site. If want to change root document to /home/myuser/www, write the line “DocumentRoot /home/myuser/www/”:

LinuxBox# vi /etc/apache2/sites-available/default
<VirtualHost *:80>
ServerAdmin webmaster@localhost

DocumentRoot /home/myuser/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options -Indexes FollowSymLinks MultiViews -Includes
AllowOverride None
Order allow,deny
allow from all
</Directory>

Virtual Hosts

Virtual Hosting is method for hosting multiple domain names on a single web server. By default, apache is configured with a single "defult" virtual host which can be used as as a template for additional virtual hosts if you have multiple sites on server.

To modify the default virtual host, edit the file /etc/apache2/sites-available/default. If you wish to configure a new virtual host or site, copy that file into the same directory with a name you choose and Edit the new file:

LinuxBox# cp /etc/apache2/sites-available/default /etc/apache2/sites-available/mynewsite

Change Listening port

To change the TCP port on which web server is listening, edit "<VirtualHost *:80>" directive, and replace 80 with new port number of Your choice (for example 81). Also, desired port have to be changed in /etc/apache2/ports.conf file:

LinuxBox# vi /etc/apache2/ports.conf
NameVirtualHost *:81
Listen 81

<IfModule mod_ssl.c>
# If you add NameVirtualHost *:443 here, you will also have to change
# the VirtualHost statement in /etc/apache2/sites-available/default-ssl
# to <VirtualHost *:443>
# Server Name Indication for SSL named virtual hosts is currently not
# supported by MSIE on Windows XP.
Listen 443
</IfModule>

<IfModule mod_gnutls.c>
Listen 443
</IfModule>

LinuxBox#

Enable/disable virtual Host (site)

After editing virtual Host file, to enable the specific site, simple use a2ensite with the site name:

LinuxBox# a2ensite default
Enabling site default.
Run '/etc/init.d/apache2 reload' to activate new configuration!
LinuxBox#

( To disable the site, use a2dissite the same way as "a2ensite" command )

Restart Apache

After editing configuration files, don't forget to restart apache so new configuration can take effect:

LinuxBox# /etc/init.d/apache2 restart
Restarting web server: apache2 ... waiting .
LinuxBox#

(Apache can be also restarted with /etc/init.d/apache2 stop or /etc/init.d/apache2 start)

Source

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...