AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题

问题[virtualhost](ubuntu)

Martin Hope
Lelio Faieta
Asked: 2020-02-05 02:07:53 +0800 CST

Apache2 vhost 上未定义无效重定向

  • 1

假设我在 Apache2 中有以下 Vhost 定义

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerName dummy.com
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/dummy
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    Include /etc/letsencrypt/options-ssl-apache.conf
    ServerAlias www.dummy.com
    SSLCertificateFile /etc/letsencrypt/live/dummy.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/dummy.com/privkey.pem
</VirtualHost>
</IfModule>
<IfModule mod_ssl.c>
<VirtualHost *:80>
    ServerName dummy.com
    ServerAlias www.dummy.com
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/dummy
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    RewriteEngine on
    Redirect permanent / https://www.dummy.com
</VirtualHost>
</IfModule>

如果我输入

http://dummy.com

它重定向到

https://www.dummy.com

但是如果我输入

http://www.dummy.com或只是 www.dummy.com

它重定向到

https://www.dummy.comindex.php/

这不是一个有效的网址。

虚拟主机配置中的什么导致了这种情况?由于虚拟主机不包含此重写规则,我看不到应该在哪里调试和解决问题

apache2 virtualhost
  • 1 个回答
  • 305 Views
Martin Hope
Taux1c
Asked: 2020-01-07 16:08:35 +0800 CST

Apache 虚拟主机问题或 dns 问题?

  • 3

我之前发布了这个问题,但我想我写它的方式并不清楚。所以我删除了它,这里又是我能想到的尽可能多的信息。

我使用戴尔尺寸 2400 的旧计算机部件创建了一个服务器。我安装了带有 Linux 4.15.0-72-generic 内核的 Ubuntu 16.04.6 LTS。我安装了 mysql-server、apache2、certbot、pyton3、python-apache-certbot、php7.0、ssh、vsftpd,然后将我安装的所需端口转发到内部 ip。(192.168.1.23)。

然后我在服务器上设置了一个 wordpress 站点。问题是我设置了虚拟主机文件(如下所示),但是为了使站点正常工作,我必须使用网络内部 ip 来加载站点。


这是虚拟主机文件:

    <IfModule mod_ssl.c>
<VirtualHost 192.168.1.23:443>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/domain.com/public_html

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
ServerName domain.com
SSLCertificateFile /etc/letsencrypt/live/domain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/domain.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
~

请记住,这是工作的虚拟主机。

当我将其更改为域名 (domain.com:443) 时,它应该是不起作用的。

(端口 80 上的相同问题。)

我需要一个内部 dns 还是别的什么?

我尝试安装 bind 但要么我把它搞砸了,要么不是这样......或者两者兼而有之......老实说更倾向于两者。

无论如何,我希望这是足够的信息,并且有人能够对此有所了解。我希望能够在此服务器上托管另一个站点。

networking server dns apache2 virtualhost
  • 3 个回答
  • 4244 Views
Martin Hope
woninana
Asked: 2020-01-04 12:25:23 +0800 CST

虚拟主机不能在邮递员中工作,但可以通过 CURL 访问

  • 0

我正在使用可以使用本地 url 访问的 SLIM 框架:http://localhost:/

但我无法通过在浏览器或邮递员中输入网址: http ://dev.slim.com 通过虚拟主机访问它。它说:

无法访问此站点 dev.slim.com 的服务器 IP 地址无法找到。

这是我的配置文件:

<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName dev.slim.com

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/api-slim/public/

<Directory /var/www/html/api-slim/public/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>


# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf

但是我尝试使用 CURL 并且我从 url 中得到了一些结果,这意味着虚拟主机正在工作,但是为什么我无法在浏览器或邮递员中访问它?

server php apache2 virtualhost slim
  • 1 个回答
  • 1365 Views
Martin Hope
BlueSkies
Asked: 2019-11-27 10:25:43 +0800 CST

使用虚拟主机时将浏览器指向哪里?[复制]

  • 0
这个问题在这里已经有了答案:
无法访问本地网页(错误:无法解析主机) (1 个回答)
2年前关闭。

