Apache2 in Ubuntu

Source: Internet
Author: User
Apache2 in Ubuntu is strange-Linux Enterprise Application-Linux server application information. The following is a detailed description. I used to use apache in windows all the time. I feel familiar with it. Now I suddenly switch to linux or ubuntu, and I think it has changed a lot, I don't know if apache2 is upgraded to this mode or ubuntu.

The installation is simple. apt-get install apache2 and apt-get install php5 are OK. The default localhost home page points to/var/www, next there is a directory apache2-default is stored in the original various languages index welcome page.

In the configuration file win, the following is an httpd. conf file, which is complicated:

The configuration file in ubuntu is in/etc/apache2, and apache2.conf is a global configuration or master configuration file, httpd. conf is a user configuration file. It is often used in php programming. php overwrites config. default. the settings in the PHP file are the same. The user settings are independent to facilitate management and backup. After all, the main configuration file is rarely modified. You can occasionally write one or two statements to httpd. conf for easy backup.

In addition to two configuration files, four directories under/etc/apache2 have not been seen before and should be used frequently:
Sites-available-defined virtual host settings
Sites-enabled-activated VM
Mod-available-module Installed
Mod-enabled-activated modules

Generally, If you create an available Directory in ln under the enabled directory, the corresponding host settings or module connections are equivalent to activating or enabling the virtual host or module. At first glance, it is a little troublesome. It is much easier to think about it.

As for how to configure ln later, for example, a setting file for the virtual host NameVirtualHost * will be generated by default. The corresponding file is sites-enabled/000-default, in fact, the link to the file sites-available/default, the file content syntax and the original httpd. conf is the same. As for the module, It is similar. For example, after I install php5, A php5.load (link to mod-available/php5.load) is generated under the "mod-enabled" directory. The file content is as follows: loadModule php5_module/usr/lib/apache2/modules/libphp5.so, there is also a link file php5.conf, which should be related to the php5 settings, the content is also very simple:


AddType application/x-httpd-php. php. phtml. php3
AddType application/x-httpd-php-source. phps


With these files as a reference, you can draw a picture when configuring a VM or loading a module. At this time, if you still follow the previous syntax in httpd. if the module is loaded in the conf file (LoadModule dir_module/usr/lib/apache2/modules/mod_dir.so), an error is prompted and an error is returned when apache is started:

* Starting apache 2.0 web server... Syntax error on line 20 of/etc/apache2/httpd. conf:
Module dir_module is built-in and can't be loaded
[Fail]

When creating a link, you just need to use a soft link.

Root @ wf:/etc/apache2 # ll mod-enabled/
Total 0
Lrwxrwxrwx 1 root 36 cgi. load->/etc/apache2/mods-available/cgi. load
Lrwxrwxrwx 1 root 37 php5.conf->/etc/apache2/mods-available/php5.conf
Lrwxrwxrwx 1 root 37 php5.load->/etc/apache2/mods-available/php5.load
Lrwxrwxrwx 1 root 28 proxy. load-> ../mod-available/proxy. load
Lrwxrwxrwx 1 root 30 rewrite. load-> ../mod-available/rewrite. load

In addition, I found a small problem. after renaming 000-default to 000-default.disabled, it still takes effect, but changing it to 000-default # disabled will become invalid, this is the same as "Include/etc/apache2/sites-enabled/[^. #] * "there are some inconsistencies, but I don't know where the problem is. However, my practice is simpler and I keep my previous operation habits:

Vi apache2.conf
...
# Include the virtual host configurations:
# Include/etc/apache2/sites-enabled/[^. #] *
Include/etc/apache2/fwolf. conf

In this way, all the configurations are in one document, which is convenient during Backup and suitable for websites with simple configurations.

In addition, if the second hard disk or other mounting device is involved when configuring the virtual directory (non-linux format partition, excluding the partition format with linux format permission information ), the user www-data used by apache2 by default cannot be accessed. Although the configuration script does not report an error, the error 403 Forbidden will be generated no matter how it is accessed, the solution is to add the user www-data to the corresponding user group:

Usermod-a-G plugdev www-data

If you do not have permissions in other forms, you can set the permissions based on the owner according to the above method.

Of course, you should also note that ubuntu is basically full unicode, and the files and editors are UTF-8 encoded. Therefore, if the previous webpage files are gb2312 encoded, you must convert them to utf8 to display them correctly:

$ Mkdir/tmp/iconv_t
$ For I in *
> Do
> Iconv $ I-fgb2312-tutf-8-o/tmp/iconv_t/$ I
> Done
$ Cp/tmp/iconv_t /*.

The above is just a small example of using iconv to convert files in batches.

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.