Build a Python data analytics platform

Source: Internet
Author: User
Tags http authentication debian server jupyter jupyter notebook

Basic structure


In fact, there is nothing advanced, but it is the usual set of:

Pandas, NumPy, matplotlib ...

But in order to be more convenient to use, the addition of Jupyter notebook (that is, the former Ipython notebook) ...

In order to be more convenient to use, the front end added nginx or Apache anti-generation ...

Double in order to be more secure, add a let's encrypt HTTPS (just this server does not have 80 ports, the reason you understand, so you can not use the method I said before, here with a new method) ...

Installation Environment


I install the required packages manually on my FreeBSD or Debian server, but this method is not suitable for unfamiliar people.

In contrast, Linux or Mac is handy, but under Windows it's a nightmare-because all packages that contain non-Python dependencies, except the Pure Python package, are cumbersome to install under Windows- After all, Windows does not have its own compilation environment.

So here's the easy way: Anaconda.

Anaconda is a good thing to do with python--especially those who don't love tossing--the necessary big kill device. It's the equivalent of packaging Python's basic environment and commonly used packages, even including the package manager, with Anaconda, which makes it easy to use Python on all platforms.

Installation is very simple, directly from the official website to download the installation program to run.

Note that it is highly recommended to install the Python3 version, after all, Python2 is out.

Preliminary use


After loading the Anaconda,python environment is ready to use-of course, the command line, or add an editor, idle the goods I think is not as good as vim. If you want to work well, you should install an IDE, such as Pycharm, but for beginners or non-programmers, it is not necessary, or notebook convenient and simple.

Earlier this is a part of Ipython, is a web version of the Ipython, later Ipython became jupyter, so it has become jupyter notebook.

Jupyter notebook is already included in the latest version of the Anaconda, so it can be used directly.

Using notebook locally is very simple and runs:

650) this.width=650; "Src=" http://image2.135editor.com/cache/remote/ Ahr0chm6ly9tbwjpei5xbg9nby5jbi9tbwjpel9wbmcvsva3mfzpyzqxn0rqyu05t1voallwawfiawi0zwlhmgvxn1vvcghwdxluvtfhzzj3zgtvvxo5rgnlb Khvawe1bflwuu9cwki2tgfvqxfbyzbtbldvvw51bhllus8wp3d4x2ztdd1wbmc= "alt=" ahr0chm6ly9tbwjpei5xbg9nby5jbi9tbwjpel9w " />

Launches an instance and automatically opens a browser page, which is then ready to work.

This is certainly possible, but the better way is to let it run on the remote server and open it through the browser.

The simplest way is to open the 8888 port, but it is not safe, not recommended, so you need to make some configuration.

Configuring Jupyter Notebook


Compared to Ipython notebook, the new Jupyter notebook use configuration more convenient than the original.

The first is to create the configuration file:

650) this.width=650; "Src=" http://image2.135editor.com/cache/remote/ Ahr0chm6ly9tbwjpei5xbg9nby5jbi9tbwjpel9wbmcvsva3mfzpyzqxn0rqyu05t1voallwawfiawi0zwlhmgvxn1vvdkvqm1q2svy2uklsmzzmt0zink9sa Mzjwnbyz0rleepyvmdsy0jivgzmcwlirzbwtdv6ytl1qs8wp3d4x2ztdd1wbmc= "alt=" ahr0chm6ly9tbwjpei5xbg9nby5jbi9tbwjpel9w " />

Then you can see jupyter_notebook_config.py this configuration file under ~/.jupyter/, there are many configuration options can be modified, but here is not in detail, interested people to study it.

Here is only one:

650) this.width=650; "Src=" http://image2.135editor.com/cache/remote/ Ahr0chm6ly9tbwjpei5xbg9nby5jbi9tbwjpel9wbmcvsva3mfzpyzqxn0rqyu05t1voallwawfiawi0zwlhmgvxn1vvtwd5oxluuwtaa2f6yw5uovyyovhvq 2pjsvz5tghnazeyb1hmtk53bmxxbvlvmux3awjvy0xkqs8wp3d4x2ztdd1wbmc= "alt=" ahr0chm6ly9tbwjpei5xbg9nby5jbi9tbwjpel9w " />

Changing this to false will not automatically open the browser.