使用虚拟主机时,我应该将浏览器指向哪里?

我正在尝试为Example.com. 我的理解是,如果一切顺利,我必须将浏览器指向Example.com/phptest.php才能访问 page phptest.php。但它不起作用。另一方面,如果我将浏览器指向localhost/phptest.php,它将返回phptest.php页面。

相关目录/文件结构如下。

ls -l /var/www/html/example.com/public_html
total 12
-rw-r--r-- 1 ubuntu ubuntu 203 Nov 25 14:49 index.html
-rw-r--r-- 1 ubuntu ubuntu  21 Nov 25 18:56 info2.php
-rw-r--r-- 1 ubuntu ubuntu 641 Nov 25 13:48 phptest.php

任何帮助将不胜感激。

apache2 virtualhost
  • 1 个回答
  • 329 Views
Martin Hope
Ruwenzori
Asked: 2019-08-25 01:05:46 +0800 CST

Ubuntu 19.04 的虚拟主机

  • 1

我已经阅读了几篇文章并梳理了 stackExchange,但无法解决问题。我有两个域名,我想为每个域名创建虚拟主机。我创建了单独的文件夹,在其中托管每个域的index.html。我还创建了一个 conf 文件,在/etc/apache2/sites-available下,文件如下:

NameVirtualHost x.x.x.x:80

<VirtualHost x.x.x.x:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        ServerName example1.org
        ServerAlias www.example1.org
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/org/public_html
        #Options +FollowSymlinks
        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn
        #<Directory /var/www/html/org/public_html>
        # Options -Indexes +FollowSymLinks +MultiViews
        # AllowOverride All
        # Require all granted
        #</Directory>

        LogLevel warn

        ErrorLog ${APACHE_LOG_DIR}/example1aorg-error.log
        CustomLog ${APACHE_LOG_DIR}/example1org-access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
</VirtualHost>



<VirtualHost x.x.x.x:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        ServerName example2.com
        ServerAlias www.example2.com
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/com/public_html
        #Options +FollowSymlinks
        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn
        #<Directory /var/www/html/com/public_html>
        # Options -Indexes +FollowSymLinks +MultiViews
        # AllowOverride All
        #</Directory>

        LogLevel warn

        ErrorLog ${APACHE_LOG_DIR}/example2com-error.log
        CustomLog ${APACHE_LOG_DIR}/example2com-access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

xxxx是公共 IP
example1和example2不是我正在使用的域,而只是虚拟域。

当我尝试在我的服务器上加载域时,服务器总是向我显示example1的索引文件。

我不知道该怎么做,虚拟主机似乎无法与两个域一起使用。

编辑:我仍然无法弄清楚,这是我的域名:www.asanteniafrica.com www.asanteniafrica.org

我想相信这与域的 .org 和 .com 部分有关,我仍在研究。

virtualhost
  • 2 个回答
  • 372 Views
Martin Hope
Craig Morgan
Asked: 2019-06-28 05:58:46 +0800 CST

其他目录中的 XAMPP VirtualHost 403 禁止错误

  • 1

我根据这个网站创建了一个虚拟主机设置: https ://ourcodeworld.com/articles/read/302/how-to-setup-a-virtual-host-locally-with-xampp-in-ubuntu

这部分设置显然有效。但是,我希望将项目文件夹放在 htdocs 以外的其他位置,以便将工作与我的其他文档一起自动备份到云中。

VirtualHost 文件如下所示:

<VirtualHost 127.0.0.2:80>
    DocumentRoot "/home/dave/Dropbox/Documents/Projects/MyApp"
    ServerName lcover.local
    DirectoryIndex index.html

    <Directory "/home/dave/Dropbox/Documents/Projects/MyApp">
        Options All
        AllowOverride All
        Require all granted
    </Directory>
    ErrorLog "logs/lcover.local-error_log"
    CustomLog "logs/lcover.local-access_log" common
</VirtualHost>

当我去http://lcover.local时,我得到 403 错误。

我很确定这是一个所有者/权限问题,我尝试了几种组合但无法使其正常工作。

我应该如何设置目录和文件的权限?

