Httpd-2.2.0 virtual host directory permissions issue

  
Because the available server resources are limited, you can only use the apache virtual machine to complete more work tasks. The current version of apache is 2.2.4. Compared with the previous version, there are many places to improve. The biggest difference is that the virtual machine is made into a file in the main configuration file by including the file. Of course, the difference is still There are many, here only focus on virtual machines. System solaris 10Apache version httpd-2.2.0 network interface address 192.168.27.201 Apache installation path /usr/local/apache2/virtual machine mode port 8088

Modify the main configuration file /usr/local/apache2/conf /httpd.conf. Open the main configuration file httpd.conf with the editor (vi, etc.), and uncomment the comment in front of the Include conf/extra/httpd-vhosts.conf line (about 395 lines) to make the include function take effect. Then add the listener "Listen 192.168.27.201:8088" to the virtual machine in the main configuration file (the first letter 'L' is uppercase). Modify the added content as follows:


 Listen 192.168.27.201:8088.............. (omit some, no need to modify) Include conf/extra/httpd -vhosts.conf //Virtual machine configuration with a separate file, //​​This way the main configuration file is smaller, easier to maintain. 

Modify the virtual machine configuration file. Its directory is in the main configuration file httpd.conf in the way it is included (Include) indicates that the path is /usr/local/apache2/conf/extra/httpd-vhosts.conf. If you plan to use other files, you can configure it in the main configuration. Reassign in the file. This virtual machine configuration file is a template, giving examples of two apache virtual machines, commenting them out! Note: If it is a domain-based virtual machine mechanism, the NameVirtualHost *.80 line is required, because I am here based on the virtual mechanism of the port (exactly based on the IP address), so comment it out. First add the following block to httpd-vhosts.conf according to the template:


< VIRTUALHOST 192.168.27.201:8088>DocumentRoot "/www/docs" //Virtual Machine Root document directory ServerName 192.168.27.201:8088< /VIRTUALHOST>

Then go back to the apache installation directory and execute the command bin/apachectl –t to check whether the syntax of the main configuration file is correct. Then execute bin/apachectl –S without errors. Check that the syntax of the virtual machine is correct. Next, create a test document test.html in the root document directory of the virtual machine, start the apache service bin/apachectl start&, use the browser to access http://192.168.27.201, and display the default page of apache, indicating that the main configuration file is normal. Go to http://192.168.27.201:8088/test.html. Return code 403 (no access), the content of the page is "You can't view this page...", the same problem has already happened to 2 people, they All agree that it was set up in the old version such as apache1.3, it should not be like this! And the grammar check has passed, what is the problem? Open the main configuration file conf/httpd.conf and find the following block:


< DIRECTORY />Options FollowSymLinksAllowOverride NoneOrder deny,allow //Deny Deny from first reject All //Reject all accesses < /DIRECTORY>

This block is the access control of the directory, and it is very strict, so we must manually join the permission control block of the virtual machine directory. Allows users to access the virtual machine's directory and page files normally. There are two places to join the virtual directory access control block: the main configuration file httpd.conf and the virtual machine configuration file httpd-vhost.conf, which is more appropriate in that place? Of course, the most important reason for choosing a virtual machine configuration file is that it is more convenient to maintain and may also involve security issues (this I did not test). Next, insert the directory access control block into the virtual machine configuration file in the following form:


< VIRTUALHOST 192.168.27.201:8088>DocumentRoot "/www/docs" ServerName 192.168.27.201:8088< DIRECTORY docs? www ?> //Insert Starts Options -Indexes FollowSymLinksAllowOverride NoneOrder allow,denyAllow from all< /DIRECTORY> //Insert Ends< /VIRTUALHOST>

Complete File, check the syntax, restart the apache service, and then use the browser to access the virtual machine address, this should be normal.

Copyright © Windows knowledge All Rights Reserved