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
    • 最新
    • 标签
主页 / server / 问题

问题[alias](server)

Martin Hope
Dom
Asked: 2021-01-22 08:26:17 +0800 CST

如何设置将在 shebang 中受到尊重的命令别名

  • 0

我在我的 Linux 服务器上运行多个版本的 PHP。我在 bashrc 中添加了一个别名,以将php命令指向特定版本alias php='/usr/bin/php7.3'。

当我实际使用 php 命令执行 PHP 脚本时,这可以按预期工作,例如php myscript.php

但是,如果我创建myscript.php一个可执行文件并将 shebang#!/usr/bin/env php放在顶部,它会使用默认版本的 PHP 执行脚本,并且不使用我的 bashrc 中定义的别名。

我知道我可以将 shebang 更改为#!/usr/bin/env /usr/bin/php7.3,但我需要全局,而不是逐个文件。

php是否可以为shebang 中尊重的命令设置别名?

linux php bash bashrc alias
  • 1 个回答
  • 1237 Views
Martin Hope
YorSubs
Asked: 2020-11-15 06:31:09 +0800 CST

bash 控制台上的热字串

  • 1

我可以做这样的事情来给常用的东西加上别名alias iii='sudo yum install',而且效果很好,但是当我使用它时能够在命令行上扩展一个命令真是太好了。当然,我可以键入alias以显示所有别名,甚至command -V <command>可以扩展别名或函数,但有时查看命令的完整布局比查看别名感觉更好。

我认为这在 bash 中是可能的,但我不知道如何。对于上面的例子,有人可以描述如何输入i, then i, then i, then space,并为此立即删除 3x i 以替换所有内容,sudo yum install 之后我可以继续输入我想要的内容?

linux bash console alias
  • 1 个回答
  • 112 Views
Martin Hope
Repox
Asked: 2020-09-30 05:39:10 +0800 CST

Nginx - 根和别名之间的区别?

  • 0

我的目标是让 Laravel 安装与作为静态内容生成的 Nuxt 应用程序一起运行。

当位置以 . 开头时,我希望 Laravel 可用/api。这按预期工作。

对于任何其他请求,我想让 Nginx 从另一个文件夹中为我提供静态内容。

root /var/www/html/public/dist;我可以通过在第 18 行 ( )更改文档根目录并将以下配置更改为下面try_files配置中的状态来实现这一点。

我试着换掉root,alias这给了我一些时髦的结果。我从 Nginx 收到 500 服务器响应,错误日志中有以下输出:

2020/09/29 13:28:17 [error] 7#7: *3 rewrite or internal redirection cycle while internally redirecting to "/index.html", client: 172.21.0.1, server: _, request: "GET /my/fake/url HTTP/1.1", host: "localhost"
172.21.0.1 - - [29/Sep/2020:13:28:17 +0000] "GET /claims/creat HTTP/1.1" 500 580 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36" "-"

我有以下配置(在 Docker 容器内运行)。

server {
    listen 80 default_server;

    root /var/www/html/public;

    index index.html index.htm index.php;

    server_name _;

    charset utf-8;

    location = /favicon.ico { log_not_found off; access_log off; }
    location = /robots.txt  { log_not_found off; access_log off; }

    error_page 404 /index.php;

    location / {
        alias /var/www/html/public/dist;
        try_files $uri $uri/ /index.html;
        error_page 404 /400.html;
    }

    location ~ /api {
        try_files $uri $uri/ /index.php$is_args$args;
    }

    location ~ \.php$ {
        fastcgi_pass php:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }
    
    location ~ /\.ht {
        deny all;
    }
}

我不完全确定有什么区别,这也让我质疑我是否应该使用alias或root在我的情况下,我希望能在理解这一点方面提供一些帮助。

nginx alias documentroot
  • 1 个回答
  • 6420 Views
Martin Hope
Zereges
Asked: 2020-09-27 04:00:18 +0800 CST

AllowOverride 不适用于别名站点

  • 0

我有两个域johny.com和alice.com一个管理它们的网络服务器(apache)。Web 文件位于/var/www/johny.com和中,/var/www/alice.com并被配置为两个具有适当ServerName和DocumentRoot. 现在,Alice 想要保护她在网络上的一个文件不被任何人看到。她介绍了一个.htaccess文件,内容如下

<Files "private.txt">
  Require all denied
</Files>

并且还在她的虚拟主机的 apache 配置中添加了以下内容

<Directory /var/www/alice.com>
   Options Indexes FollowSymLinks
   AllowOverride All
</Directory>

并且没有人可以访问alice.com/private.txt. 到目前为止,一切都很好。

现在 John 决定通过更改他的 vhost apache 配置来为 Alice 的 web 提供一个别名

Alias "/alice" "/var/www/alice.com"

任何人都可以在 上看到 Alice 的网页john.com/alice。但是任何人也可以看到爱丽丝私人文件的内容。

alice.com/private.txt给出 403 禁止。
john.com/alice/private.txt显示文件的内容。

这是怎么回事?不通过指令AllowOverride传播?Alias我们应该如何解决这个问题?阿帕奇版本是Apache/2.4.38 (Debian). 将乱码放入.htaccess文件中只会在 500 Internal Server Error 上给出 500 Internal Server Error alice.com,而不是 on john.com/alice,所以似乎.htaccess根本不考虑别名。

alias apache2
  • 1 个回答
  • 1190 Views
Martin Hope
Nick
Asked: 2017-01-25 02:17:02 +0800 CST

BIND 的 ANAME / ALIAS 记录

  • 7

