Installing Apache in Ubuntu
Installation instructions: sudo apt-get install apache2
After the installation is complete:
The resulting start and stop files are:/etc/init.d/apache2
Start: sudo apache2ctl-k start
Stop: sudo apache2ctl-k stop
Restart: sudo apache2ctl-k restart
Config file is present:/etc/apache2
It should be stated that the generic Apache Release configuration file is:
httpd.conf
The main configuration file for the Ubuntu release is:
Apache2.conf
The following files are referenced in apache2.conf:
# contains the configuration of the dynamic module:
Include/etc/apache2/mods-enabled/*.load
Include/etc/apache2/mods-enabled/*.conf
# contains the user's own configuration:
Include/etc/apache2/httpd.conf
# contains the configuration of the Port listener:
Include/etc/apache2/ports.conf
# contains a generic configuration statement fragment:
include/etc/apache2/conf.d/
# contains the configuration directives for the virtual host:
include/etc/apache2/sites-enabled/
Modify Httpd.conf
Add the following content:
ServerName 127.0.0.1:80
Ubuntu apache2 Configuration
1.apache2.conf is the master configuration file, httpd.conf user profile
2. Virtual Directory in httpd.conf
<VirtualHost *>
DocumentRoot "path"
ServerName name
<Directory "path"> allow from all Options +Indexes </Directory>
</VirtualHost>
3. Root settings (default home directory) in/etc/apache2/sites-available/default
4. Restart command
Sudo /etc/init.d/apache2 restartOr
Cd /etc/init.d
Sudo apache2 -k restart
Stop stop; start start 5. log files in/var/log/apache2/
<virtualhost *:80>
ServerName www.kimoqi.com
Documentroot/home/vsftpd/kimoqi
</VirtualHost>
<virtualhost *:80>
ServerName www.arwenedu.com
Documentroot/home/vsftpd/wangguan/webapps
</VirtualHost>
<virtualhost *:80>
ServerName www.arwenedu.org.cn
Documentroot/home/vsftpd/wangguan/chem
</VirtualHost>
Vi/etc/httpd/conf/httpd.conf
Under Windows, Apache usually has only one configuration file, which is httpd.conf. But after I installed the Apache2 with the Apt-getinstallapache2 command on Ubuntu Linux, I found that its httpd.conf (located in the/etc/apache2 directory) was empty! And then found that the Ubuntu Apache software package configuration file is not as simple as windows, it put the individual settings in different configuration files, look complex, but think carefully about the design is really reasonable.
Strictly speaking, Ubuntu Apache (or should say Linux under the Apache?) I am not sure that the configuration file for other distributions of the Apache package is that/etc/apache2/apache2.conf,apache automatically reads the configuration information for this file at startup. Some other configuration files, such as httpd.conf, are included through the include directive. These include lines can be found in apache2.conf:
Reference
# Include Module Configuration:
Include/etc/apache2/mods-enabled/*.load
Include/etc/apache2/mods-enabled/*.conf
# Include All the user configurations:
Include/etc/apache2/httpd.conf
# Include Ports Listing
Include/etc/apache2/ports.conf
......
# Include Generic snippets of statements
include/etc/apache2/conf.d/
# Include The virtual host configurations:
include/etc/apache2/sites-enabled/
Combined with annotations, you can clearly see the general effect of each configuration file. Of course, you can put all the settings in apache2.conf or httpd.conf or any configuration file. This division of Apache2 is only a good habit.
One of the most important things to do after installing Apache is to know where the Web document root directory is, and for Ubuntu, the default is/var/www. How do you know that? There is no documentroot in apache2.conf, httpd.conf is empty, so it must be in other files. After searching, found in the/etc/apache2/sites-enabled/000-default, there is such content:
Reference
Namevirtualhost *
<virtualhost *>
ServerAdmin [email protected]
documentroot/var/www/
......
This is setting up the virtual host, which means nothing to me. So I put the apache2.conf in the include/etc/apache2/sites-enabled/line commented out, and in httpd.conf set documentroot for my user directory under a directory, so as to facilitate the development.
And look at what's in the/etc/apache2 directory. Just found in the apache2.conf sites-enabled directory, and/etc/apache2 under a sites-available directory, what is put in it? In fact, this is the real configuration file, and the sites-enabled directory is just some of the files pointing to the symbolic link 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.
Mods-available, mods-enabled, and the above-mentioned sites-available, sites-enabled, these two directories are the configuration files and links that store the Apache function module. When I installed the PHP module with Apt-get installphp5, 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.
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. Or if you think it is superfluous, you can first remove the include/etc/apache2/ports.conf line in the apache2.conf and set the Apache port in the httpd.conf.
The default installed directory structure in Ubuntu is a bit different. In Ubuntu, the module and VirtualHost configuration has two directories, one is the 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.
-
- <virtualhost *>
-
- ServerName Domain Name
-
-
-
- DocumentRoot the public in the Rails project as the root directory
-
- <directory Public root directory >
-
- Options execcgi FollowSymLinks
-
- AllowOverride All
-
- Allow from all
-
- Order Allow,deny
-
- </Directory>
-
- errorlog/var/log/apache2/error-domain name. log
-
- </VirtualHost>
For further configuration and use, you can consult the Apache manual.
Apache Configuration file httpd.conf description
DocumentRoot "/var/www/html" ---Apache default server home directory path
directoryindex index.html index.htm index.php index.html.var ---Default document, separated by spaces between multiple files
Listen 192.168.1.1:80 Setting the listening IP is 192.168.1.1 address and port is 80
Listen 192.168.1.2:8080 Setting the listening IP is 192.168.1.2 address and port is 8080
serverroot "/ETC/HTTPD" sets the path relative to the root directory, usually where the configuration and log files are stored. The default is:/ETC/HTTPD typically includes conf and logs subdirectories
errorlog logs/error_log Setting error log Note: If the log file storage path does not start with "/", it means that the file is relative to the ServerRoot directory
customlog logs/access_log Combined access log (combined indicates the format used by the log and common format)
ServerAdmin [email protected] set up the network administrator's email-when the client server error occurs, the server will usually return to the client Error prompt page, in order to facilitate the resolution of the error, this page usually has an administrator's email address, you can use the Serv Eradmin statement to set the administrator's email address
ServerName www.iigoogle.com:80 Set the server host name (if a domain name can be filled in the domain name, no domain name can be filled in the server IP address)
Adddefaultcharset GB2312 Sets the default character set and defines the default character set that the server returns to the client (since Western Europe UTF-8 is the Apache default character set, so garbled when accessing a Chinese-language web page, as long as the character set is changed to GB2 312, then restart Apache service)
alias/down "/software/download" creates a virtual directory (creates a virtual directory named down, which corresponds to a physical path of:/software/download)
Alias/ftp "/var/ftp" to create the virtual directory (create a virtual directory named FTP, which corresponds to the physical path is:/var/ftp)
<directory "/var/www/html" > set directory Permissions (<directory "directory path" > This write statement to set directory permissions </Directory>)
Options FollowSymLinks page:116
AllowOverride None
</Directory>
Domain-based virtual host
namevirtualhost 220.123.55.99---First use the namevirtualhost directive to specify which IP address is responsible for responding to requests to the virtual host
<virtualhostwww.iigoogle.com>
ServerNamewww.iigoogle.com:80
ServerAdmin[email protected]
Documentroot/www/docs/iigoogle
DirectoryIndex index.jsp
Errorlog Logs/www/iigoogle/error_log
Customlog Logs/www/iigoogle/access_log Common
</VirtualHost>
Another way of writing
Namevirtualhost 220.123.55.99:80
<virtualhost www.iigoogle.com:80>
ServerName www.iigoogle.com
ServerAdmin[email protected]
Documentroot/www/docs/iigoogle.com
Errorlog Logs/www/iigoogle/error_log
Customlog Logs/www/iigoogle/access_log Common
</VirtualHost>
Transferred from: http://www.blogjava.net/duanzhimin528/archive/2010/03/05/314564.html
Ubuntu Configuration Apache2