Hướng dẫn how do i start a local php server? - làm cách nào để khởi động một máy chủ php cục bộ?

Bạn cũng có thể tạo máy chủ của riêng mình trong PHP bằng mã!

$ file = "src/browser.php"; // tệp này được mở với máy chủ khi nó bắt đầu!

    } else {

        $filearray = array();
        $filearray = explode("/", $file);
        $file = $filearray[1];
    }

echo $fetchArray[0] . " Request " . $file . "\n"; 

// <-- Control Header
$output = "";
$Header = "HTTP/1.1 200 OK \r\n" .
"Date: Fri, 31 Dec 1999 23:59:59 GMT \r\n" .
"Content-Type: text/html \r\n\r\n";

$Content = file_get_contents($file);
$output = $Header . $Content;

    socket_write($client,$output,strlen($output));
    socket_close($client);

}
print('server running..');

Chạy mã này sau đó mở trình duyệt đến localhost: 443 hoặc bất kỳ cổng nào bạn chọn

Cảnh báo

Máy chủ web này được thiết kế để hỗ trợ phát triển ứng dụng. Nó cũng có thể hữu ích cho các mục đích thử nghiệm hoặc cho các trình diễn ứng dụng được chạy trong môi trường được kiểm soát. Nó không nhằm mục đích là một máy chủ web đầy đủ tính năng. Nó không nên được sử dụng trên một mạng công cộng.

CLI SAPI cung cấp một máy chủ web tích hợp.

Máy chủ web chỉ chạy một quy trình duy nhất, vì vậy các ứng dụng PHP sẽ bị đình trệ nếu yêu cầu bị chặn.

Yêu cầu URI được phục vụ từ thư mục làm việc hiện tại nơi PHP được bắt đầu, trừ khi tùy chọn -T được sử dụng để chỉ định một gốc tài liệu rõ ràng. Nếu một yêu cầu URI không chỉ định một tệp, thì index.php hoặc index.html trong thư mục đã cho được trả về. Nếu không có tệp nào tồn tại, việc tìm kiếm index.php và index.html sẽ được tiếp tục trong thư mục cha và cứ thế cho đến khi tìm thấy một hoặc gốc tài liệu đã đạt được. Nếu tìm thấy một index.php hoặc index.html, nó sẽ được trả về và $ _server ['path_info'] được đặt thành phần kéo dài của URI. Nếu không, một mã phản hồi 404 được trả về.

Nếu một tệp PHP được đưa ra trên dòng lệnh khi máy chủ web được khởi động, nó được coi là tập lệnh "bộ định tuyến". Tập lệnh được chạy ở đầu mỗi yêu cầu HTTP. Nếu tập lệnh này trả về

    } else {

        $filearray = array();
        $filearray = explode("/", $file);
        $file = $filearray[1];
    }

echo $fetchArray[0] . " Request " . $file . "\n"; 

// <-- Control Header
$output = "";
$Header = "HTTP/1.1 200 OK \r\n" .
"Date: Fri, 31 Dec 1999 23:59:59 GMT \r\n" .
"Content-Type: text/html \r\n\r\n";

$Content = file_get_contents($file);
$output = $Header . $Content;

    socket_write($client,$output,strlen($output));
    socket_close($client);

}
print('server running..');
0, thì tài nguyên được yêu cầu sẽ được trả về. Nếu không, đầu ra của tập lệnh được trả về trình duyệt.
    } else {

        $filearray = array();
        $filearray = explode("/", $file);
        $file = $filearray[1];
    }

echo $fetchArray[0] . " Request " . $file . "\n"; 

// <-- Control Header
$output = "";
$Header = "HTTP/1.1 200 OK \r\n" .
"Date: Fri, 31 Dec 1999 23:59:59 GMT \r\n" .
"Content-Type: text/html \r\n\r\n";

$Content = file_get_contents($file);
$output = $Header . $Content;

    socket_write($client,$output,strlen($output));
    socket_close($client);

}
print('server running..');
0
, then the requested resource is returned as-is. Otherwise the script's output is returned to the browser.

Các loại MIME tiêu chuẩn được trả về cho các tệp có phần mở rộng: .3gp, .apk, .avi, .bmp, .css, .csv, .doc, .docx, .flac, .gif, .gz, .gzip, .htm,. HTML, .ICS,. không , .wmv, .xls, .xlsx, .xml, .xsl, .xsd và .zip.

