Score:1

Is it possible to start apache2 as non-service foreground program?

cn flag

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.

Score:2
in flag

The command you search for is something like:

httpd -D FOREGROUND -e debug

But be aware this can have challenges with performance.

Anutrix avatar
cn flag
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.
Romeo Ninov avatar
in flag
@Anutrix, did you configure your server?
Anutrix avatar
cn flag
`php -S 0.0.0.0:8000` was just simple.
ezra-s avatar
ru flag
@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.
Anutrix avatar
cn flag
Does starting it as a service not require that conf? Oddly, I get no errors when starting it as a service.
Romeo Ninov avatar
in flag
@Anutrix, did you check what variables are set in service script?
Score:0
cn flag

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

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.