I’m just set a new computer to work on, so I install Apache24, PHP and MySQL.
I use the different tutorial, and I could launch a “server” from php -S localhost:8000
or I could do it from httpd -k start
.
In my .conf
# If your host doesn't have a registered DNS name, enter its IP address here.
# ServerName localhost:80
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80 Listen 127.0.0.1:1000
And I don’t understand what is the difference?
I could access to 127.0.0.1:1000
and I see my directory htdocs but It’ work even if I don’t start httpd.
It’s a bit a big mess in my head between, what is a server that is not a server why some port work why other not.
If I check with netstat, it only show : 1000 listening.
In the end, I want to test some stuff with a “simple” php server before try it on symfony server.
By advance, Thanks for your help. 😀
Axel
2
Answers
php -S
starts the built in PHP web server.httpd
starts an Apache web server using PHP to process PHP files.If you just want to test a couple of things locally, the built in PHP web server is probably fine – it’s lightweight and easy to spin up and close down.
If you want a full web server you should use Apache. It’s probably not working because it’s either not configured correctly for your environment, your PHP version or your document root. There’s plenty of resources online for setting up Apache locally, depending on your operating system.
https://secure.php.net/manual/en/features.commandline.webserver.php:
php -S localhost:8000
starts PHPs builtin webserver (not as many features). Your site will be available athttp://localhost:8000
orhttp://127.0.0.1:8000
. Files will be served from the directory you executed it.https://httpd.apache.org/:
httpd -k start
starts the Apache webserver. Your site (if not configured otherwise) will be available athttp://localhost
orhttp://127.0.0.1
. Can/must be configured if you want to use a different directory than the default one.