nginx关于php的二级域名+子目录问题
Jun 06, 2016 pm 08:35 PM
具体环境为nginx+php,欲配置phpmyadmin。
现在的问题是访问主机域名,html目录下php可以正常运行。但是访问phpmyadmin.xxxxx.com域名,html/phpmyadmin下文件会通过浏览器下载。各种搜索改参数无果,求支援。
具体nginx.conf参数如下:
<code> server { listen 80; server_name localhost; root html; access_log logs/host.access.log main; location / { } #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_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ /\.ht { deny all; } } include vhost/*.conf; </code>
vhosh/*.conf配置如下
<code>server { listen 80; server_name phpmyadmin.xxxxx.com; root html/phpmyadmin; #charset koi8-r; access_log logs/phpmyadmin.access.log main; #error_log log/phpmyadmin.error.log main; location / { index index.html index.htm index.php; } } </code>
回复内容:
具体环境为nginx+php,欲配置phpmyadmin。
现在的问题是访问主机域名,html目录下php可以正常运行。但是访问phpmyadmin.xxxxx.com域名,html/phpmyadmin下文件会通过浏览器下载。各种搜索改参数无果,求支援。
具体nginx.conf参数如下:
<code> server { listen 80; server_name localhost; root html; access_log logs/host.access.log main; location / { } #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_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ /\.ht { deny all; } } include vhost/*.conf; </code>
vhosh/*.conf配置如下
<code>server { listen 80; server_name phpmyadmin.xxxxx.com; root html/phpmyadmin; #charset koi8-r; access_log logs/phpmyadmin.access.log main; #error_log log/phpmyadmin.error.log main; location / { index index.html index.htm index.php; } } </code>
在你的 phpmyadmin.xxxxx.com
的 vhost 里缺少 fastcgi 的配置,当然不对啦。把你在 localhost
的 vhost 里配置的内容复制过来就差不多对了。
就是以下这些:
<code>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; } </code>
huandu已经解答了
你没有配置php解析部分,所谓nginx不知道你要通过什么方式去解析
话说你用的lnmp.org的安装包,不太需要自己修改配置文件吧,顶多加个include *.conf用来解析urlwrite

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

How To Set Up Visual Studio Code (VS Code) for PHP Development
