Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Using built-in PHP server can't access localhost site that use custom domain name specified in etc/hosts

Actually already asked my question in the title.
What I’ve done:

  1. Installed PHP 8, and set path to it in env. var.
  2. Changed file C:\Windows…\etc\hosts and added lines to it:
127.0.0.1   astrononeko.dev
127.0.0.1   www.astrononeko.dev
::1         astrononeko.dev
::1         www.astrononeko.dev
  1. In cmd used

ipconfig /flushdns
4) Then created directory C:\Projects\Web\php and file index.php. There is regular Hello world programm. Typed all the combinations listed below:

php -S localhost:80
php -S 127.0.0.1:80
php -S astrononeko.dev:80
php -S astrononeko.dev:4000
php -S www.astrononeko.dev:80
php -S www.astrononeko.dev:8000
php -S 0.0.0.0:80

Through browser could access only by localhost. Command curl works on every listed domains, ping does not work on any if I specify the port

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Using Windows 10 and PHP 8 only

When trying to adress by domain names, getting something like this

[Wed Jun 15 15:46:19 2022] 127.0.0.1:60869 Accepted

[Wed Jun 15 15:46:19 2022] 127.0.0.1:60868 Invalid request (Unsupported SSL request)

[Wed Jun 15 15:46:19 2022] 127.0.0.1:60868 Closing

Google refers it as httpS problem, but I checked both secured http and non-secured and actually there are problems around https when using another web-servers other than built-in PHP, like Apache, which I’m not using.

Will be really glad if you could answer my question if you know what is the problem!

>Solution :

some time ago we started to change .dev for local development as .dev is a FQDN now. Why don’t you try to change in your \etc\host to something like .test

127.0.0.1   astrononeko.test
127.0.0.1   www.astrononeko.test
::1         astrononeko.test
::1         www.astrononeko.test

Also be sure that your host file is readable by php.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading