12

I have got a problem with restart httpd service on my server.

When I try service httpd restart, it will give me an error:

root@server1 [/usr/src]# service httpd restart
AH00548: NameVirtualHost has no effect and will be removed in the next release /usr/local/apache/conf/httpd.conf:455

I don't really understand what I get an error when i try to restart the httpd service.

Can you please tell me what I have to do to correct the problem?

P.S I need to set the setting correctly in the httpd.conf as I need the rewrite rules to work correctly as it did not work when I try to use RewriteCond %{HTTP_HOST} ^google as it wont do anything to mask the domain name to my domain name.

2 Answers 2

17

The error instructs you to look at line 455 in /usr/local/apache/conf/httpd.conf. That line likely starts with NameVirtualHost, which is no longer necessary. But it is a warning, not an error. Also take a look in the logs (your configuration appears not standard; check in /var/log for the httpd logs).

10

As an elaboration of other answers, do as follow:

  1. Open /usr/local/apache/conf/httpd.conf
  2. Comment bellow lines or similar ones by adding #:

    NameVirtualHost 188.165.XX.XX:80

    <VirtualHost 188.165.XX.XX:80>

  3. Add following line:

    <VirtualHost *:80>

(or simply replace 188.165.XX.XX:80 with *:80). Save httpd.conf and restart apache, service httpd restart.

2
  • 2
    I thinking that -1 because only delete with row with NameVirtualHost is right as is in accepted answer. You can use virtual host with IP and port still in apache 2.4.
    – Pavel
    Jan 29, 2017 at 19:52
  • 1
    You can, but the important thing to understand is that the name at VirtualHost isn't the name of the vhost, it's the name of the interface on which to accept connections. So in most cases *:80 there is sufficient and less error-prone. The actual name goes into the ServerName directive.
    – rustyx
    Feb 7, 2018 at 10:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.