Need help starting web server on localhost

Hello, I started coding this little PHP service on repl.it, but now I’m trying to run it locally on my PC so I can debug it in the browser console.
It runs Manjaro linux, and I installed the apache and php packages from the distro repositories and started Apache with
sudo systemctl start httpd.service
However I’m still unable to run the code, my IDE (PHPStorm) gives this output:

/usr/bin/php -S localhost:80 -t /home/ben/Nextcloud/codn/Web/FH-BackendBasics/HÜs/2-schleifen
[Sat Apr 11 16:12:53 2020] Failed to listen on localhost:80 (reason: Permission denied)

Process finished with exit code 1

Probably forgot something there, but what is it?

Don’t need apache for a local server. Low ports can only be listened on by root, use something like 8000 instead of 80

To use apache, see php section of:
https://wiki.archlinux.org/index.php/Apache_HTTP_Server
But it seems like you have no reason to do that.

How do I make the server listen on a higher port, and what is the thing I need to do to run my php code, if it’s not running the webserver. As far as I understood it, PHP runs on the server, yes?

you’d specify 8000 instead of 80 in your command (look at your output)

Okay, I now get permission, but output on browser page/console is 502 Bad Gateway

presumably you didn’t specify the port in your browser and are therefore talking to the wrong server (apache)

oh you’re seeing it in your php server? idk without reproducing then

When I click the “run” button in PHPStorm, and then one of the browser buttons in the top right corner,


it calls this address:
http://localhost:63342/2-schleifen/index.php?_ijt=tj4embcbrq32t484s1ocbvt4v7 (=> 502)
the correct one would be:
http://localhost:8000/index.php
/2-schleifen/ is configured to be the webroot, I don’t know why it puts it there again, or how to make Phpstorm open the page on the configured port instead of :63342, and what is this strange parameter ?_ijt=tj4embcbrq32t484s1ocbvt4v7 behind the address…

Presumably phpstorm starts its own server that you’d need to configure if you wanted to use it