Install 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:
Stop it:
Reboot:
sudo apache2ctl-k restart
Configuration file Guaranteed:/etc/apache2
What you need to note is 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 configuration directives for virtual hosts:
include/etc/apache2/sites-enabled/
Modify Httpd.conf
Add the following:
Ubuntu apache2 Configuration
1.apache2.conf is the primary 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 restart or
cd/etc/init.d
sudo apache2-k restart
Stop stopping; 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's configuration file is usually only one, which is httpd.conf. But when I installed Apache2 with the Apt-get install apache2 command on Ubuntu Linux, I found that httpd.conf (located in the/etc/apache2 directory) was empty! It turns out that the configuration file for Ubuntu's Apache software package is not as simple as windows, and that it looks complicated by splitting the settings into different profiles, but it's really reasonable to think about the design.
Strictly speaking, Ubuntu Apache (or should I say Apache under Linux)? I am not sure that the configuration file for other distributions of the Apache package is/etc/apache2/apache2.conf,apache to automatically read the configuration information for this file at startup. 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 overall 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.
The most important thing after you install 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 the apache2.conf, httpd.conf is empty, so it must be in the other files. After the search, found in the/etc/apache2/sites-enabled/000-default, there is such content:
Reference
Namevirtualhost *
<virtualhost *>
ServerAdmin webmaster@localhost
documentroot/var/www/
...
This is set up a virtual host, it doesn't make sense to me. So I commented out the include/etc/apache2/sites-enabled/line in apache2.conf, and in httpd.conf I set DocumentRoot to a directory in my user directory so it was easy to develop.
And look at what's in the/etc/apache2 catalogue. Just now found in the apache2.conf sites-enabled directory, and under/etc/apache2 there is a sites-available directory, which is put what? In fact, this is the real configuration file, and the sites-enabled directory to store just a few points to the file here the symbolic link, you can use ls/etc/apache2/sites-enabled/to confirm. So, if you have more than one virtual host configured on Apache, each virtual host's configuration file is placed under Sites-available, so it is very convenient to disable and enable the virtual host: When creating a link to a virtual host profile under Sites-enabled , it is enabled, if you want to shut down a virtual host, simply delete the corresponding link, you do not have to change the configuration file.
Mods-available, mods-enabled and the above sites-available, sites-enabled similar, the two directories are stored in the Apache function module configuration files and links. When I installed the PHP module with apt-get install PHP5, I had php5.load, php5.conf, and links to these two files in both directories. This catalog result is very handy for enabling and deactivating a certain Apache module.
The last one to say is ports.conf, which sets the port used by Apache. If you need to adjust the default port settings, it is recommended that you edit this file. Or you think it is superfluous, you can first apache2.conf in the include/etc/apache2/ports.conf line out, in the httpd.conf set Apache port.
The default installed directory structure in Ubuntu is a little different. The configuration of module and virtual host in Ubuntu has two directories, one is available, the other is enabled,available directory is stored valid content, but does not work, only use LN to enable the past can function. It's easy to use for debugging, but if you don't know beforehand, it's a bit of a hassle to find.
/etc/apache2/sites-available is placed in the VH configuration, but does not work, to the file link to the sites-enabled directory.
<virtualhost *>
ServerName domain
documentroot to take public in rails project as root
<directory public root directory >
Options execcgi followsymlinks
allowoverride all
allow to order
Allow,deny
</Directory>
errorlog/var/log/apache2/error-domain log
</VirtualHost>
For further configuration and use, you can access 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 documents, separated by spaces between multiple files
Listen 192.168.1.1:80 Setting Listener IP is 192.168.1.1 address and port is 80
Listen 192.168.1.2:8080 Setting Listener IP is 192.168.1.2 address and port is 8080
ServerRoot "/ETC/HTTPD" sets the path to the root directory, usually the location where the configuration files and log files are stored. The default is:/ETC/HTTPD typically includes the Conf and logs subdirectories
ErrorLog Logs/error_log Set Error log Note: If the log file store 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, as well as common format)
ServerAdmin lindenstar@163.com set up network administrator Email-When an error occurs on the client server, the server usually returns the error page to the client, which, in order to facilitate resolution of the error, usually has an email address of the administrator, which can be used ServerAdmin statement to set the administrator's email address
ServerName www.iigoogle.com:80 Set Server host name (if a domain name can be filled in domain name, no domain name can be filled into the server IP address)
Adddefaultcharset GB2312 Set the default character set, define the server to return to the client default character set (because Western European UTF-8 is the Apache default character set, so when you visit a Web page with Chinese characters, there will be garbled characters, then just change the character set to GB2312 and restart the AP Ache service)
Alias/down "/software/download" creates a virtual directory (creates a virtual directory named down, and its corresponding physical path is:/software/download)
Alias/ftp "/var/ftp" creates a virtual directory (creates a virtual directory named FTP, which corresponds to the physical path:/VAR/FTP)
<directory "/var/www/html" > set directory Permissions (<directory "directory path" > This write set directory permission statement </Directory>)
Options FollowSymLinks page:116
allowoverride None
</Directory>
Domain-based virtual host
Namevirtualhost 220.123.55.99 ---Use the namevirtualhost directive to specify which IP address is responsible for responding to requests for a virtual host
<virtualhost www.iigoogle.com>
ServerName www.iigoogle.com:80
ServerAdmin
iigoogle@163.com 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
iigoogle@163.com documentroot/www/docs/iigoogle.com
ErrorLog logs/www/iigoogle/error_log
customlog logs/www/iigoogle/ Access_log Common
</VirtualHost>
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.