How to make "php -S" to work on local network?

Asked
Active3 hr before
Viewed126 times

9 Answers

90%

It works, but the server only available on that computer only. Is there a way to test it on other devices within the same LAN?, Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers ,This will allow you to access the server remotely (see docs http://php.net/manual/en/features.commandline.webserver.php),Connect and share knowledge within a single location that is structured and easy to search.

You will want to launch the server with the command

php -S 0.0.0.0:8888

php - S 0.0 .0 .0: 8888
load more v
88%

The built-in Web Server should not be used on a public network. , The CLI SAPI provides a built-in web server. , The web server runs only one single-threaded process, so PHP applications will stall if a request is blocked. ,Example #2 Starting with a specific document root directory

$ cd~/public_html
$ php - S localhost: 8000
load more v
72%

cd path / to / your / app
php - S localhost: 8000
load more v
65%

The phone needs to be connected to the same local network as the computer that the web server is running on. I have both connected to my wifi router., Using the PHP command line web server to transfer files between devices on a local network ,When I’m finished transferring files, I just press Ctrl-C in the terminal to close down the web server., Low-cost motor control by displaying coloured shapes on a phone or PC screen

The basic idea is that I run the PHP web server in the folder that contains the files I want to transfer onto my phone, then use the browser on my phone to download the files. Let’s say that the file I’m transferring is called “myfile.txt” and it’s in the directory “/home/xubuntu/Downloads/“. I would type the following commands in a terminal to run the PHP web server in that directory:

cd / home / xubuntu / Downloads
php - S 0.0 .0 .0: 8000
load more v
75%

To use this functionality in PHP, you need to have a version 5.4 or above. Using terminal, navigate to the root of the folder where the index.php or index.html and run the following command. ,PS: You can also replace "localhost" with an IP address so that other computers connected via LAN or to the same wifi network can access this. Eg 'php -S 192.168.10.25:8000'. Now every other computer connected to the same LAN can access this from http://192.168.10.25:8000, Conversion Optimization ,You can also run PHPMyAdmin as a PHP built-in web server. Learn how here. Applications involving MySQL database connection can also be served in this server. You can test this by navigating to your drupal installation root folder and run 'php -S localhost:8000' in terminal. Then go to 'http://localhost:8000' and see the magic happen!

To use this functionality in PHP, you need to have a version 5.4 or above. Using terminal, navigate to the root of the folder where the index.php or index.html and run the following command.

php -S localhost:8000
// php -S <host>:<port>
40%

cd into the directory the file is in,Okay, so here's the simple answer I would have loved to find but couldn't,Run php -S localhost:8000 (or replace 8000 with a different port),Go to localhost:8000 in the browser

cd into the directory the file is in

cd
load more v
22%

I made a site in PHP and MySQL responsive and would like to access it on my Android phone by localhost, I know I have to put my IP in the browser of the mobile phone but when I access it it appears the following error: , Click Networks and select the network for the current connection. , Then stay Apache with the XAMPP Control Panel. And test on the cell phone using the IP of the computer, as shown in the tutorial for WAMP. , You only need to use 2 features in your phone's browser:

Transform this:

<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">
   Require local
   ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</LocationMatch>

In this:

<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">
   #Require local
   #ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</LocationMatch>
load more v
60%

This article explains how to set up a simple local testing server on your machine, and the basics of how to use it.,How do you set up a local testing server?,To get around the problem of async requests, we need to test such examples by running them through a local web server. One of the easiest ways to do this for our purposes is to use Python's http.server module.,Some examples won't run if you open them as local files. This can be due to a variety of reasons, the most likely being:

python - V
# If the above fails,
try:
python3 - V
# Or,
if the "py"
command is available,
try:
py - V
load more v
48%

The site configured at this address does not contain the requested file. , Read the full documentation for more information about using GitHub Pages. , If this is your site, make sure that the filename case matches the URL. For root URLs (like http://example.com/) you must provide an index.html file.

The site configured at this address does not contain the requested file.

If this is your site, make sure that the filename case matches the URL.
For root URLs (like http://example.com/) you must provide an index.html file.

http: //example.com/
load more v

Other "undefined-undefined" queries related to "How to make "php -S" to work on local network?"