1

I am trying to get python's SimpleHTTPServer to start on boot using /etc/init/pyweb.conf and to specify the path which the script will be executed in and server files from, however I don't seem to be able to get it to work.

Here's what I have ended up with, but it's not firing off:

# Start SimpleHTTPServer
#
description "SimpleHTTPServer"
start on startup
task
exec python -m SimpleHTTPServer 
--path=/var/pyweb/

3 Answers 3

1

Maybe

cd

into that folder and run

python -m SimpleHTTPServer

from there?

0
1

Add chdir /var/pyweb before your exec-line.

Described here: http://upstart.ubuntu.com/wiki/Stanzas#chdir

Edit: To be clear, SimpleHTTPServer doesn't take any --path or other options like that. You can give it a port number, that's about it.

Also, you don't want to use it as something permanent (i.e. on boot, used a lot); use a real httpd for that.

Thirdly; this is more of ServerFault question.

1
  • Thanks very much for suggestions adding the chdir solved it. This is to be used for a touchscreen web config, the web server will probably serve one page during initial setup and potentially never serve another page unless the config is changed which is unlikely. many thanks again.
    – crankshaft
    Sep 21, 2011 at 13:18
1

Change to a directory containing web files, for example:

cd /var/www/test

Run this command:

python -m SimpleHTTPServer

If the default port (8000) isn't available, you can try a different one by adding it to the command:

python -m SimpleHTTPServer 1234

Once this is working, you can run the command below to make the server persistent:

nohup python -m SimpleHTTPServer 1234 &

1
  • Your solution duplicates an earlier one (please do read all answers before posting a new one), and as the OP is using upstart there's no use for nohup (although for anyone doing the same without upstart it would be useful).
    – zagrimsan
    Nov 25, 2015 at 10:56

You must log in to answer this question.

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