Developer on Alibaba Coud: Build your first app with APIs, SDKs, and tutorials on the Alibaba Cloud. Read more ＞
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
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:
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
When creating a link, you just need to use a soft link.
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:
# Include the virtual host configurations:
# Include/etc/apache2/sites-enabled/[^. #] *
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:
$ For I in *
> Iconv $ I-fgb2312-tutf-8-o/tmp/iconv_t/$ I
$ Cp/tmp/iconv_t /*.
The above is just a small example of using iconv to convert files in batches.
This article is an English version of an article which is originally in the Chinese language on aliyun.com and is provided for information purposes only. This website makes no representation or warranty of any kind, either expressed or implied, as to the accuracy, completeness ownership or
reliability of the article or any translations thereof. If you have any concerns or complaints relating to the article, please send an email, providing a detailed description of the concern or
complaint, to firstname.lastname@example.org. A staff member will contact you within 5 working days. Once verified, infringing content will be removed immediately.
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:
and provide relevant evidence. A staff member will contact you within 5 working days.