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
    • 最新
    • 标签
主页 / user-91250

F21's questions

Martin Hope
F21
Asked: 2013-10-29 00:03:28 +0800 CST

具有 A 记录和 NS 记录的子域是否有效?

  • 6

假设我拥有example.com.

然后我在to上创建一个A记录。test.example.com1.1.1.1

然后我在to上创建一个NS记录。test.example.comns1.anotherdnshost.com

在另一个 DNS 主机上,我将A根 ( test.example.com) 的记录添加到2.2.2.2.

客户端查询时,会返回test.example.com哪条记录?A哪个会是更“主导”的A记录?这样的设置有效吗?

domain-name-system
  • 5 个回答
  • 14070 Views
Martin Hope
F21
Asked: 2013-04-09 17:37:38 +0800 CST

nginx gzip 启用但不是 gzipping

  • 5

我在 nginx 1.2.8 上启用了 gzip,但出于某种原因,它没有压缩任何东西。

Nginx 安装信息:

nginx version: nginx/1.2.8
built by gcc 4.7.2 (Ubuntu/Linaro 4.7.2-2ubuntu1) 
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx-1.2.8 --with-http_ssl_module --with-http_realip_module --with-http_gzip_static_module --with-pcre --conf-path=/etc/nginx/nginx.conf --add-module=../headers-more-nginx-module-0.19rc1

配置:

