How to install python server on CentOS 7

To install Python Server on CentOS 7

Python&rsquo s SimpleHTTPServer is a module that allows you to instantly create a web server or serve your files in a snap. With SimpleHTTPServer, you don&rsquo t need to install anything since you have python interpreter installed. It is very simple to install Python server on CentOS 7 and this article sheds light on it.

Installing python

You can install Python by executing the yum command in your terminal.


\[root@linuxhelp Desktop\]# yum install python -y Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 \* base: mirror.vbctv.in
 \* extras: mirror.vbctv.in
 \* updates: mirror.vbctv.in
.
.
.
Updated:
  python.x86\_64 0:2.7.5-48.el7                                                  

Dependency Updated:
  python-libs.x86\_64 0:2.7.5-48.el7                                             

Complete!

Once it is done, start python http server by running the following command.


\[root@linuxhelp Desktop\]#  python2.7 -m SimpleHTTPServer 8880 Serving HTTP on 0.0.0.0 port 8880 ...

After that, open your browser and give the url as serverip:8880(192.168.7.165:8880). It will display the server. The sever starts running on your screen.

< ads2>

While server runs in browser, you can see the it will log details displayed on your terminal.


\[root@linuxhelp Desktop\]#  python2.7 -m SimpleHTTPServer 8880 Serving HTTP on 0.0.0.0 port 8880 ...
192.168.7.165 - - \[03/Aug/2017 06:16:53\] " GET / HTTP/1.1"  200 -
192.168.7.165 - - \[03/Aug/2017 06:16:53\] code , message File 
192.168.7.165 - - \[03/Aug/2017 06:16:53\] " GET /favicon.ico HTTP/1.1"   -
192.168.7.165 - - \[03/Aug/2017 06:16:53\], message File 

With this, the installation of Phython Server is complete.

Tag : CentOS Python
FAQ
Q
What is the usage of help() and dir() function in Python?
A
Help() function: The help() function is used to display the documentation string and also facilitates you to see the help related to modules, keywords, attributes, etc.
Dir() function: The dir() function is used to display the defined symbols.
Q
How is memory managed in Python?
A
Memory management in python is managed by Python private heap space. All Python objects and data structures are located in a private heap. The programmer does not have access to this private heap. The python interpreter takes care of this instead.
Q
Can I delete Python?
A
That depends on where Python came from.

If someone installed it deliberately, you can remove it without hurting anything. On Windows, use the Add/Remove Programs icon in the Control Panel.
Q
Why is Python installed on my machine?
A
If you find Python installed on your system but don’t remember installing it, there are several possible ways it could have gotten there.

Perhaps another user on the computer wanted to learn programming and installed it; you’ll have to figure out who’s been using the machine and might have installed it.
Q
What is Python?
A
Python is a programming language. It’s used for many different applications. It’s used in some high schools and colleges as an introductory programming language because Python is easy to learn,