Changelog: Các loại MIME được hỗ trợ (Tiện ích mở rộng tệp)
Phiên bảnSự mô tả
5.5.12 .xml, .xsl và .xsd
5.5.7 , , .mpeg, .mov, .odp, .ods, .odt, .oga, .pdf, .pptx, .pps, .qt, .swf, .tar, .text, .tif, .wav, .wmv,. XLS, .xlsx và .zip
5.5.5 .pdf
5.4.11 .ogg, .ogv và .webm
5.4.4 .htm và .svg
Thay đổi
Phiên bảnSự mô tả
7.4.0 .xml, .xsl và .xsd

Cảnh báo

Máy chủ web này được thiết kế để hỗ trợ phát triển ứng dụng. Nó cũng có thể hữu ích cho các mục đích thử nghiệm hoặc cho các trình diễn ứng dụng được chạy trong môi trường được kiểm soát. Nó không nhằm mục đích là một máy chủ web đầy đủ tính năng. Nó không nên được sử dụng trên một mạng công cộng.

CLI SAPI cung cấp một máy chủ web tích hợp.

$ cd ~/public_html
$ php -S localhost:8000

Máy chủ web chỉ chạy một quy trình duy nhất, vì vậy các ứng dụng PHP sẽ bị đình trệ nếu yêu cầu bị chặn.

PHP 5.4.0 Development Server started at Thu Jul 21 10:43:28 2011
Listening on localhost:8000
Document root is /home/me/public_html
Press Ctrl-C to quit

Yêu cầu URI được phục vụ từ thư mục làm việc hiện tại nơi PHP được bắt đầu, trừ khi tùy chọn -T được sử dụng để chỉ định một gốc tài liệu rõ ràng. Nếu một yêu cầu URI không chỉ định một tệp, thì index.php hoặc index.html trong thư mục đã cho được trả về. Nếu không có tệp nào tồn tại, việc tìm kiếm index.php và index.html sẽ được tiếp tục trong thư mục cha và cứ thế cho đến khi tìm thấy một hoặc gốc tài liệu đã đạt được. Nếu tìm thấy một index.php hoặc index.html, nó sẽ được trả về và $ _server ['path_info'] được đặt thành phần kéo dài của URI. Nếu không, một mã phản hồi 404 được trả về.

PHP 5.4.0 Development Server started at Thu Jul 21 10:43:28 2011
Listening on localhost:8000
Document root is /home/me/public_html
Press Ctrl-C to quit.
[Thu Jul 21 10:48:48 2011] ::1:39144 GET /favicon.ico - Request read
[Thu Jul 21 10:48:50 2011] ::1:39146 GET / - Request read
[Thu Jul 21 10:48:50 2011] ::1:39147 GET /favicon.ico - Request read
[Thu Jul 21 10:48:52 2011] ::1:39148 GET /myscript.html - Request read
[Thu Jul 21 10:48:52 2011] ::1:39149 GET /favicon.ico - Request read

Nếu một tệp PHP được đưa ra trên dòng lệnh khi máy chủ web được khởi động, nó được coi là tập lệnh "bộ định tuyến". Tập lệnh được chạy ở đầu mỗi yêu cầu HTTP. Nếu tập lệnh này trả về

    } else {

        $filearray = array();
        $filearray = explode("/", $file);
        $file = $filearray[1];
    }

echo $fetchArray[0] . " Request " . $file . "\n"; 

// <-- Control Header
$output = "";
$Header = "HTTP/1.1 200 OK \r\n" .
"Date: Fri, 31 Dec 1999 23:59:59 GMT \r\n" .
"Content-Type: text/html \r\n\r\n";

$Content = file_get_contents($file);
$output = $Header . $Content;

    socket_write($client,$output,strlen($output));
    socket_close($client);

}
print('server running..');
0, thì tài nguyên được yêu cầu sẽ được trả về. Nếu không, đầu ra của tập lệnh được trả về trình duyệt.

Các loại MIME tiêu chuẩn được trả về cho các tệp có phần mở rộng: .3gp, .apk, .avi, .bmp, .css, .csv, .doc, .docx, .flac, .gif, .gz, .gzip, .htm,. HTML, .ICS,. không , .wmv, .xls, .xlsx, .xml, .xsl, .xsd và .zip.

$ cd ~/public_html
$ php -S localhost:8000 -t foo/

Máy chủ web chỉ chạy một quy trình duy nhất, vì vậy các ứng dụng PHP sẽ bị đình trệ nếu yêu cầu bị chặn.

PHP 5.4.0 Development Server started at Thu Jul 21 10:50:26 2011
Listening on localhost:8000
Document root is /home/me/public_html/foo
Press Ctrl-C to quit

