Search code examples
phplinuxapachelamp

How to start apache2 in command line specifying a port?


I would like to start Apache2 server in my Linux command line specifying a port. A solution which don't need to edit php.ini would be nice, because the command should not request sudo.

I need to access to the server with this adress:

http://localhost:1234/

For the moment, it start at:

http://localhost/

Solution

  • From PHP 5.4 you can run a localhost server from the command line using

    php -S localhost:1234
    

    PHP Docs: http://php.net/manual/en/features.commandline.webserver.php

    You may need to add php to your PATH.