App local index php

localhost/index.php

«localhost/index.php» refers to the default web page of a web application or website that is written in the PHP programming language and running on a local server.

To access a PHP application running on localhost, you need to have a web server installed on your computer. You can install a web server like Apache, Nginx or XAMPP, which includes a web server, database server, and other tools necessary for running web applications. Once installed, you can start the web server and access the application in your web browser by entering the URL «http://localhost/index.php» in the address bar.

Here are the steps to access a PHP application on localhost:

  1. Install a web server like Apache, Nginx or XAMPP on your computer.
  2. Start the web server by running the appropriate command or using the graphical interface.
  3. Place the PHP files for your application in the web server’s document root directory. In the case of Apache, this directory is typically located at «/var/www/html» on Linux or «C:\xampp\htdocs» on Windows when using XAMPP.
  4. Open your web browser and enter «http://localhost/index.php» in the address bar. This will load the default web page for your PHP application.

If everything is set up correctly, you should see the homepage of your PHP application. From there, you can navigate through the different pages of the application, interact with its features, and run its programs or scripts as intended.

Localhost & Your connection Analysis (live)

Date 2023/07/27 19:29:25
HTTP ACCEPT text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
HTTP ACCEPT CHARSET windows-1251,utf-8;q=0.7,*;q=0.7
HTTP ACCEPT ENCODING gzip
HTTP ACCEPT LANGUAGE ru-ru,ru;q=0.8,en-us;q=0.5,en;q=0.3
HTTP CONNECTION Keep-Alive
HTTP HOST localhosts.mobi
HTTP REFERER https://localhosts.mobi/
HTTP USER AGENT Mozilla/5.0 (X11; CrOS i686 4319.74.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.57 Safari/537.36
HTTP X FORWARDED FOR 95.143.190.109
HTTP CF RAY 7ed74a858aa3abf6-KLD
HTTP X FORWARDED PROTO https
HTTP CF VISITOR
HTTP CDN LOOP cloudflare
HTTP CF CONNECTING IP 95.143.190.109
HTTP CF IPCOUNTRY RU
REMOTE ADDR 172.71.17.150
REMOTE PORT 38780
SERVER NAME localhosts.mobi
SERVER PORT 80
REQUEST URI /index-php
REDIRECT URL /index-php
HTTPS on
REDIRECT STATUS 200
LSWS EDITION Openlitespeed 1.7.17
X-LSCACHE on,crawler
SERVER PROTOCOL HTTP/1.1
SERVER SOFTWARE LiteSpeed
REQUEST METHOD GET
REQUEST TIME FLOAT 1690486165.4501
REQUEST TIME 1690486165

These data are reflected instantly. It is never saved on the server, stored or used.

127.0.0.1 Server Pages

Apache/2.4.54 (Win64) OpenSSL/1.1.1p PHP/8.2.0 Server at localhost Port 80

Источник

Run a PHP Web Server to Quickly Serve Local Files and Folders From Any Directory

The most basic requirement while working on websites and web apps is the ability to see our results in a web browser. We do this by serving the local source code via a HTTP web server and then visiting http://localhost in our browser to see the results. Traditionally we’d install and configure web servers like Apache or Nginx but if you’re working on a PHP app or a static website and already have PHP installed in your system, you wouldn’t need to go the traditional route.

You can use the built-in PHP web server to quickly serve PHP and other static files (HTML, CSS, images, videos, fonts, etc.) from your current working directory or any other path in your local file system.

Built-in Web Server

The PHP CLI language interpreter ships with a built-in web server that can be fired up like this:

# Serve index.php or index.html from the current working directory $ php -S localhost:8080 # Serve a specific file $ php -S localhost:8080 specific-file.php

The syntax of the command looks like this:

$ php [options] -S addr:port [-t docroot]

You can always go through the different options by reading up on man php but as far as serving local files and folders are concerned all we need to know is that pass your desired host ( addr ) and port to -S and if you want, you can specify the document root with the -t option. If no document root is specified, the current working directory is served.

$ pwd /home/user # Serve cwd as docroot $ php -S 0.0.0.0:8080 PHP 7.2.24-0ubuntu0.18.04.10 Development Server started at Sat Feb 5 09:54:51 2022 Listening on http://0.0.0.0:8080 Document root is /home/rish # docroot Press Ctrl-C to quit. # Serve cwd/pub/ as docroot $ php -S 0.0.0.0:8080 -t pub/ PHP 7.2.24-0ubuntu0.18.04.10 Development Server started at Sat Feb 5 09:55:51 2022 Listening on Document root is /home/user/pub # docroot Press Ctrl-C to quit

Whenever the document root ( http://localhost ) or a folder ( http://localhost/foo ) is accessed via an HTTP request, the web server will look for an index.php or index.html file in the respective file system folder. If none of them are found, the parent directories will be looked up for those files until the document root is reached. Eventually an HTTP 404 Not Found will be thrown if the files aren’t found.

Router Scripts

While passing a specific file to the web server, it is super important to note that the file will be treated as a “router” script in such cases. An example:

$ php -S localhost:8080 page.php

Now regardless of whatever URL that you visit – /foo , /foo/bar.php , /baz.php , /style.css , etc. – page.php will always be executed.

  • If page.php returns false for a particular HTTP request, then the requested resource (file) will be processed and served.
  • If page.php does not return false for a request then any output produced by itself be returned to the client (browser).

This makes the in-built PHP web server similar to the rewrite modules of other servers like Apache and Nginx. This makes the web server compatible with any PHP web framework (Laravel, Symfony, etc.) that take advantage of URL re-writes to route all the requests through a single index.php and eventually invoke different routes and controllers internally.

File (Extension) Support

The PHP web server can serve the following static file extensions and will send the standard MIME types (content types) while serving them – .3gp, .apk, .avi, .bmp, .css, .csv, .doc, .docx, .flac, .gif, .gz, .gzip, .htm, .html, .ics, .jpe, .jpeg, .jpg, .js, .kml, .kmz, .m4a, .mov, .mp3, .mp4, .mpeg, .mpg, .odp, .ods, .odt, .oga, .ogg, .ogv, .pdf, .pdf, .png, .pps, .pptx, .qt, .svg, .swf, .tar, .text, .tif, .txt, .wav, .webm, .wmv, .xls, .xlsx, .xml, .xsl, .xsd, and .zip .

Any other extension like .rb (Ruby), .py (Python), etc. will be served off as Content-Type: application/octet-stream which will lead to a file download in the web browser.

Limitations

The PHP web server is easy and quick to setup so that one can get started with serving static and PHP files or even apps written on popular PHP frameworks. There are a few limitations though that we must be aware of:

  • The server runs a single-threaded process. This means new requests will “stall” if a previous request is blocked due to performing time consuming operations like network or disk IO, data computation, etc.
  • Due to the previous reason, never use it in production environments. For production it is always recommended to use a more sophisticated and scalable web server like Apache, Nginx, etc.

Источник

App local index php

This web server is designed to aid application development. It may also be useful for testing purposes or for application demonstrations that are run in controlled environments. It is not intended to be a full-featured web server. It 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.

URI requests are served from the current working directory where PHP was started, unless the -t option is used to specify an explicit document root. If a URI request does not specify a file, then either index.php or index.html in the given directory are returned. If neither file exists, the lookup for index.php and index.html will be continued in the parent directory and so on until one is found or the document root has been reached. If an index.php or index.html is found, it is returned and $_SERVER[‘PATH_INFO’] is set to the trailing part of the URI. Otherwise a 404 response code is returned.

If a PHP file is given on the command line when the web server is started it is treated as a «router» script. The script is run at the start of each HTTP request. If this script returns false , then the requested resource is returned as-is. Otherwise the script’s output is returned to the browser.

Standard MIME types are returned for files with extensions: .3gp, .apk, .avi, .bmp, .css, .csv, .doc, .docx, .flac, .gif, .gz, .gzip, .htm, .html, .ics, .jpe, .jpeg, .jpg, .js, .kml, .kmz, .m4a, .mov, .mp3, .mp4, .mpeg, .mpg, .odp, .ods, .odt, .oga, .ogg, .ogv, .pdf, .pdf, .png, .pps, .pptx, .qt, .svg, .swf, .tar, .text, .tif, .txt, .wav, .webm, .wmv, .xls, .xlsx, .xml, .xsl, .xsd, and .zip.

Changelog: Supported MIME Types (file extensions)

Version Description
5.5.12 .xml, .xsl, and .xsd
5.5.7 .3gp, .apk, .avi, .bmp, .csv, .doc, .docx, .flac, .gz, .gzip, .ics, .kml, .kmz, .m4a, .mp3, .mp4, .mpg, .mpeg, .mov, .odp, .ods, .odt, .oga, .pdf, .pptx, .pps, .qt, .swf, .tar, .text, .tif, .wav, .wmv, .xls, .xlsx, and .zip
5.5.5 .pdf
5.4.11 .ogg, .ogv, and .webm
5.4.4 .htm and .svg
Changelog
Version Description
7.4.0 You can configure the built-in webserver to fork multiple workers in order to test code that requires multiple concurrent requests to the built-in webserver. Set the PHP_CLI_SERVER_WORKERS environment variable to the number of desired workers before starting the server. This is not supported on Windows.

This experimental feature is not intended for production usage. Generally, the built-in Web Server is not intended for production usage.

Example #1 Starting the web server

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

Источник

Читайте также:  Массив строк java добавление
Оцените статью