2

apache2 normally runs a service. I don't apache2 service to run in background. I want to run it as long as it's a foreground program so I know that when I close my terminals while forgetting to stop a background service.

If not, is there any simple alternative? python -m SimpleHTTPServer is perfect except it doesn't support POST unless I write a script.

So I am trying to find a single command server program that doesn't run as service.

2 Answers 2

3

The command you search for is something like:

httpd -D FOREGROUND -e debug

But be aware this can have challenges with performance.

6
  • From what I know httpd is same as apache2. apache2 -D FOREGROUND -e debug gave me [core:warn] [pid 1038] AH00111: Config variable ${APACHE_RUN_DIR} is not defined apache2: Syntax error on line 80 of /etc/apache2/apache2.conf: DefaultRuntimeDir must be a valid directory, absolute or relative to ServerRoot. If not, how to install httpd.
    – Anutrix
    Jan 12, 2023 at 17:14
  • @Anutrix, did you configure your server? Jan 12, 2023 at 17:51
  • php -S 0.0.0.0:8000 was just simple.
    – Anutrix
    Jan 13, 2023 at 14:05
  • @Anutrix that error just means you didnt preload the envvars file or whatever one you have with system variables used in the configuration of your apache server. Jan 19, 2023 at 12:02
  • Does starting it as a service not require that conf? Oddly, I get no errors when starting it as a service.
    – Anutrix
    Jan 19, 2023 at 12:39
0

php -S 0.0.0.0:8000 was the simplest way(short command) to host a temporary server that supports POST by default that I could find.

Src: https://unix.stackexchange.com/a/33213/306145

Not the answer you're looking for? Browse other questions tagged .