Ubuntu Apache Virtual Host Configuration
Unlike Apache in Windows, there is usually only one configuration file, namely httpd. conf.
The local environment uses apt-get install xxx
In Linux, the configuration file of Apache is/etc/apache2/apache2.conf. Apache automatically reads the configuration information of this file at startup. Some other configuration files, such as httpd. conf, are included through the Include command.
There is the sites-enabled directory in apache2.conf, and there is a sites-available directory under/etc/apache2. In fact, this is the real configuration file, the sites-enabled directory stores only symbolic links to the files here. You can use ls/etc/apache2/sites-enabled/to confirm it.
Therefore, if multiple virtual hosts are configured on apache and the configuration files of each virtual host are stored in sites-available, it is very convenient to disable and enable the Virtual Host: when a link is established under sites-enabled to a virtual host configuration file, it is enabled. To disable a virtual host, you only need to delete the corresponding link, you do not need to modify the configuration file.
1. sudo cp/etc/apache2/sites-avaliable/000-default.conf, named test. conf
2. modify the configuration file: test. conf.
<VirtualHost *: 80>
# The ServerName directive sets the request scheme, hostname and port that
# The server uses to identify itself. This is used when creating
# Redirection URLs. In the context of virtual hosts, the ServerName
# Specifies what hostname must appear in the request's Host: header
# Match this virtual host. For the default virtual host (this file) this
# Value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName www.test.com
ServerAdmin webmaster @ localhost
DocumentRoot/var/www/html/test/
ErrorLog/var/www/html/test/error. log
CustomLog/var/www/html/test/access. log combined
<Directory "/var/www/html/test">
Options FollowSymLinks
DirectoryIndex index. php index.html index.htm
AllowOverride All # note that the configuration in this place will affect the enabling of. htaccess in the local directory.
Order deny, allow
Allow from All
</Directory>
# Available loglevels: trace8,..., trace1, debug, info, notice, warn,
# Error, crit, alert, emerg.
# It is also possible to configure the loglevel for Particle
# Modules, e.g.
# LogLevel info ssl: warn
# For most configuration files from conf-available/, which are
# Enabled or disabled at a global level, it is possible
# Include a line for only one participant virtual host. For example
# Following line enables the CGI configuration for this host only
# After it has been globally disabled with "a2disconf ".
# Include conf-available/serve-cgi-bin.conf
</VirtualHost>
3. Create a link file:
Sudo ln-s/etc/apache2/sites-available/test. conf/etc/apache2/sites-enabled/test. conf
Or: sudo a2ensite test. conf
4. Restart the apache server
Sudo/etc/init. d/apache2 restart
5. Modify hosts (/etc/hosts)
Add 127.0.0.1 www.test.com
Access is basically normal here!
Note: If you still need to support directory-level URL rewriting, continue:
1. Terminal Operation
Sudo a2enmod
The program prompts the name of the module that can be activated. Enter: rewrite
If rewrite already load is returned
2. Modify/etc/apache2/sites-enabled/test. conf (the link points to the site configuration file)
Change the AllowOverride attribute to All and save it. (We have configured All above)
3. Reload apache
Sudo/etc/init. d/apache2 restart
Install a Web Server on Ubuntu Server 14.04 (Linux + Apache + MySQL + PHP)
Install and configure the PHP environment in Linux (Apache2)
Install the LAMP \ Vsftpd \ Webmin \ phpMyAdmin service and settings in Ubuntu 13.04
Compile and install LAMP in CentOS 5.9 (Apache 2.2.44 + MySQL 5.6.10 + PHP 5.4.12)
Source code for Web server architecture in RedHat 5.4 build the LAMP environment and application PHPWind
Apache details: click here
Apache: click here