Apache没有看到网站 - CentOS 7

时间:2017-05-18 06:47:35

标签: php linux apache centos7 apache2.4

我在Ubuntu中设置了很多虚拟主机,但今天我需要在CentOS 7服务器上执行此操作。我安装了Apache并设置了VHost配置,但是当我查看该网站时没有任何内容。

我知道Apache正在读取我的Config文件,因为如果我在其中添加了一个错误并重新启动Apache,它就会抱怨错误。有什么东西"否则"这是CentOS 7需要的吗?

4 个答案:

答案 0 :(得分:0)

您想要实现哪种虚拟主机?基于我的名字。

如果您未在2.4版本上运行>那么你需要为IP:PORT对

启用名称虚拟主机指令

NameVirtualHost *:80

不同的行为可能取决于发行版随附的Apache服务器的不同版本。

如果没有,可能取决于未正确设置的selinux标签。无论如何,在这种情况下,您将收到权限错误。老实说,我不相信情况就是这样。

答案 1 :(得分:0)

这是我在运行Apache 2.4.6的CentOS 7.3.1611上使用的设置我通常使用virtualmin / webmin进行配置,但我查看了httpd.conf我的配置中的基本设置是

<VirtualHost xxx.xxx.xxx.xxx:80>
SuexecUserGroup "#502" "#502"
ServerName grid.hosted-systems.co.uk
ServerAlias www.grid.hosted-systems.co.uk
ServerAlias webmail.grid.hosted-systems.co.uk
ServerAlias admin.grid.hosted-systems.co.uk
DocumentRoot /home/grid/public_html
ErrorLog /var/log/grid.hosted-systems.co.uk_error_log
CustomLog /var/log/grid.hosted-systems.co.uk_access_log combined
DirectoryIndex index.html index.htm index.php index.php4 index.php5

<Directory /home/grid/public_html>
    Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch +ExecCGI
    allow from all
    AllowOverride All   Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
    Require all granted
    AddType application/x-httpd-php .php
    AddHandler fcgid-script .php
    AddHandler fcgid-script .php5
    FCGIWrapper /home/grid/fcgi-bin/php5.fcgi .php
    FCGIWrapper /home/grid/fcgi-bin/php5.fcgi .php5
</Directory>

<Directory /home/grid/cgi-bin>
    allow from all
    AllowOverride All   Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
    Require all granted
</Directory>

RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.grid.hosted-systems.co.uk
RewriteRule ^(.*) https://grid.hosted-systems.co.uk:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.grid.hosted-systems.co.uk
RewriteRule ^(.*) https://grid.hosted-systems.co.uk:10000/ [R]
RemoveHandler .php
RemoveHandler .php5
    php_admin_value engine Off
FcgidMaxRequestLen 1073741824
Alias /dav /home/grid/public_html

<Location /dav>
    DAV on
    AuthType Basic
    AuthName "grid.hosted-systems.co.uk"
    AuthUserFile /home/grid/etc/dav.digest.passwd
    Require valid-user
    ForceType text/plain
    Satisfy All
    RemoveHandler .php
    RemoveHandler .php5
    RewriteEngine off
</Location>

<Files awstats.pl>
    AuthName "grid.hosted-systems.co.uk statistics"
    AuthType Basic
    AuthUserFile /home/grid/.awstats-htpasswd
    require valid-user
</Files>
</VirtualHost>

<VirtualHost xxx.xxx.xxx.xxx:80>
SuexecUserGroup "#500" "#500"
ServerName mirrors.hosted-systems.co.uk
ServerAlias www.mirrors.hosted-systems.co.uk
ServerAlias webmail.mirrors.hosted-systems.co.uk
ServerAlias admin.mirrors.hosted-systems.co.uk
DocumentRoot /home/hosted-systems/domains/mirrors.hosted-systems.co.uk/public_html
ErrorLog /var/log/virtualmin/mirrors.hosted-systems.co.uk_error_log
CustomLog /var/log/virtualmin/mirrors.hosted-systems.co.uk_access_log combined
ScriptAlias /cgi-bin/ /home/hosted-systems/domains/mirrors.hosted-systems.co.uk/cgi-bin/
ScriptAlias /awstats/ /home/hosted-systems/domains/mirrors.hosted-systems.co.uk/cgi-bin/
DirectoryIndex index.html index.htm index.php index.php4 index.php5

<Directory /home/hosted-systems/domains/mirrors.hosted-systems.co.uk/public_html>
    Options +Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch +ExecCGI
    allow from all
    AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
    Require all granted
    AddType application/x-httpd-php .php
    AddHandler fcgid-script .php
    AddHandler fcgid-script .php5
    FCGIWrapper /home/hosted-systems/domains/mirrors.hosted-systems.co.uk/fcgi-bin/php5.fcgi .php
    FCGIWrapper /home/hosted-systems/domains/mirrors.hosted-systems.co.uk/fcgi-bin/php5.fcgi .php5
</Directory>

<Directory /home/hosted-systems/domains/mirrors.hosted-systems.co.uk/cgi-bin>
    allow from all
    AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
    Require all granted
</Directory>

Alias "/centos" "/home/shared/CentOS"
    <Directory "/home/shared/CentOS">
            Options +Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch +ExecCGI
            Require all granted
            HeaderName HEADER.html
    </Directory>

Alias "/centos/" "/home/shared/CentOS/"
    <Directory "/home/shared/CentOS/">
            Options +Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch +ExecCGI
            IndexOptions FancyIndexing FoldersFirst NameWidth=* DescriptionWidth=*
            Require all granted
            HeaderName HEADER.html
    </Directory>
</VirtualHost>

此处的设置使用端口80设置两个虚拟网站,并绑定到同一个IP,可以使用http://servernamehttp://ServerAlias访问.DocumentRoot是文件作为服务器的位置。 第二个VirtualServer基本上是相同的设置,但它也显示了如何使用Alias部分从主目录外部提取文档。

作为旁注,如果有人在发布的内容中发现任何可用性,请告诉我或编辑并告知我。

琥珀 - 马里

答案 2 :(得分:0)

所以对此的答案是CentOS服务器(默认情况下)阻止了HTTP端口80.这看起来有点傻但是只要我允许防火墙为网络流量打开这些端口,一切正常:

iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT

答案 3 :(得分:0)

我在Centos 7.5上尝试firewall-cmd --add-service=http,并且可以正常工作