Start an apache server in any directory from command line

后端 未结 7 1315
故里飘歌
故里飘歌 2020-12-25 12:26

I want to be able to start an apache server from the command line, typing something like apache site-folder or apache . --port=2000

This sh

7条回答
  •  -上瘾入骨i
    2020-12-25 13:14

    For the benefit of anyone stumbling across this with the same question, I wanted something that was as simple as the pache package mentioned, but not relying on having node.js installed.

    My use-case was in looking for a replacement for the webrick server used in Jekyll. Webrick, like most lightweight run-anywhere http servers, doesn't support .htaccess files.

    So I took gpilotino's answer and packaged it up a bit. I've been using it for a few weeks now and although I am sure it can be improved upon it's doing the job. It comes as a script and a minimal httpd.conf file, which makes it easy to extend to support, say, PHP.

    You can find it at: https://github.com/julianbrowne/apache-anywhere

    Essentially, once it's installed (an optionally config tweaked) you just run:

    apache -d document_root_directory -p {port}

    and:

    apache stop {port}

    when you are done.

提交回复
热议问题