Yêu cầu URI được phục vụ từ thư mục làm việc hiện tại nơi PHP được bắt đầu, trừ khi tùy chọn -T được sử dụng để chỉ định một gốc tài liệu rõ ràng. Nếu một yêu cầu URI không chỉ định một tệp, thì index.php hoặc index.html trong thư mục đã cho được trả về. Nếu không có tệp nào tồn tại, việc tìm kiếm index.php và index.html sẽ được tiếp tục trong thư mục cha và cứ thế cho đến khi tìm thấy một hoặc gốc tài liệu đã đạt được. Nếu tìm thấy một index.php hoặc index.html, nó sẽ được trả về và $ _server ['path_info'] được đặt thành phần kéo dài của URI. Nếu không, một mã phản hồi 404 được trả về.

Nếu một tệp PHP được đưa ra trên dòng lệnh khi máy chủ web được khởi động, nó được coi là tập lệnh "bộ định tuyến". Tập lệnh được chạy ở đầu mỗi yêu cầu HTTP. Nếu tập lệnh này trả về

    } else {

        $filearray = array();
        $filearray = explode("/", $file);
        $file = $filearray[1];
    }

echo $fetchArray[0] . " Request " . $file . "\n"; 

// <-- Control Header
$output = "";
$Header = "HTTP/1.1 200 OK \r\n" .
"Date: Fri, 31 Dec 1999 23:59:59 GMT \r\n" .
"Content-Type: text/html \r\n\r\n";

$Content = file_get_contents($file);
$output = $Header . $Content;

    socket_write($client,$output,strlen($output));
    socket_close($client);

}
print('server running..');
0, thì tài nguyên được yêu cầu sẽ được trả về. Nếu không, đầu ra của tập lệnh được trả về trình duyệt.

    } else {

        $filearray = array();
        $filearray = explode("/", $file);
        $file = $filearray[1];
    }

echo $fetchArray[0] . " Request " . $file . "\n"; 

// <-- Control Header
$output = "";
$Header = "HTTP/1.1 200 OK \r\n" .
"Date: Fri, 31 Dec 1999 23:59:59 GMT \r\n" .
"Content-Type: text/html \r\n\r\n";

$Content = file_get_contents($file);
$output = $Header . $Content;

    socket_write($client,$output,strlen($output));
    socket_close($client);

}
print('server running..');
1

$ php -S localhost:8000 router.php

Các loại MIME tiêu chuẩn được trả về cho các tệp có phần mở rộng: .3gp, .apk, .avi, .bmp, .css, .csv, .doc, .docx, .flac, .gif, .gz, .gzip, .htm,. HTML, .ICS,. không , .wmv, .xls, .xlsx, .xml, .xsl, .xsd và .zip.

Changelog: Các loại MIME được hỗ trợ (Tiện ích mở rộng tệp)

    } else {

        $filearray = array();
        $filearray = explode("/", $file);
        $file = $filearray[1];
    }

echo $fetchArray[0] . " Request " . $file . "\n"; 

// <-- Control Header
$output = "";
$Header = "HTTP/1.1 200 OK \r\n" .
"Date: Fri, 31 Dec 1999 23:59:59 GMT \r\n" .
"Content-Type: text/html \r\n\r\n";

$Content = file_get_contents($file);
$output = $Header . $Content;

    socket_write($client,$output,strlen($output));
    socket_close($client);

}
print('server running..');
2

$ php -S localhost:8000 router.php

Phiên bản

Sự mô tả

    } else {

        $filearray = array();
        $filearray = explode("/", $file);
        $file = $filearray[1];
    }

echo $fetchArray[0] . " Request " . $file . "\n"; 

// <-- Control Header
$output = "";
$Header = "HTTP/1.1 200 OK \r\n" .
"Date: Fri, 31 Dec 1999 23:59:59 GMT \r\n" .
"Content-Type: text/html \r\n\r\n";

$Content = file_get_contents($file);
$output = $Header . $Content;

    socket_write($client,$output,strlen($output));
    socket_close($client);

}
print('server running..');
3

$ php -S localhost:8000 router.php

.xml, .xsl và .xsd

, , .mpeg, .mov, .odp, .ods, .odt, .oga, .pdf, .pptx, .pps, .qt, .swf, .tar, .text, .tif, .wav, .wmv,. XLS, .xlsx và .zip

Cảnh báo

Máy chủ web này được thiết kế để hỗ trợ phát triển ứng dụng. Nó cũng có thể hữu ích cho các mục đích thử nghiệm hoặc cho các trình diễn ứng dụng được chạy trong môi trường được kiểm soát. Nó không nhằm mục đích là một máy chủ web đầy đủ tính năng. Nó không nên được sử dụng trên một mạng công cộng.

CLI SAPI cung cấp một máy chủ web tích hợp.

