Apache Server Configuration--linux

Source: Internet
Author: User
<span id="Label3"></p><span style="font-size: 18pt; font-family: ‘Microsoft YaHei‘;"><span style="font-size: 18pt; font-family: ‘Microsoft YaHei‘;">related Packages:</span></span> <blockquote> <blockquote> Httpd-2.2.3-29.e15.i386.rpm//main Package Httpd-devel-2.2.3-29.e15.i386.rpm//development Package httpd-manual-2.2.3   -29.e15.i386.rpm//manual Documentation System-config-httpd-1.3.3.3-1.e15.noarch.rpm//configuration Tool <span style="color: #999999;">Note: A dependency package issue occurs during installation and can be resolved</span> <span style="color: #999999;">with Yum Installation Need to configure firewall to release when enabled</span> </blockquote> </blockquote><span style="font-family: ‘Microsoft YaHei‘; font-size: 18pt;"><span style="font-family: ‘Microsoft YaHei‘; font-size: 18pt;">auto-load on Boot:</span></span> <blockquote> <blockquote> Chkconfig--level 3 httpd </blockquote> on </blockquote><span style="font-family: ‘Microsoft YaHei‘; font-size: 18pt;"><span style="font-family: ‘Microsoft YaHei‘; font-size: 18pt;">Configuration Instance:</span></span> <blockquote> Example 1: set up a Web server in the department, using the IP address and port for 192.168.0.3:80, the home page with index.html Files. The Administrator e-mail address is [email protected], the encoding type of the Web page is GB2312, all the site resources are stored in the/var/www/html directory, and the Apache root directory is set to THE/ETC/HTTPD directory. Edit Master Profile httpd.conf <span style="color: #ff0000;"><span style="color: #ff0000;">vim/etc/httpd/conf/httpd.conf</span></span>Edit Master Profile ServerRoot " <span style="color: #ff0000;"><span style="color: #ff0000;">/etc/httpd</span></span>"//set Apache's Home Directory timeout <span style="color: #ff0000;"><span style="color: #ff0000;"></span> -</span>Set Request Timeout Listen <span style="color: #ff0000;"><span style="color: #ff0000;"></span> the</span>Setting the Listening port serveradmin <span style="color: #ff0000;"><span style="color: #ff0000;"> <span style="color: #ff0000;"><span class="__cf_email__" data-cfemail="99ebf6f6edd9eaf8f5fceab7faf6f4">[email protected]</span></span> </span></span>Set up the admin mailbox servername <span style="color: #ff0000;"><span style="color: #ff0000;">192.168.0.3:80</span></span>Set host or Ipdocumentroot " <span style="color: #ff0000;"><span style="color: #ff0000;">/var/www/html</span></span>"//set Apache Document Directory DirectoryIndex <span style="color: #ff0000;"><span style="color: #ff0000;">index.html</span></span>Set Home page File Adddefaultcharset <span style="color: #ff0000;"><span style="color: #ff0000;">GB2312</span></span>Set site encoding edit home file to use as Test: Cd/var/www/htmlecho "this is Web test sample." >>index.htmlchmod 705 index.html Reload Service: <span style="color: #ff0000;"><span style="color: #ff0000;">Service httpd Restar</span></span> </blockquote>Example 2: assuming that the Apache server has 192.168.0.2 and 19.16.0.3 two addresses, and then configure apache, to bind multiple websites to different IP addresses, to access different IP addresses on the server, you can see different sites. <blockquote> <span style="color: #ff0000; font-size: 14pt;"><span style="color: #ff0000; font-size: 14pt;"><strong>(ip-based)</strong></span></span> <span style="color: #ff0000;"><span style="color: #ff0000;">mkdir/var/www/ip1/var/www/ip2</span></span>Create two home directories edit httpd.conf file: <virtualhost <span style="color: #ff0000;"><span style="color: #ff0000;">192.168.0.2</span></span>>//set IP documentroot for virtual host <span style="color: #ff0000;"><span style="color: #ff0000;">/var/www/ip1</span></span>Set the home directory of the virtual host DirectoryIndex index.html//set master page file ServerAdmin <span class="__cf_email__" data-cfemail="4c3e2323380c3f2d20293f622f2321"><span class="__cf_email__" data-cfemail="4c3e2323380c3f2d20293f622f2321">[email protected]</span></span>Set the admin mailbox errorlog logs/ip1-error_log//set the location of the error log customlog Logs/ip1-access_log common//settings visit Ask where the log is stored </virtualhost><virtualhost <span style="color: #ff0000;"><span style="color: #ff0000;">192.168.0.3</span></span>>//set the appropriate IP documentroot <span style="color: #ff0000;"><span style="color: #ff0000;">/var/www/ip2</span></span>DirectoryIndex index.html ServerAdmin <span class="__cf_email__" data-cfemail="2e5c41415a6e5d4f424b5d004d4143"><span class="__cf_email__" data-cfemail="2e5c41415a6e5d4f424b5d004d4143">[email protected]</span></span>Errorlog logs/ip2-error_log customlog Logs/ip2-access_log common</virtualhost> </blockquote> <blockquote> <span style="color: #ff0000; font-size: 14pt;"><span style="color: #ff0000; font-size: 14pt;"><strong>(domain-based)</strong></span></span> <span style="color: #ff0000;"><span style="color: #ff0000;">Mkdir/var/www/smile/var/www/long</span></span>Create two home directories edit httpd.conf file: <virtualhost 192.168.0.3>//set IP documentroot for a virtual host <span style="color: #ff0000;"><span style="color: #ff0000;">/var/www/smile</span></span>Set the home directory of the virtual host DirectoryIndex index.html//set master page file ServerName <span style="color: #ff0000;"><span style="color: #ff0000;">www.smile.com</span></span>Set the virtual host full domain name ServerAdmin <span class="__cf_email__" data-cfemail="86f4e9e9f2c6f5e7eae3f5a8e5e9eb"><span class="__cf_email__" data-cfemail="86f4e9e9f2c6f5e7eae3f5a8e5e9eb">[email protected]</span></span>Set the admin mailbox errorlog logs/smile-error_log//set the location of the error log customlog Logs/smile-access_log Common//set Where to place the access log </virtualhost><virtualhost 192.168.0.3> DocumentRoot <span style="color: #ff0000;"><span style="color: #ff0000;">/var/www/long</span></span>DirectoryIndex index.html ServerName <span style="color: #ff0000;"><span style="color: #ff0000;">www.smile.com</span></span>Set the virtual host full domain name ServerAdmin <span class="__cf_email__" data-cfemail="27554848536754464b42540944484a"><span class="__cf_email__" data-cfemail="27554848536754464b42540944484a">[email protected]</span></span>Errorlog logs/long-error_log customlog Logs/long-access_log common</virtualhost> </blockquote> <blockquote> <span style="color: #ff0000; font-size: 14pt;"><span style="color: #ff0000; font-size: 14pt;"><strong>(port-based)</strong></span></span> <span style="color: #ff0000;"><span style="color: #ff0000;">mkdir/var/www/port8080/var/www/port8090</span></span>Create two home directory edit httpd.conf Files: <span style="color: #ff0000;"><span style="color: #ff0000;">Listen 8080</span></span> <span style="color: #ff0000;"><span style="color: #ff0000;">Listen 8090</span></span><virtualhost <span style="color: #ff0000;"><span style="color: #ff0000;">192.168.0.3:8080</span></span>>//set the appropriate port documentroot/var/www/port8080//set the virtual Host's home directory Directoryind Ex index.html//set home file ServerAdmin [email protected]//settings Management Errorlog Logs/port8080-error_log//set the location of the error log customlog Logs/port8080-access_log common// Set the location of the access log </virtualhost><virtualhost <span style="color: #ff0000;"><span style="color: #ff0000;">192.168.0.3:8090</span></span>>//set the appropriate port documentroot/var/www/port8090 directoryindex index.html ServerAdmin [email protected] errorlog logs/port8090-error_log customlog logs/port8090-access_log common</virtualhost> </blockquote><p><p>Apache Server Configuration--linux</p></p></span>

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.