permissions apache2 virtualhost xampp
  • 1 个回答
  • 2347 Views
Martin Hope
Simone Conti
Asked: 2019-05-10 02:41:23 +0800 CST

为单个虚拟主机设置自签名证书

  • 0

我按照本指南https://www.digitalocean.com/community/tutorials/how-to-create-a-self-signed-ssl-certificate-for-apache-in为我的本地开发服务器生成了一个自签名证书-ubuntu-18-04

当被问到时,我将我的服务器 IP 设置为“通用名称”值。我没有设置防火墙。

完成指南建议的所有其他修改后,我可以访问https://192.168.1.202

这是问题所在

我有一些想要保护的虚拟主机,所以我尝试使用相同的证书在 https 中访问我的网站,但我总是被重定向到 apache 根页面。

这是我的配置文件

/etc/apache2/sites-enabled/kopakabana.conf

<VirtualHost *:80>
    SSLEngine on
    SSLCertificateFile     /etc/ssl/certs/apache-selfsigned.crt
    SSLCertificateKeyFile  /etc/ssl/private/apache-selfsigned.key`
    ....
</VirtualHost>

我哪里错了?

server ssl apache2 virtualhost self-signed
  • 1 个回答
  • 674 Views
Martin Hope
LeonidMew
Asked: 2019-02-27 16:03:56 +0800 CST

软件推荐 - 管理 apache localhost 和 mysql 数据库/用户的工具?

  • 0

我需要软件推荐 - 一个管理 apache 虚拟主机和主机文件的工具,可能还有 mysql 数据库创建(不是最重要的),可能还有可以访问它的 mysql 用户(在 localhost 上运行的所有站点)?

我知道如何配置它,但需要 GUI 面板。它应该是免费的并符合这个最低需求。它可以是 php 应用程序,但由于安全风险更好的系统 gui。

抱歉,我很幸运管理这一点,总是在文本配置中进行配置,但现在需要以简单的方式为其创建新网站和数据库。此外,此工具应管理 dns 或 hosts 文件,因为它仅适用于 localhost。

更新:我的安装不属于 Lamp 或 xamp,但如果可能的话,可以从那里使用一些东西

更新:我尝试了一些 ISP 虚拟主机面板,它们使虚拟主机隔离并具有不同的用户 - 与我想要的相反 - 一个用户,一个 apache,只是许多虚拟主机。

更新:我可以将 *.localhost 添加到 /etc/hosts,因此创建主机并不重要。

software-recommendation php mysql apache2 virtualhost
  • 1 个回答
  • 49 Views
Martin Hope
Samy Massoud
Asked: 2018-10-30 23:34:20 +0800 CST

本地域正在 Ping,但未在浏览器中打开

  • -1

我已经设置了本地域,例如这样

mydomain.test

每当我 ping 这个域时,我都会收到以下信息

64 bytes from localhost (127.0.0.1): icmp_seq=87 ttl=64 time=0.028 ms
64 bytes from localhost (127.0.0.1): icmp_seq=88 ttl=64 time=0.027 ms
64 bytes from localhost (127.0.0.1): icmp_seq=89 ttl=64 time=0.028 ms
64 bytes from localhost (127.0.0.1): icmp_seq=90 ttl=64 time=0.030 ms
64 bytes from localhost (127.0.0.1): icmp_seq=91 ttl=64 time=0.028 ms
64 bytes from localhost (127.0.0.1): icmp_seq=92 ttl=64 time=0.028 ms`

但是,如果我尝试在 chrome 中访问它,我会得到以下信息:

This site can’t be reached mydomain.test’s server IP address could not be found.
Search Google for mydomain test
ERR_NAME_NOT_RESOLVED

我已经使用以下 shell 脚本来设置所有 虚拟主机管理脚本

networking apache2 virtualhost hosts 17.10
  • 1 个回答
  • 838 Views
Martin Hope
user126440
Asked: 2018-10-21 23:10:26 +0800 CST

本地开发设置中 Apache 虚拟主机的连接被拒绝 [重复]

  • 0