Máy chủ web chỉ chạy một quy trình duy nhất, vì vậy các ứng dụng PHP sẽ bị đình trệ nếu yêu cầu bị chặn.

    } else {

        $filearray = array();
        $filearray = explode("/", $file);
        $file = $filearray[1];
    }

echo $fetchArray[0] . " Request " . $file . "\n"; 

// <-- Control Header
$output = "";
$Header = "HTTP/1.1 200 OK \r\n" .
"Date: Fri, 31 Dec 1999 23:59:59 GMT \r\n" .
"Content-Type: text/html \r\n\r\n";

$Content = file_get_contents($file);
$output = $Header . $Content;

    socket_write($client,$output,strlen($output));
    socket_close($client);

}
print('server running..');
4

    } else {

        $filearray = array();
        $filearray = explode("/", $file);
        $file = $filearray[1];
    }

echo $fetchArray[0] . " Request " . $file . "\n"; 

// <-- Control Header
$output = "";
$Header = "HTTP/1.1 200 OK \r\n" .
"Date: Fri, 31 Dec 1999 23:59:59 GMT \r\n" .
"Content-Type: text/html \r\n\r\n";

$Content = file_get_contents($file);
$output = $Header . $Content;

    socket_write($client,$output,strlen($output));
    socket_close($client);

}
print('server running..');
5

    } else {

        $filearray = array();
        $filearray = explode("/", $file);
        $file = $filearray[1];
    }

echo $fetchArray[0] . " Request " . $file . "\n"; 

// <-- Control Header
$output = "";
$Header = "HTTP/1.1 200 OK \r\n" .
"Date: Fri, 31 Dec 1999 23:59:59 GMT \r\n" .
"Content-Type: text/html \r\n\r\n";

$Content = file_get_contents($file);
$output = $Header . $Content;

    socket_write($client,$output,strlen($output));
    socket_close($client);

}
print('server running..');
6

    } else {

        $filearray = array();
        $filearray = explode("/", $file);
        $file = $filearray[1];
    }

echo $fetchArray[0] . " Request " . $file . "\n"; 

// <-- Control Header
$output = "";
$Header = "HTTP/1.1 200 OK \r\n" .
"Date: Fri, 31 Dec 1999 23:59:59 GMT \r\n" .
"Content-Type: text/html \r\n\r\n";

$Content = file_get_contents($file);
$output = $Header . $Content;

    socket_write($client,$output,strlen($output));
    socket_close($client);

}
print('server running..');
7

oan tại vizrt dot com ¶

5 năm trước

    } else {

        $filearray = array();
        $filearray = explode("/", $file);
        $file = $filearray[1];
    }

echo $fetchArray[0] . " Request " . $file . "\n"; 

// <-- Control Header
$output = "";
$Header = "HTTP/1.1 200 OK \r\n" .
"Date: Fri, 31 Dec 1999 23:59:59 GMT \r\n" .
"Content-Type: text/html \r\n\r\n";

$Content = file_get_contents($file);
$output = $Header . $Content;

    socket_write($client,$output,strlen($output));
    socket_close($client);

}
print('server running..');
8

    } else {

        $filearray = array();
        $filearray = explode("/", $file);
        $file = $filearray[1];
    }

echo $fetchArray[0] . " Request " . $file . "\n"; 

// <-- Control Header
$output = "";
$Header = "HTTP/1.1 200 OK \r\n" .
"Date: Fri, 31 Dec 1999 23:59:59 GMT \r\n" .
"Content-Type: text/html \r\n\r\n";

$Content = file_get_contents($file);
$output = $Header . $Content;

    socket_write($client,$output,strlen($output));
    socket_close($client);

}
print('server running..');
9

$ cd ~/public_html
$ php -S localhost:8000
0

$ cd ~/public_html
$ php -S localhost:8000
1

    } else {

        $filearray = array();
        $filearray = explode("/", $file);
        $file = $filearray[1];
    }

echo $fetchArray[0] . " Request " . $file . "\n"; 

// <-- Control Header
$output = "";
$Header = "HTTP/1.1 200 OK \r\n" .
"Date: Fri, 31 Dec 1999 23:59:59 GMT \r\n" .
"Content-Type: text/html \r\n\r\n";

$Content = file_get_contents($file);
$output = $Header . $Content;

    socket_write($client,$output,strlen($output));
    socket_close($client);

}
print('server running..');
7

Mark Simon ¶

6 năm trước

$ cd ~/public_html
$ php -S localhost:8000
3

$ cd ~/public_html
$ php -S localhost:8000
4

$ cd ~/public_html
$ php -S localhost:8000
5

$ cd ~/public_html
$ php -S localhost:8000
6

$ cd ~/public_html
$ php -S localhost:8000
7

