为家庭网络配置 Apache

为家庭网络配置 Apache

我使用的是 U13.10,并已按照 Tux Tweaks 说明安装了 LAMP(请参阅他们的网站——显然我还不能发布实际链接)。然后我按照 Tux Tweaks 的说明配置 Apache 以进行自定义主目录访问:(同样,不允许发布链接,但请参阅“如何在 Linux 上配置 Apache Web 服务器”。)所有这些都很好,我的主文件夹中有各种目录,只需转到以下位置即可访问,例如,

http://mywebdevdir/

指向 /home/me/mywebdevdir/

我的问题是,我有一个运行开放 ssh 服务器的家庭网络,而该计算机的 apache 无法执行此操作。如果 ssh 服务器位于 192.168.0.x,那么http://192.168.0.x/mywebdevdir/无法访问/查看——尽管http://192.168.0.x/转到默认的 /var/www/... 就好了。有什么想法可以扩展配置以通过家庭网络访问主目录吗?

答案1

我不太确定你在问什么,但如果我没看错的话。你想使用机器的 IP 地址从家庭网络的任何地方直接访问你的网站吗?

如果是这种情况,请按照以下步骤进行编辑000-默认.conf在后面添加您的网站文件夹名称文件根目录 /var/www/。保存并退出文件。重新启动 Apache 服务器并在网络中任何家庭系统的浏览器中输入 IP 地址。您的索引页将加载。如果您需要远程访问,则需要在家庭路由器的虚拟服务器部分中添加 Web 服务器的 IP 地址,并确保端口设置为 80。

$ cd /etc/apache2/sites-enabled/

$ ls
000-default.conf

$ cat 000-default.conf

<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 www.example.com

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/mywebsite

    # 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
</VirtualHost>

相关内容