Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure a virtual host based on IP by Fedora apache

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how Fedora apache configures an IP-based virtual host, Xiaobian thinks it is quite practical, so share it with you as a reference, I hope you can gain something after reading this article.

To recommend a very good Fedora apache system is very valuable to learn, here I mainly explain the application of Fedora apache system, including the introduction of Fedora apache package background knowledge and other aspects. Pre-install Fedora apache and its accompanying packages, which are respectively:

httpd-2.2.10-2.i386.rpm httpd-manual-2.2.10-2.i386.rpm httpd-tools-2.2.10-2.i386.rpm

Configure an IP-based virtual host

*** Step: Add a virtual IP address to the current network. Use the command: ifconfig wlan0:0 192.169.0.35 netmask www.example.com. 255.255.255.0 Thus, the current host uses two logical IPs: 192.168.0.32 and 192.168.0.35.

Step 2: Configure. Add the following to "/etc/httpd/conf/httpd.conf"***:

#Specify IP and port number ServerAdmin rexchenhan@gmail.com DocumentRoot /var/www/html/www.rex.com #This is the directory where the website is stored ServerName www.rex.com ErrorLog logs/dummy-host.www.rex.com-error_log#Location of logs CustomLog logs/dummy-host.www.rex.com-access_log common ServerAdmin rexchenhan@gmail.com DocumentRoot /var/www/html/auto.rex.com ServerName auto.rex.com ErrorLog logs/dummy-host.auto.rex.com-error_log CustomLog logs/dummy-host.auto.rex.com-access_log common

Step 3: Create a directory corresponding to the website under/var/www/html. www.rex.com auto.rex.com Create index.html for testing and change the group to Fedora apache for both directories. *** Using links to access the above two IP addresses, you can see that you have visited two different websites respectively.

4. Configure a port-based virtual host

*** Step: Modify the main configuration file to add a listening port, here we specify 8080Listen 8080

Step 2: Modify and add a Fedora apache virtual host record

#Note here port number changed to 8080 ServerAdmin rexchenhan@gmail.com DocumentRoot /var/www/html/auto.rex.com ServerName auto.rex.com ErrorLog logs/dummy-host.auto.rex.com-error_log CustomLog logs/dummy-host.auto.rex.com-access_log common

Step 3: Test two ports at the same address: 80 and 8080

Using links to visit 192.168.0.32 and 192.168.0.32: 8080 found two different pages visited, respectively. Fedora apache Configuring a domain-based virtual host

*** Step: Modify the main configuration file. Comment out all the virtual host configurations you made earlier (domain name based and IP or port based are conflicting) and turn on NameVirtualHost *:80. Change the beginning of the two previous ones to read:

Step 2: Here my dns has already configured auto.rex.com and www.rex.com, so I directly start the dns service and point my dns resolution address to my host.

Step 3: Open two domain names with links *** Use an address like http://auto.rex.com Otherwise, links will open auto.rex.com first if there is one in the current directory. (Puzzled me for a long time, just found) Configure access authorization Some websites will pop up after opening a dialog box that requires entering a username and password. Here is also a such authorization.

*** Step: Add some configuration to the virtual host configuration that needs to be added to access control.

#Note that the directory here is the same as the host directory that needs to be configured AllowOverride AuthConfig Order allow,deny Allow from all

Step 2: Create the file.htaccess under www.rex.com directory and add the following contents:

Authtype Basic AuthName "www.rex.com Auth page" AuthUserFile /etc/httpd/conf/passwd #Password file address require valid-user require user rexchenhan #User name allowed to access

Step 3: Create a password file

httpasswd-dc /etc/httpd/conf/passwd rexchenhan This command also creates a password file **, restarts the service, and tests. Fedora apache debugging log file directory/var/log/httpd/, this directory records the log corresponding to each virtual host and the main error log

About "Fedora apache how to configure an IP-based virtual host" this article is shared here, I hope the above content can be of some help to everyone, so that you can learn more knowledge, if you think the article is good, please share it to let more people see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report