$ cd ~/public_html
$ php -S localhost:8000
8

    } else {

        $filearray = array();
        $filearray = explode("/", $file);
        $file = $filearray[1];
    }

echo $fetchArray[0] . " Request " . $file . "\n"; 

// <-- Control Header
$output = "";
$Header = "HTTP/1.1 200 OK \r\n" .
"Date: Fri, 31 Dec 1999 23:59:59 GMT \r\n" .
"Content-Type: text/html \r\n\r\n";

$Content = file_get_contents($file);
$output = $Header . $Content;

    socket_write($client,$output,strlen($output));
    socket_close($client);

}
print('server running..');
7

sâu ở Deepshah chấm vào tôi ¶

2 năm trước

PHP 5.4.0 Development Server started at Thu Jul 21 10:43:28 2011
Listening on localhost:8000
Document root is /home/me/public_html
Press Ctrl-C to quit
0

PHP 5.4.0 Development Server started at Thu Jul 21 10:43:28 2011
Listening on localhost:8000
Document root is /home/me/public_html
Press Ctrl-C to quit
1

    } else {

        $filearray = array();
        $filearray = explode("/", $file);
        $file = $filearray[1];
    }

echo $fetchArray[0] . " Request " . $file . "\n"; 

// <-- Control Header
$output = "";
$Header = "HTTP/1.1 200 OK \r\n" .
"Date: Fri, 31 Dec 1999 23:59:59 GMT \r\n" .
"Content-Type: text/html \r\n\r\n";

$Content = file_get_contents($file);
$output = $Header . $Content;

    socket_write($client,$output,strlen($output));
    socket_close($client);

}
print('server running..');
7

Tamas tại Bartatamas Dot Hu ¶

8 năm trước

PHP 5.4.0 Development Server started at Thu Jul 21 10:43:28 2011
Listening on localhost:8000
Document root is /home/me/public_html
Press Ctrl-C to quit
3

PHP 5.4.0 Development Server started at Thu Jul 21 10:43:28 2011
Listening on localhost:8000
Document root is /home/me/public_html
Press Ctrl-C to quit
4

    } else {

        $filearray = array();
        $filearray = explode("/", $file);
        $file = $filearray[1];
    }

echo $fetchArray[0] . " Request " . $file . "\n"; 

// <-- Control Header
$output = "";
$Header = "HTTP/1.1 200 OK \r\n" .
"Date: Fri, 31 Dec 1999 23:59:59 GMT \r\n" .
"Content-Type: text/html \r\n\r\n";

$Content = file_get_contents($file);
$output = $Header . $Content;

    socket_write($client,$output,strlen($output));
    socket_close($client);

}
print('server running..');
7

Matthes tại Leuffen Dot de ¶

6 năm trước

PHP 5.4.0 Development Server started at Thu Jul 21 10:43:28 2011
Listening on localhost:8000
Document root is /home/me/public_html
Press Ctrl-C to quit
6

PHP 5.4.0 Development Server started at Thu Jul 21 10:43:28 2011
Listening on localhost:8000
Document root is /home/me/public_html
Press Ctrl-C to quit
7

    } else {

        $filearray = array();
        $filearray = explode("/", $file);
        $file = $filearray[1];
    }

echo $fetchArray[0] . " Request " . $file . "\n"; 

// <-- Control Header
$output = "";
$Header = "HTTP/1.1 200 OK \r\n" .
"Date: Fri, 31 Dec 1999 23:59:59 GMT \r\n" .
"Content-Type: text/html \r\n\r\n";

$Content = file_get_contents($file);
$output = $Header . $Content;

    socket_write($client,$output,strlen($output));
    socket_close($client);

}
print('server running..');
7

sâu ở Deepshah chấm vào tôi ¶

2 năm trước

PHP 5.4.0 Development Server started at Thu Jul 21 10:43:28 2011
Listening on localhost:8000
Document root is /home/me/public_html
Press Ctrl-C to quit
9

PHP 5.4.0 Development Server started at Thu Jul 21 10:43:28 2011
Listening on localhost:8000
Document root is /home/me/public_html
Press Ctrl-C to quit.
[Thu Jul 21 10:48:48 2011] ::1:39144 GET /favicon.ico - Request read
[Thu Jul 21 10:48:50 2011] ::1:39146 GET / - Request read
[Thu Jul 21 10:48:50 2011] ::1:39147 GET /favicon.ico - Request read
[Thu Jul 21 10:48:52 2011] ::1:39148 GET /myscript.html - Request read
[Thu Jul 21 10:48:52 2011] ::1:39149 GET /favicon.ico - Request read
0

    } else {

        $filearray = array();
        $filearray = explode("/", $file);
        $file = $filearray[1];
    }

