ubuntu - 服务器上没有域名的 Ubuntu Apache2 站点上的别名

标签 ubuntu server alias

我将此方法用于 3 个确实拥有域名的网站,并且一切正常。目前我正在开发另一个没有域名但可以通过服务器 IP 访问的网站,所以:

195.111.111.111/mywebsite.com/

而不是 http://mywebsite.com/

我猜你明白了:)无论如何,所有网站都共享同​​一个上传文件夹,因为它有 300.000 多张照片,我不想上传多份。

它适用于所有网站,除了这个没有域名的网站,我猜它的工作方式不同。

当我去:

195.111.111.111/mywebsite.com/product-image

我只是在我的 php 文件中收到一个错误,找不到 require once,这显然是正确的,但重点是......我的 PHP 甚至不应该能够从这个 URL 获得请求,因为我有一个别名,但它转到 PHP。

谁能告诉我我做错了什么?我当前的配置文件如下:

ServerAdmin webmaster@localhost
DocumentRoot /var/www/mywebsite.nl/

#ServerName mywebsite.nl
#ServerAlias www.mywebsite.nl

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

Alias "/product-image" "/var/www/uploads"

<Directory /var/www/mywebsite.nl/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>

RewriteEngine on
RewriteCond %{SERVER_NAME} =mywebsite.nl [OR]
RewriteCond %{SERVER_NAME} =mywebsite.nl
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

最佳答案

我在 Ubuntu 服务器上安装 SquirrelMail 后,它编写了一个如下所示的 Apache 配置文件:

Alias /squirrelmail /usr/share/squirrelmail

<Directory /usr/share/squirrelmail>
  Options FollowSymLinks
  php_flag register_globals off
  DirectoryIndex index.php
</Directory>

如果我们将其应用到您的项目中,我们将获得如下所示的 Apache 配置文件:

ServerAdmin webmaster@localhost
DocumentRoot /var/www/mywebsite.nl/

ServerName mywebsite.nl
ServerAlias www.mywebsite.nl

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

Alias /product-image /var/www/uploads

<Directory /var/www/mywebsite.nl>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Require all granted
</Directory>

<Directory /var/www/uploads>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Require all granted
</Directory>

我所做的更改:

  1. 我更改了别名路径,现在它们没有引号。
  2. 我更改了 Order allow,denyallow from allRequire all granted
  3. 然后我创建了一个 <Directory... /var/www/uploads 指令.

关于ubuntu - 服务器上没有域名的 Ubuntu Apache2 站点上的别名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49995539/

相关文章:

android - 尝试获取 adb 版本时没有这样的文件或目录

node.js - 为什么我的服务器上列出了多个 PM2 进程?

audio - 将音频从 WebAudio API 广播到服务器端然后到连接的客户端的方法

linux - CentOS中bash启动时如何自动设置别名?

linux - 双引号在别名中转义

ubuntu - 使用 Gstreamer 和 easycap 将摄像头视频从 raspberry 流式传输到 Ubuntu 机器

linux - crontab 无法运行以指定时间间隔获取 url 的 shell 脚本

php - exec php 需要很长时间

linux - 即使安装后也没有名为 numpy 的模块

mysql - 避免表中的列标题冲突加入 peewee