But manually open the browser there is a problem, you need to enter a token to log in, and this token needs to start log to see, a little trouble. So you need to configure a login password for yourself:

650) this.width=650; "Src=" http://image2.135editor.com/cache/remote/ ahr0chm6ly9tbwjpei5xbg9nby5jbi9tbwjpel9wbmcvsva3mfzpyzqxn0rqyu05t1voallwawfiawi0zwlhmgvxn1vvrny5mks4nk9pr0jpywvjawm0a015v glioudtz3bks2dxwvl2u0v2akzwawjmbzr0wmvzug1qawftc3cvmd93ef9mbxq9cg5n "alt=" ahr0chm6ly9tbwjpei5xbg9nby5jbi9tbwjpel9w "/>

After that, enter the password to be set in the command line, then automatically save to the configuration file, restart Jupyter notebook after the use.

Reverse proxy configuration


Because Jupyter notebook uses websock, it is not easy to configure the reverse proxy to port 8888.

The Nginx configuration is as follows:

650) this.width=650; "Src=" http://image2.135editor.com/cache/remote/ Ahr0chm6ly9tbwjpei5xbg9nby5jbi9tbwjpel9wbmcvsva3mfzpyzqxn0rqyu05t1voallwawfiawi0zwlhmgvxn1vvz2r1djlvawftz1jssdndaldun0vsn nbvrxzosdluodztzxvyruxewmlhawe5bwljzwlhuhlzynh0qwcvmd93ef9mbxq9cg5n "alt=" ahr0chm6ly9tbwjpei5xbg9nby5jbi9tbwjpel9w "/>

The Apache configuration is as follows:

650) this.width=650; "Src=" http://image2.135editor.com/cache/remote/ Ahr0chm6ly9tbwjpei5xbg9nby5jbi9tbwjpel9wbmcvsva3mfzpyzqxn0rqyu05t1voallwawfiawi0zwlhmgvxn1vvawe1vthmawfidty5wk42dgfnyu9py Mvov1kyvjvctujgqmljzlfnoe9sduo4cupiu2z1n095duvtus8wp3d4x2ztdd1wbmc= "alt=" ahr0chm6ly9tbwjpei5xbg9nby5jbi9tbwjpel9w "/>

HTTPS configuration


HTTPS configuration before the article said many times, but this time to introduce a different method.

Because the original problem with Acme-tiny is the need for HTTP support to implement domain name verification, and I now have the problem is that no 80 port is available, so this method does not work.

But there is no way, because let's encrypt in addition to support HTTP authentication, there are many other ways, such as DNS (but need to have the domain Name service provider has API support), and here to say: Tls-sni mode, that is, HTTPS only mode.

This is supported by let's encrypt official client, so it needs to be installed first (in Nginx, for example):

650) this.width=650; "Src=" http://image2.135editor.com/cache/remote/ Ahr0chm6ly9tbwjpei5xbg9nby5jbi9tbwjpel9wbmcvsva3mfzpyzqxn0rqyu05t1voallwawfiawi0zwlhmgvxn1vvqnv4vvduq1gyzzjrt0tqawf4ektpy mdcmxrcyuxxng9ntevpynezztn3rnphbhj2cvljqutuzgj3lza/d3hfzm10pxbuzw== "alt=" d3hfzm10pxbuzw== "/>

Then you can create the certificate:

650) this.width=650; "Src=" http://image2.135editor.com/cache/remote/ Ahr0chm6ly9tbwjpei5xbg9nby5jbi9tbwjpel9wbmcvsva3mfzpyzqxn0rqyu05t1voallwawfiawi0zwlhmgvxn1vvzu9unvf1u2m1owfcmfrmmnprawfmt Mtyvxjnawjdwvj6qkhhanfnr1zyzxnraef4uupyawf3awi3zy8wp3d4x2ztdd1wbmc= "alt=" ahr0chm6ly9tbwjpei5xbg9nby5jbi9tbwjpel9w "/>

After execution, the certificate can be automatically created and saved, and the corresponding Nginx configuration file will be modified, which is very convenient.

You can now log in and use Jupyter notebook by https://your.domain.name/access, entering the password you configured earlier.

Raptor

Source: http://blog.csdn.net/raptor/article/details/78035782

This article is from the "Marco Linux Training" blog, so be sure to keep this source http://mageedu.blog.51cto.com/4265610/1967456

Build a Python data analytics platform

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.