echo $fetchArray[0] . " Request " . $file . "\n"; 

// <-- Control Header
$output = "";
$Header = "HTTP/1.1 200 OK \r\n" .
"Date: Fri, 31 Dec 1999 23:59:59 GMT \r\n" .
"Content-Type: text/html \r\n\r\n";

$Content = file_get_contents($file);
$output = $Header . $Content;

    socket_write($client,$output,strlen($output));
    socket_close($client);

}
print('server running..');
7

Tamas tại Bartatamas Dot Hu ¶

2 năm trước

PHP 5.4.0 Development Server started at Thu Jul 21 10:43:28 2011
Listening on localhost:8000
Document root is /home/me/public_html
Press Ctrl-C to quit.
[Thu Jul 21 10:48:48 2011] ::1:39144 GET /favicon.ico - Request read
[Thu Jul 21 10:48:50 2011] ::1:39146 GET / - Request read
[Thu Jul 21 10:48:50 2011] ::1:39147 GET /favicon.ico - Request read
[Thu Jul 21 10:48:52 2011] ::1:39148 GET /myscript.html - Request read
[Thu Jul 21 10:48:52 2011] ::1:39149 GET /favicon.ico - Request read
2

PHP 5.4.0 Development Server started at Thu Jul 21 10:43:28 2011
Listening on localhost:8000
Document root is /home/me/public_html
Press Ctrl-C to quit.
[Thu Jul 21 10:48:48 2011] ::1:39144 GET /favicon.ico - Request read
[Thu Jul 21 10:48:50 2011] ::1:39146 GET / - Request read
[Thu Jul 21 10:48:50 2011] ::1:39147 GET /favicon.ico - Request read
[Thu Jul 21 10:48:52 2011] ::1:39148 GET /myscript.html - Request read
[Thu Jul 21 10:48:52 2011] ::1:39149 GET /favicon.ico - Request read
3

PHP 5.4.0 Development Server started at Thu Jul 21 10:43:28 2011
Listening on localhost:8000
Document root is /home/me/public_html
Press Ctrl-C to quit.
[Thu Jul 21 10:48:48 2011] ::1:39144 GET /favicon.ico - Request read
[Thu Jul 21 10:48:50 2011] ::1:39146 GET / - Request read
[Thu Jul 21 10:48:50 2011] ::1:39147 GET /favicon.ico - Request read
[Thu Jul 21 10:48:52 2011] ::1:39148 GET /myscript.html - Request read
[Thu Jul 21 10:48:52 2011] ::1:39149 GET /favicon.ico - Request read
4

PHP 5.4.0 Development Server started at Thu Jul 21 10:43:28 2011
Listening on localhost:8000
Document root is /home/me/public_html
Press Ctrl-C to quit.
[Thu Jul 21 10:48:48 2011] ::1:39144 GET /favicon.ico - Request read
[Thu Jul 21 10:48:50 2011] ::1:39146 GET / - Request read
[Thu Jul 21 10:48:50 2011] ::1:39147 GET /favicon.ico - Request read
[Thu Jul 21 10:48:52 2011] ::1:39148 GET /myscript.html - Request read
[Thu Jul 21 10:48:52 2011] ::1:39149 GET /favicon.ico - Request read
5

    } else {

        $filearray = array();
        $filearray = explode("/", $file);
        $file = $filearray[1];
    }

echo $fetchArray[0] . " Request " . $file . "\n"; 

// <-- Control Header
$output = "";
$Header = "HTTP/1.1 200 OK \r\n" .
"Date: Fri, 31 Dec 1999 23:59:59 GMT \r\n" .
"Content-Type: text/html \r\n\r\n";

$Content = file_get_contents($file);
$output = $Header . $Content;

    socket_write($client,$output,strlen($output));
    socket_close($client);

}
print('server running..');
7

Tamas tại Bartatamas Dot Hu ¶

8 năm trước

PHP 5.4.0 Development Server started at Thu Jul 21 10:43:28 2011
Listening on localhost:8000
Document root is /home/me/public_html
Press Ctrl-C to quit.
[Thu Jul 21 10:48:48 2011] ::1:39144 GET /favicon.ico - Request read
[Thu Jul 21 10:48:50 2011] ::1:39146 GET / - Request read
[Thu Jul 21 10:48:50 2011] ::1:39147 GET /favicon.ico - Request read
[Thu Jul 21 10:48:52 2011] ::1:39148 GET /myscript.html - Request read
[Thu Jul 21 10:48:52 2011] ::1:39149 GET /favicon.ico - Request read
7