这个问题在这里已经有了答案:
当我使用 .dev 域扩展时,虚拟主机没有按预期工作 2 个答案
3年前关闭。

我需要使用特定版本的 PHP (7.1) 设置本地 LAMP。在全新安装的 18.04 中,我首先安装了 Apache 和 MySQL。然后我按照本指南从 ppa:ondrej/php 安装 PHP 并完成安装 phpMyAdmin,它工作正常。

我的 php 安装是

sudo apt install php7.1 libapache2-mod-php7.1 php7.1-mysql php7.1-mbstring

对于我的站点测试,我运行了一个在 16.04 上对我有用的虚拟主机脚本。一切看起来都有效,除了手动必须 chown public_html 目录。我的问题是,尝试在 info.dev 访问我的测试文件会返回页面错误info.dev refused to connect.和ERR_CONNECTION_REFUSED.

PHP 似乎正在工作,因为我成功地infophp()从 apache 测试页面调用。

有人可以提出一些建议吗?

这里有更多信息...

站点可用的 v-hosts 文件

<VirtualHost *:80>

    ServerName info.dev
    ServerAlias www.info.dev
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/info.dev/public_html

    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    #CustomLog ${APACHE_LOG_DIR}/access.log combined

    #Include conf-available/serve-cgi-bin.conf

    <Directory /var/www/info.dev/public_html >
        Options Indexes FollowSymLinks MultiViews
        # AllowOverride All allows using .htaccess
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

</VirtualHost>

/etc/hosts 文件

127.0.0.1   localhost
127.0.1.1   leon

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
127.0.0.1   magento.dev
127.0.0.1   info.dev

我的一些access.log:

127.0.0.1 - - [21/Oct/2018:09:24:05 +0300] "GET / HTTP/1.1" 200 315 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0"
127.0.0.1 - - [21/Oct/2018:09:24:05 +0300] "GET /favicon.ico HTTP/1.1" 404 500 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0"
::1 - - [21/Oct/2018:09:41:18 +0300] "GET / HTTP/1.1" 200 23933 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36"

我的一些error.log

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
[Sun Oct 21 08:40:11.623382 2018] [mpm_prefork:notice] [pid 32239] AH00163: Apache/2.4.29 (Ubuntu) configured -- resuming normal operations
[Sun Oct 21 08:40:11.623406 2018] [core:notice] [pid 32239] AH00094: Command line: '/usr/sbin/apache2'
[Sun Oct 21 09:27:39.337465 2018] [mpm_prefork:notice] [pid 32239] AH00169: caught SIGTERM, shutting down
[Sun Oct 21 09:41:16.361551 2018] [mpm_prefork:notice] [pid 3368] AH00163: Apache/2.4.29 (Ubuntu) configured -- resuming normal operations
[Sun Oct 21 09:41:16.361651 2018] [core:notice] [pid 3368] AH00094: Command line: '/usr/sbin/apache2'

权限

leon@leon:/var/www/info.dev$ ls -l
total 4
drwxr-xr-x 2 leon www-data 4096 loka  21 09:42 public_html
leon@leon:/var/www/info.dev$ cd public_html/
leon@leon:/var/www/info.dev/public_html$ ls -l
total 4
-rw-r--r-- 1 leon leon 22 loka  21 09:42 index.php
leon@leon:/var/www/info.dev/public_html$ 

嗯……不管这是什么

leon@leon:/var/www/info.dev/public_html$ apachectl -S
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
*:80                   is a NameVirtualHost
         default server 127.0.1.1 (/etc/apache2/sites-enabled/000-default.conf:1)
         port 80 namevhost 127.0.1.1 (/etc/apache2/sites-enabled/000-default.conf:1)
         port 80 namevhost info.dev (/etc/apache2/sites-enabled/info.dev.conf:1)
                 alias www.info.dev
         port 80 namevhost magento.dev (/etc/apache2/sites-enabled/magento.dev.conf:1)
                 alias www.magento.dev
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex default: dir="/var/run/apache2/" mechanism=default 
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33 not_used
Group: name="www-data" id=33 not_used
apache2 virtualhost
  • 1 个回答
  • 12035 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve