Apache Service and httpd.conf configuration

Source: Internet
Author: User
Apache Service Erection
First, the Apache Service Overview:
1, the required software package: httpd httpd-devel httpd-manual
2. Port: (HTTP) 443 (HTTPS)
3, the main configuration file:/etc/httpd/*,/var/www/*
4. Default Home directory:/var/www/html
5. Script:/ETC/INIT.D/HTTPD
6, The Guardian process:/USR/SBIN/HTTPD
7, the Apache service-related SELinux environment:
1) system_u:object-r:httpd_config_t
Documents under/etc/httpd/conf and/ETC/HTTPD/CONF.D
2) system_u:object_r:httpd_log_t
The log file in the/etc/httpd/logs.
3) system_u:object_r:httpd_modules_t
Related modules used by the HTTPD service
4 Web content and web directory environment:
System_u:object_r:httpd_sys_content_t: If not this page will not be accessible.
Another: For the directory, the other group has access and executable permissions.
To set the SELinux environment:
Chcon-r-reference=/var/www/html/var/www/html/data
Restorecon-r/var/www/html
It is recommended that the site directory be/var/www/html to prevent problems caused by selinux.
The simple implementation of the Apache configuration file:
1, related configuration file modification:/etc/httpd/conf/httpd.conf
1), ServerRoot "/ETC/HTTPD" The default configuration file storage directory;
2), Timeout 120 Client Access timeout time 120 seconds;
3), Listen 80 to monitor 80 ports;
4), ServerAdmin root@rhel.com set up admin mailbox;
5), ServerName www.station53.com Server host name, you can make DNS domain name, can also be IP address;
6), documentroot/var/www/html Web page default storage directory;
7), DirectoryIndex index.html index.htm Set the name of the home page file;
2, the establishment of home page files:
Create the home page file in the/var/www/html directory index.html and write the content.
3, start related services:
Chkconfig httpd on
Service httpd Restart
4, test your own server:
Third, the user's personal homepage realization:
The configuration allows each user to have a home page that can be accessed via http://www.station53.com/~Username.
1, the main configuration file modification:
Note:
1) Directory Permissions settings:
AllowOverride: Used to define the instruction type in the. htaccess (access Control) file located in each directory. If you want to disable: allowoverride None.
Options multiviews: Defines which attributes are used by the directory.
Indexes: Allows directory browsing, but does not specify access to the file under the directory, and its directory does not exist in the default document when the Apache in Hypertext return to the directory of files and subdirectories list.
Mulitiviews: Multiple attempts to allow content negotiation. When accessing http://127.0.0.1/icons/a, the service looks for all the a.* files in the directory, and displays the file if it is in the directory, not the error message.
All: Contains all attributes except Mulitiviews, if no options statement defaults to all.
EXECCGI: Allows CGI scripts to be executed.
FollowSymLinks: You can use symbolic links in this directory.
Includes: Allows the service side to include functionality.
IncludesNOEXEC: Allows the service side to contain functionality but does not allow CGI scripts to execute.
2 default access rights and allow, deny order:
Allow,deny rules, first judge the Allow, after the judgement of the deny, conflict, the back of the effective;
Examples are as follows:
2 Set up the home directory of the personal website and establish the file:
Create the public_html directory in the personal directory/home/username directory.
Create your own home page, and then enter "Http://URL/~username" in the browser,
Note: Pay attention to the public_html directory and the file inside the SELinux environment parameters, if there are problems, please follow the above mentioned adjustments.
Four, the virtual host settings:
Www.station53.com below we are in the open www.server53.com (default has been designed and www.client53.com
1. Configure DNS:
1 edit/var/namde/chroot/etc/named.conf, edit the file as follows:
2 generated in/var/named/chroot/var/named: Server53.com.zone and client53.com.zone two files:
3 Modify the rights and contents of the document:
4 in the/var/named directory to establish Server53.com.zone, Client53.com.zone connection files, and adjust the permissions:
5 Restart the DNS service and test the newly established domain name.
2. Edit/etc/httpd/conf/httpd.conf File:
3, restart the Apache service, test settings to meet the requirements:
1 in the/var/www/html directory to establish SERVER53 and client53 two directories, and add home page files to deal with their related selinux environment settings.
2 Restart the Apache service test:
。。 What www.station53.com and www.server53.com show the same.
So we're going to continue to modify/etc/httpd/conf/httpd.conf and add the following paragraph:
Create a station53 directory under the/var/www/html directory and create a home page file to handle the SELinux environment.
Once the virtual host feature is turned on, each domain name is added to the corresponding project in the location of the virtual host project, otherwise the first virtual host setting is accessed by default.
Passed. Ok...
Five, the homepage user authentication setting: (Take Redhat's personal directory for example.) )
1, configure httpd.conf files, so that the target directory support certification:
The target directory has allowoverride authconfig entries in the httpd.conf, and the user's personal directory supports this setting when the user's personal home page is opened by default.
2, the establishment of the. htaccess file, built in the site directory, this is the/home/redhat/public_html directory.
3, the establishment of the. passwords file:
4. Test Effect:
Sure OK, be careful not to write wrong, I am in the configuration. htaccess when the password file placement location name is wrong, has been verifying the password, how can not jump past, hehe. Note that all two files are in front of the hidden file name with dots.
Apache's httpd.conf detailed
Apache Grammar Check Tool
Service httpd Configtest

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.