PHP 5.4.0 Development Server started at Thu Jul 21 10:43:28 2011
Listening on localhost:8000
Document root is /home/me/public_html
Press Ctrl-C to quit.
[Thu Jul 21 10:48:48 2011] ::1:39144 GET /favicon.ico - Request read
[Thu Jul 21 10:48:50 2011] ::1:39146 GET / - Request read
[Thu Jul 21 10:48:50 2011] ::1:39147 GET /favicon.ico - Request read
[Thu Jul 21 10:48:52 2011] ::1:39148 GET /myscript.html - Request read
[Thu Jul 21 10:48:52 2011] ::1:39149 GET /favicon.ico - Request read
8

PHP 5.4.0 Development Server started at Thu Jul 21 10:43:28 2011
Listening on localhost:8000
Document root is /home/me/public_html
Press Ctrl-C to quit.
[Thu Jul 21 10:48:48 2011] ::1:39144 GET /favicon.ico - Request read
[Thu Jul 21 10:48:50 2011] ::1:39146 GET / - Request read
[Thu Jul 21 10:48:50 2011] ::1:39147 GET /favicon.ico - Request read
[Thu Jul 21 10:48:52 2011] ::1:39148 GET /myscript.html - Request read
[Thu Jul 21 10:48:52 2011] ::1:39149 GET /favicon.ico - Request read
9

$ cd ~/public_html
$ php -S localhost:8000 -t foo/
0

$ cd ~/public_html
$ php -S localhost:8000 -t foo/
1

$ cd ~/public_html
$ php -S localhost:8000 -t foo/
2

$ cd ~/public_html
$ php -S localhost:8000 -t foo/
3

$ cd ~/public_html
$ php -S localhost:8000 -t foo/
4

$ cd ~/public_html
$ php -S localhost:8000 -t foo/
5

$ cd ~/public_html
$ php -S localhost:8000 -t foo/
6

Matthes tại Leuffen Dot de ¶

5 năm trước

$ cd ~/public_html
$ php -S localhost:8000 -t foo/
7

$ cd ~/public_html
$ php -S localhost:8000 -t foo/
8

$ cd ~/public_html
$ php -S localhost:8000 -t foo/
9

PHP 5.4.0 Development Server started at Thu Jul 21 10:50:26 2011
Listening on localhost:8000
Document root is /home/me/public_html/foo
Press Ctrl-C to quit
0

PHP 5.4.0 Development Server started at Thu Jul 21 10:50:26 2011
Listening on localhost:8000
Document root is /home/me/public_html/foo
Press Ctrl-C to quit
1

PHP 5.4.0 Development Server started at Thu Jul 21 10:50:26 2011
Listening on localhost:8000
Document root is /home/me/public_html/foo
Press Ctrl-C to quit
2

    } else {

        $filearray = array();
        $filearray = explode("/", $file);
        $file = $filearray[1];
    }

echo $fetchArray[0] . " Request " . $file . "\n"; 

// <-- Control Header
$output = "";
$Header = "HTTP/1.1 200 OK \r\n" .
"Date: Fri, 31 Dec 1999 23:59:59 GMT \r\n" .
"Content-Type: text/html \r\n\r\n";

$Content = file_get_contents($file);
$output = $Header . $Content;

    socket_write($client,$output,strlen($output));
    socket_close($client);

}
print('server running..');
7

Ivan Ferrer ¶

9 năm trước

PHP 5.4.0 Development Server started at Thu Jul 21 10:50:26 2011
Listening on localhost:8000
Document root is /home/me/public_html/foo
Press Ctrl-C to quit
4

PHP 5.4.0 Development Server started at Thu Jul 21 10:50:26 2011
Listening on localhost:8000
Document root is /home/me/public_html/foo
Press Ctrl-C to quit
5

PHP 5.4.0 Development Server started at Thu Jul 21 10:50:26 2011
Listening on localhost:8000
Document root is /home/me/public_html/foo
Press Ctrl-C to quit
6

PHP 5.4.0 Development Server started at Thu Jul 21 10:50:26 2011
Listening on localhost:8000
Document root is /home/me/public_html/foo
Press Ctrl-C to quit
7

PHP 5.4.0 Development Server started at Thu Jul 21 10:50:26 2011
Listening on localhost:8000
Document root is /home/me/public_html/foo
Press Ctrl-C to quit
8

    } else {

        $filearray = array();
        $filearray = explode("/", $file);
        $file = $filearray[1];
    }

echo $fetchArray[0] . " Request " . $file . "\n"; 

// <-- Control Header
$output = "";
$Header = "HTTP/1.1 200 OK \r\n" .
"Date: Fri, 31 Dec 1999 23:59:59 GMT \r\n" .
"Content-Type: text/html \r\n\r\n";