我使用 BIND 为大约 15,000 个域名运行一些 DNS 服务器。一些客户希望开始使用全站点内容交付 CDN,对此的要求是支持使用 ANAME / ALIAS DNS 记录,现在一些大型 DNS 提供商都支持这些记录。

有没有办法在 BIND 之上实现这些记录类型,或者你能建议如何引入这种类型的功能吗?

domain-name-system bind alias
  • 1 个回答
  • 11312 Views
Martin Hope
Ginger
Asked: 2016-10-27 12:37:45 +0800 CST

如何把它变成别名?

  • -2

我经常使用这个命令:

grep -rnw 驴 | grep 市场 | 剪切-c -80

如何在 Linux 上将其更改为别名?

我试过了:

alias search='grep -rnw $1 | grep $2 | cut -c -200'

但是当我运行它时

search hello world

它给了我:

cut: Usage: grep [OPTION]... PATTERN [FILE]...
hello: No such file or directory
cut: Try 'grep --help' for more information.
world: No such file or directory
Usage: grep [OPTION]... PATTERN [FILE]...
Try 'grep --help' for more information.
linux grep alias
  • 1 个回答
  • 638 Views
Martin Hope
Morgan Courbet
Asked: 2016-10-13 05:53:58 +0800 CST

是否可以链接相关的 MX 记录?

  • 0

我需要制作一个“MX链”,如下所示:

@alias.mydomain.net --> @mail.mydomain.net --> @smtp.targetdomain.net
         (1)                     (2)                      (3)
  • 假设 SMTP 服务器存在于smtp.targetdomain.net:

    $ host smtp.targetdomain.net
    smtp.targetdomain.net has address 1.2.3.4
    
  • 说我自己的域名是mydomain.net. (2)目前,在和之间的跳转 (3)使用以下配置:

    mail 10800 IN MX 1 smtp.targetdomain.net.
    

    让我们检查一下:

    $ host mail.mydomain.net
    mail.mydomain.net mail is handled by 1 smtp.targetdomain.net.
    

    收到一封发送到 [email protected] 的电子邮件。

  • (1)但是在和之间的跳转(2)不适用于以下配置:

    alias 10800 IN MX 1 mail
    mail 10800 IN MX 1 smtp.targetdomain.net.
    

    让我们检查一下:

    $ host alias.mydomain.net
    alias.mydomain.net mail is handled by 1 mail.mydomain.net.
    

    未收到发送到 [email protected] 的电子邮件,并将发送失败邮件发送回发件人:

    <#5.0.0 smtp; 5.1.2 - 错误的目标主机“DNS Hard Error looking up alias.mydomain.net (MX): all A records of the domain's MX records are invalid”(投递尝试:0)>#SMTP#

有没有可能做这样的MX记录链?我是否需要改用以下配置?

alias 10800 IN MX 1 smtp.targetdomain.net.
mail 10800 IN MX 1 smtp.targetdomain.net.
domain-name-system mx-record alias
  • 1 个回答
  • 389 Views
Martin Hope
user325985
Asked: 2016-06-18 10:09:21 +0800 CST

让 2 个不同的应用程序在同一主机上使用 2 个不同的 ip 和相同的端口

  • 0

我想在同一台主机上运行一个应用程序x.x.x.x:80,另一个在y.y.y.y:80同一主机上运行。我从 ovh 购买了 2 个 ip,想知道如何操作。

我发现了这些: Debian/OVH: How to configure multiple Failover IP on the same Xen (Debian) Virtual Machine?

但它只是让 ip yyyy 与 xxxx 相同

networking debian ip alias ovh
  • 3 个回答
  • 2217 Views
Martin Hope
jwerre
Asked: 2016-06-10 08:08:11 +0800 CST

Nginx 别名不起作用

  • 0

我正在尝试将 location 的所有流量传递^/[a-z0-9]{24}$给不同根目录的 index.html。我的配置设置如下:

server {
    listen 80;
    server_name example.com;
    return 301 https://$host$request_uri;
}

server {

    listen 443 ssl;

    server_name example.com;
    root /Users/me/sites/store_front/static;
    index index.html;

    try_files $uri $uri/ $uri.html =404;

    location ~ "^/[a-z0-9]{24}$" {
        alias /Users/me/web_app/static;
        try_files $uri index.html;
    }
}

出于某种原因,当我卷曲这个网址时,我得到一个 404:

$ curl -I https://example.com/55c898e7faa137f42409d403

HTTP/1.1 404 Not Found
Server: nginx/1.8.0
Content-Type: text/html; charset=UTF-8
Content-Length: 168
Connection: keep-alive

有谁知道如何让这个别名工作?

更新:

需要注意的是,我需要 index.html 中的所有相对 url 才能正确加载:

<link href="/styles/main.css" rel="stylesheet" type="text/css"
<script src="/javascript/main.js"></script>

这些文件实际上存在于web_app目录中,但 nginx 尝试从中加载它们store_front

谢谢

nginx alias
  • 1 个回答
  • 1651 Views
Martin Hope
nairdaen
Asked: 2012-06-06 12:30:40 +0800 CST

如何在 Powershell 中使用 MS DOS 定义的别名

  • 1

我有一些以 MS Dos 风格定义的别名,如何从 Powershell 调用这些别名?当我在 Powershell 提示符下键入“别名”时,我可以看到我的别名在那里定义,但是当我尝试通过键入别名来调用它们时,Powershell 会抱怨一条消息,如“术语‘whatever’不被识别为名称命令...”。

powershell alias ms-dos aliases
  • 1 个回答
  • 1270 Views

Sidebar

Stats

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

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

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

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve