首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >阿帕奇看不到网站- CentOS 7

阿帕奇看不到网站- CentOS 7
EN

Stack Overflow用户
提问于 2017-05-18 14:47:35
回答 4查看 841关注 0票数 0

我在Ubuntu中设置了很多虚拟主机,但今天我需要在CentOS 7服务器上执行此操作。我安装了Apache并设置了VHost配置,但当我查看站点时什么也没有出现。

我知道Apache正在读取我的配置文件,因为如果我在其中添加了一个错误并重新启动Apache,它会报告这个错误。在CentOS 7上还需要什么“其他”的东西吗?

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2017-05-19 21:23:06

因此,这个问题的答案是CentOS服务器(默认情况下)阻塞了HTTP80端口。这看起来真的有点傻,但当我允许防火墙为web流量打开这些端口时,一切都很正常:

代码语言:javascript
复制
iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
票数 0
EN

Stack Overflow用户

发布于 2017-05-18 22:22:41

你想实现什么样的虚拟主机?我猜是基于名字的。

如果未在2.4>版本上运行,则需要为IP:PORT对启用名称虚拟主机指令

NameVirtualHost *:80

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

如果没有,这可能取决于selinux标签没有正确设置。不管怎样,在这种情况下,你会得到一个权限错误。老实说,我不相信这是真的。

票数 0
EN

Stack Overflow用户

发布于 2017-05-19 19:54:20

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

代码语言:javascript
复制
<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基本上是相同的设置,但它也显示了如何使用别名部分从主目录外部提取文档。

顺便说一句,如果任何人在发布的内容中发现了任何可恶之处,请让我知道或编辑并让我知道。

琥珀-玛丽

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44040484

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档