$Content = file_get_contents($file);
$output = $Header . $Content;

    socket_write($client,$output,strlen($output));
    socket_close($client);

}
print('server running..');
7

Sony tại Sony-Ak Dot Com ¶

5 năm trước

$ php -S localhost:8000 router.php
0

$ php -S localhost:8000 router.php
1

    } else {

        $filearray = array();
        $filearray = explode("/", $file);
        $file = $filearray[1];
    }

echo $fetchArray[0] . " Request " . $file . "\n"; 

// <-- Control Header
$output = "";
$Header = "HTTP/1.1 200 OK \r\n" .
"Date: Fri, 31 Dec 1999 23:59:59 GMT \r\n" .
"Content-Type: text/html \r\n\r\n";

$Content = file_get_contents($file);
$output = $Header . $Content;

    socket_write($client,$output,strlen($output));
    socket_close($client);

}
print('server running..');
7

dachund tại gmail dot com

4 năm trước

$ php -S localhost:8000 router.php
3

$ php -S localhost:8000 router.php
4

$ php -S localhost:8000 router.php
5

$ php -S localhost:8000 router.php
6

    } else {

        $filearray = array();
        $filearray = explode("/", $file);
        $file = $filearray[1];
    }

echo $fetchArray[0] . " Request " . $file . "\n"; 

// <-- Control Header
$output = "";
$Header = "HTTP/1.1 200 OK \r\n" .
"Date: Fri, 31 Dec 1999 23:59:59 GMT \r\n" .
"Content-Type: text/html \r\n\r\n";

$Content = file_get_contents($file);
$output = $Header . $Content;

    socket_write($client,$output,strlen($output));
    socket_close($client);

}
print('server running..');
7

dwingardjr tại gmail dot com

5 năm trước

$ php -S localhost:8000 router.php
8

$ php -S localhost:8000 router.php
9

$ php -S localhost:8000 router.php
0

$ php -S localhost:8000 router.php
1

    } else {

        $filearray = array();
        $filearray = explode("/", $file);
        $file = $filearray[1];
    }

echo $fetchArray[0] . " Request " . $file . "\n"; 

// <-- Control Header
$output = "";
$Header = "HTTP/1.1 200 OK \r\n" .
"Date: Fri, 31 Dec 1999 23:59:59 GMT \r\n" .
"Content-Type: text/html \r\n\r\n";

$Content = file_get_contents($file);
$output = $Header . $Content;

    socket_write($client,$output,strlen($output));
    socket_close($client);

}
print('server running..');
7

Lukas ¶

5 năm trước

$ php -S localhost:8000 router.php
3

Làm cách nào để chạy một máy chủ PHP cục bộ?

Trong phần này, chúng tôi sẽ trải qua một vài lệnh đơn giản cho máy chủ web PHP ...
Bắt đầu một máy chủ PHP -S localhost: 8000. ....
Chỉ định một tài liệu thư mục gốc PHP -S localhost: 8000 -t foo/ ....
Sử dụng tệp bộ định tuyến PHP -S LocalHost: 8000 Bộ định tuyến. ....
Bước 1: Tải xuống Pchart Curl -Lok http://www.pchart.net/release/pchart2.1.4.tar ..

Làm cách nào để chạy PHP cục bộ trên Windows?

Bạn chỉ cần làm theo các bước để chạy chương trình PHP bằng dòng lệnh ...
Mở cửa sổ thiết bị đầu cuối hoặc dòng lệnh ..
Goto thư mục hoặc thư mục được chỉ định có các tệp PHP có mặt ..
Sau đó, chúng ta có thể chạy mã PHP bằng lệnh sau: php file_name.php ..

Tôi có thể tạo một máy chủ với PHP không?

Chọn Tạo một phiên bản máy chủ mới và chọn loại máy chủ PHP.Bạn cũng có thể nhấp vào Máy chủ> Loại máy chủ> Máy chủ PHP> Mới.Chọn nút mà bạn muốn máy chủ PHP chạy.Nút này phải có môi trường thời gian chạy PHP và Apache HTTP.. You can also click Servers > Server types > PHP servers > New. Select the node on which you want the PHP server to run. This node must have the PHP and Apache HTTP Server runtime environments.

Làm cách nào để chạy PHP độc lập?

Đối với hệ thống Windows, bạn sẽ có thể chạy PHP bằng cách làm theo các bước dưới đây: Tải xuống phiên bản PHP bạn muốn sử dụng và đặt nó vào C: \ PHP.nối; C: \ PHP vào đường dẫn hệ thống của bạn bằng CMD hoặc GUI.Gọi $ PHP -S LocalHost: 8000 Lệnh trong một thư mục mà bạn muốn phục vụ các trang từ.