The configuration process of apache2 under Ubuntu

Source: Internet
Author: User
Tags hosting web hosting

1. What is virtual Hosting (web hosting)?
Simply put, the same server can handle more than one domain name at a time. Assuming that both www.example1.net and www.example2.net have two domain names pointing to the same server, and the Web server supports virtual Hosting, Then www.example1.net and www.example2.net can access different web spaces on the same server (the site file directory).

Apache2 software supports virtual hosts.

2. apache2 Key configuration file location

(1) Master configuration file

Under Windows, Apache usually has only one configuration file, which is httpd.conf.

After installing Apache2 with the Apt-get install apache2 command on Ubuntu Linux, its configuration file is:/etc/apache2/apache2.conf,apache automatically reads the configuration information for this file when it is started.

(2) Virtual directory Web document root directory

For Ubuntu, the default is/var/www. In/etc/apache2/sites-enabled/000-default configuration

ServerName: The requested domain name

Documentroot:web the root directory of the document

<VirtualHost*: Custom Port># after ServerName add your site name ServerName www.linyupark.com # If you want to have multiple site names to get the same site, you can add the Serveralias after adding other    Site aliases.  # aliases are separated by a space.    Serveralias ftp.linyupark.com mail.linyupark.com # after serveradmin with the webmaster's email address, to facilitate others have the problem is to contact the webmaster. ServerAdmin [email protected] # Add a directory path (user's personal directory) to the content of the site after DocumentRoot documentroot/home/linyupark/publi c_html       <Directory/home/linyupark/public_html>Options Indexes followsymlinks multiviews allowoverride None Order allow,deny allow from all</Directory>scriptalias/cgi-bin//usr/lib/cgi-bin/<Directory"/usr/lib/cgi-bin">allowoverride None Options execcgi-multiviews +symlinksifownermatch allow from all</Directory> errorlog/home/linyupark/public_html/error.log # Possible values Include:debug, info, notice, warn, error,  Crit, # Alert, Emerg. LogLevel warn Customlog/home/linyupark/public_html/access.log combined serversignature    on</VirtualHost>
3. Site information configuration file

Sites-available directory, sites-enabled directory.

The real configuration file is the Sites-available directory. And the sites-enabled directory is just some symbolic link to the file here, you can use ls/etc/apache2/sites-enabled/to confirm. Therefore, if more than one virtual host is configured on Apache, and the configuration file of each virtual host is placed under Sites-available, it is very convenient for the virtual host to be deactivated and enabled: When a link to a virtual host profile is established under sites-enabled , it is enabled, and if you want to turn off a virtual host, simply delete the link and not change the configuration file at all.

Note: The default installed directory structure in Ubuntu is a bit different. In Ubuntu, the module and virtual host configuration has two directories, one is available, one is the enabled,available directory is a valid content, but it does not work, only with LN to enable the past can work. It is easy to use for debugging, but if you do not know beforehand, it is a bit troublesome to find it. /etc/apache2/sites-available is in the VH configuration, but it does not work, to link the file to the sites-enabled directory.

4. Module configuration

Mods-available, mods-enabled and the above said Sites-available, sites-enabled similar.

These two directories are the configuration files and links that hold the Apache function module. When I installed the PHP module with apt-get install PHP5, there were php5.load, php5.conf, and links to the two files in both directories. This catalog result is very handy for enabling and deactivating an Apache module.

5. Port configuration file

The last one to say is ports.conf, which sets the port that Apache uses. If you need to adjust the default port settings, it is recommended that you edit this file.

6. Configure the operation

The previously configured content is only "effective" virtual host, the actual effect of the words must be placed under the/etc/apache2/sites-enabled folder. We can use the LN command to create a pair of associated files:

sudo ln-s/etc/apache2/sites-available/linyupark/etc/apache2/sites-enabled/linyupark

Use the file location to create a "" "link Asking price" to activate a valid configuration file.

7. Check the syntax and restart the Web service

As a precaution, we check the syntax before restarting the service:

sudo apache2ctl configtest

If there are no errors, then restart Apache.

1. Sudo/etc/init.d/apache2-k Restart
2. or service apache2 restart
8. View Effects

On the host (Win7 system) in the change of the host table is OK. The address is:

Windows/system32/drivers/etc

Open and add a sentence:

192.168.1.22 www.linyupark.com

The effect is that the browser input www.linyupark.com will go directly to the IP 192.168.1.22 server to receive the request, see if there is a compatible virtual host domain name, some words to the corresponding directory of the Web file to the requesting user


  

The configuration process of apache2 under Ubuntu

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.