user  www-user;
worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include mime.types;
    default_type  application/octet-stream;
    client_max_body_size 10M;

    sendfile        on;
    keepalive_timeout  65;

    more_clear_headers "Server";

    gzip  on;
    gzip_types text/plain text/css application/json application/javascript application/x-javascript text/javascript text/xml application/xml application/rss+xml application/atom+xml application/rdf+xml;

    server {
        server_name test.com;
        root   /www;
        index index.php index.html index.htm;

        listen       80  default_server;

        rewrite ^/(.*)/$ /$1 permanent; #remove trailing slash

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        include      general/*.conf;

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        location ~ \.php$ {

    fastcgi_intercept_errors on;

    fastcgi_pass   unix:/run/php/php-fpm.sock;

    fastcgi_index index.php;

    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

    include        fastcgi_params;

        }
    }
}

我正在尝试发送一个简单的静态 css 文件。在我的 nginx 配置中,text/css包含在gzip_types.

当我尝试使用 Firefox 获取文件时,fiddler 显示接收到的内容未经过 gzip 压缩:

请求标头:

GET http://test.com/test.css HTTP/1.1
Host: nextdreamtest2.com
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-gb,en;q=0.5
Accept-Encoding: gzip, deflate
Cookie: __utma=237624223.1052931239.1362029000.1365467381.1365469205.16; __utmz=237624223.1362029000.1.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none); __utmc=237624223; __utmb=237624223
Proxy-Authorization: Basic cHJveHk6RTRRWlNlY0JLU3o0OFh4cWpLNkg=
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache

响应标头:

HTTP/1.1 200 OK
Date: Tue, 09 Apr 2013 01:35:07 GMT
Content-Type: text/css
Last-Modified: Thu, 31 May 2012 08:50:00 GMT
Connection: keep-alive
Content-Length: 1688

请注意,即使在服务器上启用了 gzip,也没有Content-Encoding: gzip标头,并且内容类型是配置为 gzip 的类型。


经过更多的调查,我现在更加困惑了。我在运行 nginx 的机器上尝试了 FireFox 20.0(Ubuntu 12.10),并且文件被正确压缩:

Connection  keep-alive
Content-Encoding    gzip <------------------------------
Content-Type    text/html
Date    Tue, 09 Apr 2013 04:23:08 GMT
Set-Cookie  200ceb26807d6bf99fd6f4f0d1ca54d4=7hjir1h44g3dq8hlsihdsrn9v5; path=/; HttpOnly
Transfer-Encoding   chunked  <---------------------

但是,如果我尝试使用 IE10、FireFox 20 和 Chrome 26 以及 Fiddler 检查我的 Windows 8 计算机上的标头以访问服务器,响应永远不会压缩!

Connection  keep-alive
Content-Length  2192 <------------------
Content-Type    text/html
Date    Tue, 09 Apr 2013 04:27:16 GMT

这非常奇怪,因为我在我的 nginx.conf 中没有看到任何会歧视 Windows 8 机器的东西。

是什么原因造成的?

nginx
  • 2 个回答
  • 13073 Views
Martin Hope
F21
Asked: 2013-04-09 16:39:03 +0800 CST

为什么nginx在请求为HEAD时不发送Content-Length头?

  • 2

我正在使用 CURL 测试对我的 nginx 服务器的 HEAD 请求。提供的文件是一个简单的PHP文件。

如果我使用GET:

$ curl -XGET http://test.com/phpinfo.php -I
HTTP/1.1 200 OK
Date: Tue, 09 Apr 2013 00:35:35 GMT
Content-Type: text/html
Connection: keep-alive
Content-Length: 72080

但是,如果我使用HEAD:

$ curl -XHEAD http://test.com/phpinfo.php -I
HTTP/1.1 200 OK
Date: Tue, 09 Apr 2013 00:37:00 GMT
Content-Type: text/html
Connection: keep-alive

为什么如果请求是HEAD,nginx 会省略Content-Length标头?php 脚本非常简单,不会以HEAD任何特殊方式响应。

我可以在 nginx 中打开任何选项,以便它也发送Content-LengthforHEAD吗?

相关nginx信息:

nginx version: nginx/1.2.8
built by gcc 4.7.2 (Ubuntu/Linaro 4.7.2-2ubuntu1) 
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx-1.2.8 --with-http_ssl_module --with-http_realip_module --with-http_gzip_static_module --with-pcre --conf-path=/etc/nginx/nginx.conf --add-module=../headers-more-nginx-module-0.19rc1

配置:

user  www-user;
worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include mime.types;
    default_type  application/octet-stream;
    client_max_body_size 10M;

    sendfile        on;
    keepalive_timeout  65;

    more_clear_headers "Server";

    gzip  on;
    gzip_types text/plain text/css application/json application/javascript application/x-javascript text/javascript text/xml application/xml application/rss+xml application/atom+xml application/rdf+xml;

    server {
        server_name test.com;
        root   /www;
        index index.php index.html index.htm;

        listen       80  default_server;

        rewrite ^/(.*)/$ /$1 permanent; #remove trailing slash

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        include      general/*.conf;

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        location ~ \.php$ {

    fastcgi_intercept_errors on;

    fastcgi_pass   unix:/run/php/php-fpm.sock;

    fastcgi_index index.php;

    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

    include        fastcgi_params;

        }
    }
}
nginx
  • 1 个回答
  • 5843 Views
Martin Hope
F21
Asked: 2012-12-22 04:46:23 +0800 CST

PHP-FPM 无法使用 Samba 共享?

  • 1

我有一个在 Ubuntu Desktop 12.04 上完美运行的 PHP-FPM 和 nginx 设置。Web 服务器的文件从名为 的目录提供,该目录/www设置为root服务器的目录。

最初,/www作为 VMware 共享文件夹安装(因为 Ubuntu 桌面作为来宾操作系统运行)。但是,由于共享文件夹的性能问题(延迟 2 秒!),我正在测试 samba 共享。

我的 Windows 7 主机上有一个名为webfilesshared 的文件夹作为网络共享。我可以/www通过将它作为 cifs 安装在我的中来自动安装它fstab:

//192.168.1.7/webfiles /www cifs credentials=/home/user/.smbcredentials,iocharset=utf8,file_mode=0777,dir_mode=0777 0 0 

/www启动时挂载良好,我可以在 Ubuntu 中创建和删除文件。Nginx 也能够毫无问题地从中提供静态文件。

问题是,一旦我希望它通过 PHP-FPM 为 PHP 文件提供服务器,我就会开始File not found.出错。尽管事实上设置工作得很好,唯一改变的是/www,我现在有一个 samba 共享,而不是挂载在 的共享文件夹。

我对 samba 不是很熟悉,但这可能是什么原因造成的?

nginx
  • 1 个回答
  • 941 Views
Martin Hope
F21
Asked: 2012-12-19 21:03:31 +0800 CST

Nginx + PHP - 没有为 1 个服务器块指定输入文件。其他服务器块工作正常

  • 0

我正在运行带有 nginx 1.2.6 的 Ubuntu Desktop 12.04。PHP 是 PHP-FPM 5.4.9。

这是我的相关部分nginx.conf:

http {
    include       mime.types;

    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;

    server {

       server_name testapp.com;
       root /www/app/www/;
       index index.php index.html index.htm;

       location ~ \.php$ {

        fastcgi_intercept_errors on;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
       }
    }

    server {
        listen       80  default_server;
        root /www
        index index.html index.php;

        location ~ \.php$ {
          fastcgi_intercept_errors on;
          fastcgi_pass   127.0.0.1:9000;
          fastcgi_index  index.php;
          fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
          include        fastcgi_params;
        }
    }
}

相关位来自php-fpm.conf:

; Chroot to this directory at the start. This value must be defined as an
; absolute path. When this value is not set, chroot is not used.
; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
; of its subdirectories. If the pool prefix is not set, the global prefix
; will be used instead.
; Note: chrooting is a great security feature and should be used whenever 
;       possible. However, all PHP paths will be relative to the chroot
;       (error_log, sessions.save_path, ...).
; Default Value: not set
;chroot = 

; Chdir to this directory at the start.
; Note: relative path can be used.
; Default Value: current directory or / when chroot
chdir = /www

在我的主机文件中,我重定向了2 个域:testapp.com和.test.com127.0.0.1

我的网页文件都存储在/www.

从上面的设置来看,如果我访问test.com/phpinfo.phpand test.com/app/www,一切都会按预期进行,并且我会从 PHP 获得输出。

但是,如果我访问testapp.com,我会得到可怕的No input file specified.错误。

所以,在这一点上,我拉出日志文件看看:

2012/12/19 16:00:53 [error] 12183#0: *17 FastCGI sent in stderr: "Unable to open primary script: /www/app/www/index.php (No such file or directory)" while reading response header from upstream, client: 127.0.0.1, server: testapp.com, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "testapp.com"

这让我很困惑,因为我检查了一遍又一遍,/www/app/www/index.php确实存在!这也通过有效的事实得到验证,test.com/app/www/index.php这意味着文件存在并且权限正确。

testapp.com为什么会发生这种情况?仅v-host出现故障的根本原因是什么?


只是对我的调查的更新:

我已经评论出来并chroot缩小问题范围chdirphp-fpm.conf

如果我删除location ~ \.php$块testapp.com,那么 nginx 将向我发送一个包含 PHP 代码的 bin 文件。这意味着在 nginx 方面,一切都很好。

问题是在将文件传递给 PHP-FPM 时一定有什么东西破坏了文件路径。

default_server话虽如此, v-host 可以正常工作是很奇怪的,因为它的根是/www,而 v-host 却不起作用,testapp.com因为根是/www/app/www.

nginx
  • 2 个回答
  • 5886 Views
Martin Hope
F21
Asked: 2012-12-14 21:21:47 +0800 CST

我们需要显式地将 php.ini 的位置传递给 php-fpm 吗?

  • 6

我看到一个奇怪的问题,如果我在启动它时php.ini没有明确地将它传递给它,我就不会被使用。php-fpm

这是我正在使用的新贵脚本:

start on (filesystem and net-device-up IFACE=lo)
stop on runlevel [016]

pre-start script
    mkdir -p /run/php
end script


expect fork
respawn
exec /usr/local/php/sbin/php-fpm --fpm-config /etc/php/php-fpm.conf

如果 PHP 以上述方式启动,php.ini则永远不会使用 my,即使它位于Configuration File (php.ini) Path.

这是来自的相关部分phpinfo():

Configuration File (php.ini) Path           /etc/php/
Loaded Configuration File                   (none)
Scan this dir for additional .ini files     (none)
Additional .ini files parsed                (none) 

php-fpm如果我修改 upstart 脚本的最后一行以 php.ini明确指向:

exec /usr/local/php/sbin/php-fpm --fpm-config /etc/php/php-fpm.conf -c /etc/php/php.ini

然后我们看到php.ini加载了:

Configuration File (php.ini) Path           /etc/php/
Loaded Configuration File                   /etc/php/php.ini
Scan this dir for additional .ini files     (none)
Additional .ini files parsed                (none) 

为什么会这样?这是 php-fpm 中的一个怪癖吗?


次要更新:这似乎也是使用apt-get.

我通过运行以下命令在 Ubuntu Server 12.04 虚拟机中进行了测试安装:

sudo apt-get install nginx php5-fpm

安装后启动了 PHP-FPM 和 nginx,一切似乎都很好。然后我在 nginx 的配置中取消注释 php 的设置并放置一个测试phpinfo()文件来检查 PHP 的设置。

相关位是:

Configuration File (php.ini) Path           /etc/php5/fpm
Loaded Configuration File                   (none)
Scan this dir for additional .ini files     /etc/php5/fpm/conf.d
Additional .ini files parsed                /etc/php5/fpm/conf.d/10-pdo.ini 

我注意到也没有php.ini加载。但是,如果我转到/etc/php5/fpm,我可以看到 aphp.ini存在。我还检查了 PHP-FPM 的启动脚本,并且-c没有使用参数将 ini 文件链接到 PHP。对于希望 php.ini 由 PHP-FPM 自动加载的人来说,这可能会造成混淆。

php-fpm
  • 1 个回答
  • 13253 Views
Martin Hope
F21
Asked: 2012-12-14 20:41:43 +0800 CST

Linux 上的 PHP 共享扩展

  • 0

我正在运行 Ubuntu Server 12.04,并且更喜欢自己编译 PHP 而不是使用apt-get. PHP 作为 PHP-FPM 运行。

编译扩展时,我可以使用诸如此类的方式将其设置为编译为共享扩展--with-bcmath=shared。

将扩展编译为共享有什么好处吗?

我还注意到扩展被编译到一个非常复杂的文件夹中。在我的系统上(我的 php 前缀是/usr/local/php-5.4.9),扩展名以/usr/local/php-5.4.9/lib/php/extensions/no-debug-non-zts-20100525.

是否有一种全局方式来设置文件夹以便所有共享扩展都将在那里编译?我知道我可以做类似的事情,--with-foobar=shared,/usr/local/foobar/ 但必须为每个共享扩展设置扩展文件夹效率低下且容易出错。

php
  • 1 个回答
  • 1060 Views
Martin Hope
F21
Asked: 2012-12-10 19:59:22 +0800 CST

Nginx - 为所有主机启用 PHP

  • 8

我目前正在测试 nginx 并设置了一些虚拟主机,方法是将每个虚拟主机的配置放在一个名为sites-enabled.

然后我要求 nginx 使用以下命令加载所有这些配置文件:

include       C:/nginx/sites-enabled/*.conf;

这是我当前的配置:

http {
    server_names_hash_bucket_size  64;

    include       mime.types;
    include       C:/nginx/sites-enabled/*.conf;
    default_type  application/octet-stream;


    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       80;
        root         C:/www-root;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            index  index.html index.htm index.php;
        }

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }    

    }

    server{
        server_name  localhost;
    }
}

这是虚拟主机的配置之一:

server {
        server_name testsubdomain.testdomain.com

        root C:/www-root/testsubdomain.testdomain.com;
}

问题是对于 testsubdomain.testdomain.com,我无法让 php 脚本运行,除非我为它定义了一个带有 fastcgi 参数的位置块。

我想做的是能够为此服务器上的所有托管站点启用 PHP(无需添加带有 fastcgi 参数的 PHP 位置块)以实现可维护性。这样一来,如果我需要更改 PHP 的任何 fastcgi 值,我只需在 1 个位置更改它。

这对 nginx 来说是可能的吗?如果是这样,如何做到这一点?

php
  • 1 个回答
  • 3620 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