4

I want to deploy my project in virtual host in CentOS running server. I have this

<Directory />
#change value of next line from none to all
    AllowOverride none
    Require all denied
</Directory>
<VirtualHost *:80>
ServerAdmin root@localhost
ServerName project.com
ServerAlias www.project.com
DocumentRoot /var/www/html/project

<Directory /var/www/html/project>
        DirectoryIndex index.php
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Require all granted
</Directory>
</VirtualHost>

In the httpd.conf in the /etc/httpd/conf folder I also have this

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
#127.0.0.1    localhost.localdomain localhost host.server4-245.com
#::1          localhost.localdomain localhost host.server4-245.com
192.168.1.97   www.project.com
127.0.0.1      www.project.com

In the hosts in the /etc folder but when i try to access http://project.com/ in the browser I get :

This site can’t be reached

project.com’s server DNS address could not be found. Search Google for project ERR_NAME_NOT_RESOLVED

after altering this I restarted the httpd using

systemctl restart httpd

When I do this in ubuntu I happened to do one step that I cant do in centOS. The step below:

sudo a2ensite httpd.conf

When I search for the equivalent of this command in centOS there is none.

What could be missing in my config? Could it be that I was not able to reload the httpd.conf?

***UPDATE***

when I try to access using IP like 192.168.1.97/project When I have the virtual host config I cant access when I comment out the config I can access it.

***Update***

When I rune netstat -autnp | grep "\:80" | grep LISTEN

I get :

tcp6 0 0 :::80 :::* LISTEN 6905/httpd

  • 1
    Try putting the hostname in /etc/hosts. – Michael Hampton Dec 6 '17 at 5:24
  • how should i go with @MichaelHampton sorry not that good with dealing with server – guradio Dec 6 '17 at 5:25
  • With an editor? How did you edit it previously? – Michael Hampton Dec 6 '17 at 5:28
  • I used vi editor i mean what should I add in the hosts file? you mean I should move the file into the folder /etc/hosts? sorry I didnt get the first question I thought I need to add some lines to it @MichaelHampton – guradio Dec 6 '17 at 5:31
  • You need to add an IP address and hostname that you want to use. – Michael Hampton Dec 6 '17 at 5:43
0

You are accessing hxxp://project.com/ but you only have www.project.com in your /etc/hosts file. you need to add an entry for project.con too

192.168.1.97   www.project.com project.com
127.0.0.1      www.project.com project.com
| improve this answer | |
  • what are the last two parameters ? – guradio Dec 6 '17 at 6:41
  • still same i cant access it – guradio Dec 6 '17 at 6:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.