User Rating: / 0
PoorBest 

Bookmark and Share

If you are new to Unixmen, you may want to subscribe :

 

So lets start

cd /var/www/html
[root@test11 html]# ls

info.php

[root@test11 html]# touch index.html
[root@test11 html]# view index.html

(make your Welcome text message)

[root@test11 html]# python -m SimpleHTTPServer

Serving HTTP on 0.0.0.0 port 8000 ...

Test11.unixmen.com - - [23/Sep/2009 07:00:29] "GET / HTTP/1.1" 200 –

Now open your browser with

http://localhost:8000 or http://127.0.0.1 or http://IP:8000

 

Other way you can change the web port with :

python -m SimpleHTTPServer 8081 or other  port

If you want to make your server local in your intern LAN of Only on this server edit this Pyhton script :

 

import sys
import BaseHTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
HandlerClass = SimpleHTTPRequestHandler
ServerClass = BaseHTTPServer.HTTPServer
Protocol = "HTTP/1.0"
if sys.argv[1:]:
port = int(sys.argv[1])
else:
port = 8000
server_address = ('127.0.0.1', port)
HandlerClass.protocol_version = Protocol
httpd = ServerClass(server_address, HandlerClass)

sa = httpd.socket.getsockname()
print "Serving HTTP on", sa[0], "port", sa[1], "..."
httpd.serve_forever()

 

Enjoy

 

 


Related Articles By Tags:

Comments (2)
  • Mike  - How do i make HTTP server accessable?
    avatar

    http://localhost:8000 or http://127.0.0.1 or http://IP:8000 are all local, yes? how do i enable the http server to be accessible by the public?

  • Zinovsky
    avatar

    This one is not local : http://IP:8000 because you can use IP= your external IP.
    So public can use http://IP:8000 to access your server

Write comment
Your Contact Details:
Gravatar enabled
Comment:
[b] [i] [u] [s] [url] [quote] [code] [img]   
:D:):(:0:shock::confused:8):lol::x:P:oops::cry:
:evil::twisted::roll::wink::!::?::idea::arrow: