turn on the NameVirtualHost directive

Issues related to applications and software problems
lse123new
Posts: 63
Joined: 2014/05/01 15:48:05

turn on the NameVirtualHost directive

Post by lse123new » 2018/04/05 07:26:17

My book Linux Bible 9/e : Chapter 17: Configuring a Web Server
says for Virtual host conf the below ... well in what file is this to turn it ON:

turn on the NameVirtualHost directive.
???

"
To use name-based virtual hosting, turn on the NameVirtualHost directive. Then add as
many VirtualHost containers as you like. Here’s how to configure a virtual host:
After you enable NameVirtualHost, your default DocumentRoot (/var/www/html) is no longer used if someone
accesses the server by IP address or some name that is not set in a VirtualHost container. Instead, the first
VirtualHost container is used as the default location for the server.

1. In Fedora or RHEL, create a fi le named /etc/httpd/conf.d/example.org.conf using this template:
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster@example.org
ServerName www.example.org
ServerAlias web.example.org
DocumentRoot /var/www/html/example.org/
DirectoryIndex index."

mghe
Posts: 696
Joined: 2015/11/24 12:04:43
Location: Katowice, Poland

Re: turn on the NameVirtualHost directive

Post by mghe » 2018/04/05 08:05:37


User avatar
TrevorH
Forum Moderator
Posts: 22999
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: turn on the NameVirtualHost directive

Post by TrevorH » 2018/04/05 08:25:20

Yes, but your *clients* need to address the server by name and not by ip address. The name they use has to be known by hte server as its own.
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

lse123new
Posts: 63
Joined: 2014/05/01 15:48:05

Re: turn on the NameVirtualHost directive

Post by lse123new » 2018/04/05 08:28:11

what you mean?
Leave all like are but create this file:

/etc/httpd/conf.d/example.org.conf

and add below to this ^^^ file? or is any other conf file that must add the: turn on the NameVirtualHost directive.


NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster@example.org
ServerName www.example.org
ServerAlias web.example.org
DocumentRoot /var/www/html/example.org/
DirectoryIndex index."

bitwiz
Posts: 6
Joined: 2017/07/15 18:09:50

Re: turn on the NameVirtualHost directive

Post by bitwiz » 2018/04/07 13:35:14

The line:

Code: Select all

NameVirtualHost *:80
...turns on Apache's ability to serve websites by name on port 80. In this case, the asterisk means Apache will serve websites through any IP address enabled in networking on the server.

The default config file for apache is: /etc/httpd/conf/httpd.conf

At the bottom of that file, it has:

Code: Select all

# Supplemental configuration
#
# Load config files in the "/etc/httpd/conf.d" directory, if any.
IncludeOptional conf.d/*.conf
Which will load files in that folder, each site gets its own config file.

So yes, you have the right idea, the settings for your site go into a file called example.org.conf which you create (replace example.org with your actual domain name), inside of conf.d folder.

You have to restart httpd to apply any changes you make to those conf files.

lse123new
Posts: 63
Joined: 2014/05/01 15:48:05

Re: turn on the NameVirtualHost directive

Post by lse123new » 2018/04/07 14:41:45

NameVirtualHost *:80

this ^^ line should be

in /etc/httpd/conf/httpd.conf

or in /etc/httpd/conf.d/example.org.conf ?

should included in both is error? so only in one file ... in other words during the call of conf files run only one?

User avatar
TrevorH
Forum Moderator
Posts: 22999
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: turn on the NameVirtualHost directive

Post by TrevorH » 2018/04/07 14:49:51

I think you already have name based virtuial hosts active but in order for them to work your clients must address the server by name and not by ip address.
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

bitwiz
Posts: 6
Joined: 2017/07/15 18:09:50

Re: turn on the NameVirtualHost directive

Post by bitwiz » 2018/04/08 20:58:36

You only need to specify NameVirtualHost in /etc/httpd/conf/httpd.conf

Servers host websites on port 80 (http) and port 443 (https for SSL) so our httpd.conf has these two entries:

Code: Select all

NameVirtualHost *:80
NameVirtualHost *:443

lse123new
Posts: 63
Joined: 2014/05/01 15:48:05

Re: turn on the NameVirtualHost directive

Post by lse123new » 2018/04/10 07:45:16

IN
/etc/httpd/conf/httpd.conf
I CAN NOT FIND NEITHER COMMENTED
NameVirtualHost *:80
NameVirtualHost *:443

WHERE TO ADD THESE LINES ... ?
WHAT LINES MUST FOLLOW THESE TWO in httpd.conf ... ?

lse123new
Posts: 63
Joined: 2014/05/01 15:48:05

Re: turn on the NameVirtualHost directive

Post by lse123new » 2018/04/16 08:54:44

Where find and install CLI BROWSERS for CentOS 7 --- what serach in man pages...
AKA TEXT BROWSERS RUN IN LINUX SHELL --- I mean find web pages via cmds in cli and not gui... and show only some text in shell cli window...
???

I did a Linux CENTOS7 course but forgot SINCE... how install and how find them...

Post Reply