search
HomeBackend DevelopmentPHP TutorialIIS下PHP运行环境搭建与网页服务器故障排查方法

一、对于php页面完全无法访问的情况

1、确认是php的问题还是iis等服务器的问题

判断方法,在目录下放一个静态文件,通过浏览器判断这个静态文件可否访问。若可以访问,即为php问题。

如果是IIS的问题,常见的有两种情况,一个判断的利器是telnet。

linux的telnet其实更加好用,因为默认是打开回显的。而windows,则需要用 set localecho,否则看不到输入的文字

1.1 防火墙禁止80端口

进入telnet后,输入指令,open 域名 80

如:open www.baidu.com 80

如果能连接上,会出现一个黑色屏幕,等待输入

提示所谓的无法打开到主机的连接,在端口80失败,则表示这个端口不可达。可能的原因有:DNS服务器没有这个域名(用nslookup查),远程主机没有开启或禁止连接(用ping等命令查),以及这里说的,防火墙没有打开80端口。

1.2 服务器上目标目录的权限设置不正确

这种情况下,一般会提示要求登录的对话框,不至于显示不出来页面

1.3 其他问题

假设要访问的主机是www.baidu.com ,那么,用如下命令查:

> telnet www.baidu.com 80

会出来一个黑屏幕,这个时候速度要快,因为服务器可能不会等你输入,他期待的是一个迅速的输入。(可以先在记事本里头打好,然后粘贴进去),直接telnet可能没有localecho,可能需要盲打

指令例子,括号内的字符不要输入:

GET / HTTP/1.1 (回车)

Host: www.baidu.com (回车)

(回车)

注意,在host行后有两个回车。

这个是用telnet模拟浏览器对目标主机的请求。如图:

注意,回复头的内容拥有非常丰富的信息,如200表示请求成功。500表示内部服务器错误等,具体信息可以看看相关文档。

1.4 一点点背景知识

以上的步骤涉及到浏览器发起请求的过程,介绍下或许会有帮助:

1、 你在浏览器的地址栏输入域名,并按下回车。

2、浏览器请求DNS服务器将域名转换为IP地址——注意,这一步还和你的网页服务器(IIS或者APACHE)没有任何关系。

3、浏览器向你的网页服务器请求连接——相当于我们telnet 80端口。当然, 如果你指定了端口号,他就会连接你指定的端口。但是默认端口是80,这个是rfc规定的http的端口,https端口是443,这个过程更加复杂,有密钥交换和加解密的过程,因此没办法用这种方法做trouble shooting,建议在这个阶段先搞定http的再说。

4、建立了一条连接,服务器等待浏览器发请求头,浏览器发请求头。请求头以一个空行结束。

5、请求头格式如下:

方法【空格】请求路径(不包含域名,如/a.html或者/)【空格】协议

HOST:请求的域名

例如:

GET /index.php HTTP/1.1 (回车)

Host: www.baidu.com (回车)

(回车)

请求头可能有其他信息,例如,提交的信息,不过对于我们而言,这个就够了。

方法,常用的就是get和post,一般请求网页用get,提交信息用post。

6、服务器处理并返回数据,包括头和网页体。

HTTP/1.1 200 OK

这行开头,包括了协议,以及错误代码(或成功代码),错误代码解释。

对于浏览器而言,可能会有不少信息有用,但对于我们而言,知道代码和错误代码解释就很有必要了。

信息体里头,可能会有很多别的东西,例如对这个信息的详细解释等。php的错误报告开启的时候,也会在这里头报告相关问题。

2、确认php扩展加载。

2.1isapi扩展

对于isapi扩展,在主目录的配置下:

找到php:

若没有,添加之。

2.2对于fastcgi方法

另一种加载方法是fastcgi,这种方法需要判断是fastcgi引擎问题还是php问题,判断方法是跳过fastcgi,直接用cgi方式加载php.exe。

二、php页面部分能访问的情况

简单的判断是不是这种情况的方法是,新建一个php文件,输入如下内容:

注意大小写和空格必须正确。正常情况下回输出一个phpinfo页面,如下图所示:

该页面非常有用。

1、判断php文件加载正确性

确认Loaded Configuration File里头加载的是不是你想要他加载的php.ini文件。有可能修改该文件错误。

2、判断mysql等扩展是否加载

很多时候可能会有这种情况,就是页面白屏,但是明显的,页面加载了一半。例如,tittle部分已经显示出来了,包括supersite、discuz等站点很可能出现这种情况。

判断方法很简单,页面上搜索mysql,要是没有如下内容就是没有加载

[1]   [2]    下一页

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
11 Best PHP URL Shortener Scripts (Free and Premium)11 Best PHP URL Shortener Scripts (Free and Premium)Mar 03, 2025 am 10:49 AM

Long URLs, often cluttered with keywords and tracking parameters, can deter visitors. A URL shortening script offers a solution, creating concise links ideal for social media and other platforms. These scripts are valuable for individual websites a

Introduction to the Instagram APIIntroduction to the Instagram APIMar 02, 2025 am 09:32 AM

Following its high-profile acquisition by Facebook in 2012, Instagram adopted two sets of APIs for third-party use. These are the Instagram Graph API and the Instagram Basic Display API.As a developer building an app that requires information from a

Working with Flash Session Data in LaravelWorking with Flash Session Data in LaravelMar 12, 2025 pm 05:08 PM

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

Build a React App With a Laravel Back End: Part 2, ReactBuild a React App With a Laravel Back End: Part 2, ReactMar 04, 2025 am 09:33 AM

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

Simplified HTTP Response Mocking in Laravel TestsSimplified HTTP Response Mocking in Laravel TestsMar 12, 2025 pm 05:09 PM

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

cURL in PHP: How to Use the PHP cURL Extension in REST APIscURL in PHP: How to Use the PHP cURL Extension in REST APIsMar 14, 2025 am 11:42 AM

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

12 Best PHP Chat Scripts on CodeCanyon12 Best PHP Chat Scripts on CodeCanyonMar 13, 2025 pm 12:08 PM

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

Announcement of 2025 PHP Situation SurveyAnnouncement of 2025 PHP Situation SurveyMar 03, 2025 pm 04:20 PM

The 2025 PHP Landscape Survey investigates current PHP development trends. It explores framework usage, deployment methods, and challenges, aiming to provide insights for developers and businesses. The survey anticipates growth in modern PHP versio

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment