Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install and configure Apache for Ubunt

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "Ubunt how to install and configure Apache", the content is simple and easy to understand, organized clearly, I hope to help you solve doubts, let Xiaobian lead you to study and learn "Ubunt how to install and configure Apache" this article bar.

1. Ubuntu Apache2.conf is the main configuration file, httpd.conf user configuration file

2. Virtual directories are in httpd.conf

DocumentRoot "Path"

ServerName

allow from all Options +Indexes

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;start

5. Log files in/var/log/apache2/

ServerName www.kimoqi.com

DocumentRoot /home/vsftpd/kimoqi

ServerName www.arwenedu.com

DocumentRoot /home/vsftpd/wangguan/webapps

ServerName www.arwenedu.org.cn

DocumentRoot /home/vsftpd/wangguan/chem

vi /etc/httpd/conf/httpd.conf

Under Windows, there is usually only one Ubuntu Apache configuration file, httpd.conf. But after installing Ubuntu Apache2 on Ubuntu Linux with apt-get install apache2, I found that its httpd.conf (located in/etc/apache2 directory) was empty! Then found that Ubuntu Apache package configuration file is not as simple as Windows, it put the various settings into different configuration files, looks complex, but think about the design is really reasonable.

Strictly speaking, Ubuntu Apache (or should I say Apache under Linux?) I don't know about other distributions of Ubuntu Apache. The configuration file is/etc /apache2/apache2.conf, which Ubuntu Apache automatically reads at startup. Other configuration files, such as httpd.conf, are included via the Include directive. These Include lines can be found in Ubuntu 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 the comments, it is clear what each profile does. Of course, you can put all your settings in Ubuntu Apache2.conf or httpd.conf or any configuration file. This partitioning of Ubuntu Apache2 is just a good habit.

One of the most important things to do after installing Ubuntu Apache is to know where the Web documentation root is located, which for Ubuntu is/var/www by default. How do you know? There is no DocumentRoot entry in apache2.conf, and httpd.conf is empty, so it must be in another file. After searching, I found that in/etc /apache2/sites-enabled/000-default, there is such a content:

reference

NameVirtualHost *

ServerAdmin webmaster@localhost

DocumentRoot /var/www/

This is for setting up virtual hosts, which doesn't make sense to me. So I commented out the Include /etc/apache2/sites-enabled/line in Ubuntu Apache2.conf, and set DocumentRoot to a directory under my user directory in httpd.conf, which is convenient for development.

Take a look at the contents of/etc/apache2. Just now we found sites-enabled directory in apache2.conf, and sites-available directory in/etc /apache2, what is in it? In fact, these are the real configuration files, and the sites-enabled directory only holds symbolic links to files here, which you can verify with ls /etc/apache2/sites-enabled/. Therefore, if apache is configured with multiple virtual hosts, and the configuration files of each virtual host are placed under sites-available, it is very convenient for disabling and enabling virtual hosts: when a link to a virtual host configuration file is established under sites-enabled, it is enabled; if you want to shut down a virtual host, just delete the corresponding link, and you don't have to change the configuration file at all.

mods-available and mods-enabled are similar to sites-available and sites-enabled above, where configuration files and links for Ubuntu Apache feature modules are stored. When I installed the PHP module with apt-get install php5, I had php5.load, php5.conf, and links to them in these two directories. This directory result is very convenient for enabling and disabling certain Ubuntu Apache modules.

*** One is ports.conf, which sets the port used by Ubuntu Apache. If you need to adjust the default port settings, it is recommended to edit this file. Or you think it is too much, you can also remove the Include /etc/apache2/ports.conf line in apache2.conf and set the Apache port in httpd.conf.

The directory structure of the default installation in Ubuntu is slightly different. In Ubuntu module and virtual host configuration have two directories, one is available, the other is enabled, the available directory is to store valid content, but does not work, only with ln connected to the enabled past can work. It is very convenient for debugging, but if you don't know in advance, it is a bit troublesome to find.

/etc/apache2/sites-available contains VH configuration, but it doesn't work. Link the file to sites-enabled directory.

That's all for "Ubunt How to Install and Configure Apache." Thanks for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report