Reputation: 6258
I can't believe how many issues I've been having getting apache up and running. It's clearly not a run out-of-the-box type thing.
I'm running a web server on CentOS with httpd
installed via yum
.
I created a very basic hello world index.html
here (cgi-bin
and html
was created by the install):
/var/www/
├── cgi-bin
└── html
└── index.html
The httpd
configuration directory is structured like so:
/etc/httpd
├── conf
│ ├── httpd.conf
│ └── magic
├── conf.d
│ ├── autoindex.conf
│ ├── README
│ ├── userdir.conf
│ └── welcome.conf
├── conf.modules.d
│ ├── 00-base.conf
│ ├── 00-dav.conf
│ ├── 00-lua.conf
│ ├── 00-mpm.conf
│ ├── 00-proxy.conf
│ ├── 00-systemd.conf
│ └── 01-cgi.conf
├── logs -> ../../var/log/httpd
├── modules -> ../../usr/lib64/httpd/modules
├── run -> /run/httpd
├── sites-available
│ └── http.conf
└── sites-enabled
└── http.conf -> /etc/httpd/sites-available/http.conf
None of these files were created by me, but I did setup the sites-available
and sites-enabled
directories, as these make more sense and I have seen this done before.
To get these directories work, I added:
IncludeOptional sites-enabled/*.conf
to the end of httpd.conf
.
The http.conf
file I wrote looks simply like this:
<VirtualHost *:80>
ServerName domain.name.com
DocumentRoot /var/www/html/
</VirtualHost>
Running httpd -t
reports Syntax OK
and httpd -S
prints the following:
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
*:80 domain.name.com (/etc/httpd/sites-enabled/http.conf:1)
ServerRoot: "/etc/httpd"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/etc/httpd/logs/error_log"
Mutex proxy: using_defaults
Mutex authn-socache: using_defaults
Mutex default: dir="/run/httpd/" mechanism=default
Mutex mpm-accept: using_defaults
Mutex authdigest-opaque: using_defaults
Mutex proxy-balancer-shm: using_defaults
Mutex rewrite-map: using_defaults
Mutex authdigest-client: using_defaults
PidFile: "/run/httpd/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="apache" id=48 not_used
Group: name="apache" id=48 not_used
So everything looks pretty normal. Obviously, running sudo service httpd restart
restarts without errors and the httpd
logs look okay.
Checking /etc/httpd/logs/error_log
doesn't also display anything exciting.
But, when I go to the server by IP or name (using ping
, I determined that DNS is, in fact, correctly translating the name to the IP), I get a connection refused error.
I'm totally at a loss at what's going on and I'm at the end of my debugging rope. Any ideas?
I really appreciate the help!
Upvotes: 2
Views: 7845
Reputation: 602
Fedora (and I believe CentOS) have a pretty restrictive firewall by default, you need to use something like this to open port 80:
sudo firewall-cmd --add-service=http
Pass --permanent once you're sure it's working. More details here: http://ask.xmodulo.com/open-port-firewall-centos-rhel.html
Fedora also has some SELinux settings that by default restrict web servers from actually accessing files even though they look readable. You can use getsebool/setsebool
to investigate this http://forums.fedoraforum.org/showthread.php?t=240075
Upvotes: 1