0-Python foundation-environment construction

install under window


1. Install Python

Download python-3.7.0-amd64.exe, install directly in the next step, remember to check Add Python 3.7 to PATH
https://www.python.org/downloads/release/python-370/

2. Install the libraries and services required by the web server

1. Install mysql, view the mysql installation tutorial

安装完测试正常后,使用以下命令部署web的后台数据库框架
mysql -u root -p < schema.sql

2.pip3 install jinja2 aiomysql aiohttp

3. Install pyCharm64

The development of win must have an integrated development environment, it is very convenient to use pyCharm.

Download the professional version and crack, so that you can write css, js code
https://blog.csdn.net/u014044812/article/details/78727496

K71U8DBPNE-eyJsaWNlbnNlSWQiOiJLNzFVOERCUE5FIiwibGljZW5zZWVOYW1lIjoibGFuIHl1IiwiYXNzaWduZWVOYW1lIjoiIiwiYXNzaWduZWVFbWFpbCI6IiIsImxpY2Vuc2VSZXN0cmljdGlvbiI6IkZvciBlZHVjYXRpb25hbCB1c2Ugb25seSIsImNoZWNrQ29uY3VycmVudFVzZSI6ZmFsc2UsInByb2R1Y3RzIjpbeyJjb2RlIjoiSUkiLCJwYWlkVXBUbyI6IjIwMTktMDUtMDQifSx7ImNvZGUiOiJSUzAiLCJwYWlkVXBUbyI6IjIwMTktMDUtMDQifSx7ImNvZGUiOiJXUyIsInBhaWRVcFRvIjoiMjAxOS0wNS0wNCJ9LHsiY29kZSI6IlJEIiwicGFpZFVwVG8iOiIyMDE5LTA1LTA0In0seyJjb2RlIjoiUkMiLCJwYWlkVXBUbyI6IjIwMTktMDUtMDQifSx7ImNvZGUiOiJEQyIsInBhaWRVcFRvIjoiMjAxOS0wNS0wNCJ9LHsiY29kZSI6IkRCIiwicGFpZFVwVG8iOiIyMDE5LTA1LTA0In0seyJjb2RlIjoiUk0iLCJwYWlkVXBUbyI6IjIwMTktMDUtMDQifSx7ImNvZGUiOiJETSIsInBhaWRVcFRvIjoiMjAxOS0wNS0wNCJ9LHsiY29kZSI6IkFDIiwicGFpZFVwVG8iOiIyMDE5LTA1LTA0In0seyJjb2RlIjoiRFBOIiwicGFpZFVwVG8iOiIyMD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cXLWDFAk0lRJnKGFMTggrWjV8GYpw5bq23VmIqqDLgkNzuoog==

Install under Centos


1. Install Python

Install gcc compiler and zlib in advance when compiling zlib-devel

Download Python installation package

cd /usr/local/src
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz

2. Unzip

tar -zxvf Python-3.7.0.tgz

3. Compile and install the package

cd Python-3.7.0
./configure --prefix=/usr/local/python
make && make install

4. Add environment variables

#echo PATH='/usr/local/python/bin/:$PATH' >> /etc/profile
<br>#source /etc/profile

Sometimes the following error occurs

ModuleNotFoundError: No module named '_ctypes'

Just install as follows:

yum install libffi-devel -y

5. Check whether it is successful, execute the following code

python3.7
Python 3.7.0 (default, Nov 27 2018, 10:35:54)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
2. Modify the default python version (this step may not be necessary, because it will cause supervisorctl to not start, supervisorctl can only run on python2)

1. Check the default python version is 2.7.5

python
Python 2.7.5 (default, Jul 13 2018, 13:06:57)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()

2. Modify the default Python path of the system, because when entering Python commands in the terminal, the default is to point to Python 2.7.5

mv /usr/bin/python /usr/bin/python-2.7.5
``` 

3.建立新的软连接,指向Python-3.7.0  

ln -s /usr/local/python/bin/python3.7 /usr/bin/python
 ```

4. Open a new terminal, enter the python environment through the python command, you can see that we have pointed to our newly installed python 3.7.0:

python
Python 3.7.0 (default, Nov 27 2018, 10:35:54)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print("test")
test
>>> exit()

5. After changing the default python, I found an error when installing using yum

 yum install openssh-server
  File "/usr/bin/yum", line 30
    except KeyboardInterrupt, e:
                            ^
SyntaxError: invalid syntax

6. Because yum depends on python, so here we modify the default python, we must modify yum, so that it runs to the old version:

vi /usr/bin/yum   

将第一行中的“#!/usr/bin/python”   
修改为“#!/usr/bin/python-2.7.5”
保存即可

7. If there are other errors, you may need to modify the two files

yum install tree
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package tree.x86_64 0:1.6.0-10.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================
 Package                Arch                     Version                        Repository              Size
=============================================================================================================
Installing:
 tree                   x86_64                   1.6.0-10.el7                   base                    46 k

Transaction Summary
=============================================================================================================
Install  1 Package

Total download size: 46 k
Installed size: 87 k
Is this ok [y/d/N]: y
Downloading packages:
  File "/usr/libexec/urlgrabber-ext-down", line 28
    except OSError, e:
                  ^
SyntaxError: invalid syntax


Exiting on user cancel

1. vim /usr/libexec/urlgrabber-ext-down

将/usr/bin/python改为/usr/bin/python-2.7.5。

2. vim /usr/bin/yum-config-manager

解决办法同上: #!/usr/bin/python换成 #!/usr/bin/python-2.7.5 
3. Install the libraries and services required by the web server

1. Install mysql, view the mysql installation tutorial

安装完测试正常后,使用以下命令部署web的后台数据库框架
mysql -u root -p < schema.sql

2.pip3 install jinja2 aiomysql aiohttp

3.yum install openssh-server nginx supervisor dos2unix

The following two tools are used here

  • 1. Supervisor: a tool to monitor the service process;

The main purpose of this tool is to use Supervisor to start our app.py process, so that if there is a problem with the app.py process, it will be saved and restarted.

Use echo_supervisord_conf to generate the default configuration file, which is saved in supervisord.conf

echo_supervisord_conf > /etc/supervisord.conf

Modify the last two lines of /etc/supervisord.conf

[include]
files = /etc/supervisord.d/*.conf

Add the configuration file awesome.conf in /etc/supervisord.d/

[program:awesome]
command     = /srv/awesome/www/app.py
directory   = /srv/awesome/www
user        = root
startsecs   = 3
redirect_stderr         = true
stdout_logfile_maxbytes = 50MB
stdout_logfile_backups  = 10
stdout_logfile          = /srv/awesome/log/app.log

To see who owns the permissions of the www to be run, configure who the user in awesome.conf above is

[root@centos awesome]# ls -l
total 24
drwxr-xr-x 2 root root 4096 Nov 27 17:23 log
lrwxrwxrwx 1 root root   21 Nov 27 16:56 www -> www-18-11-27_16.56.28
drwxr-xr-x 4 root root 4096 Nov 27 16:09 www-18-11-27_16.08.59
drwxr-xr-x 4 root root 4096 Nov 27 16:26 www-18-11-27_16.26.12
drwxr-xr-x 4 root root 4096 Nov 27 16:28 www-18-11-27_16.28.37
drwxr-xr-x 4 root root 4096 Nov 27 16:53 www-18-11-27_16.53.41
drwxr-xr-x 5 root root 4096 Nov 27 17:11 www-18-11-27_16.56.28

Reference: https://www.cnblogs.com/wswang/p/5795766.html

supervisorctl stop program_name  # 停止某一个进程,program_name 为 [program:x] 里的 x

supervisorctl start program_name  # 启动某个进程

supervisorctl restart program_name  # 重启某个进程

supervisorctl stop groupworker:  # 结束所有属于名为 groupworker 这个分组的进程 (start,restart 同理)

supervisorctl stop groupworker:name1  # 结束 groupworker:name1 这个进程 (start,restart 同理)

supervisorctl stop all  # 停止全部进程,注:start、restartUnlinking stale socket /tmp/supervisor.sock
、stop 都不会载入最新的配置文件

supervisorctl reload  # 载入最新的配置文件,停止原有进程并按新的配置启动、管理所有进程

supervisorctl update  # 根据最新的配置文件,启动新配置或有改动的进程,配置没有改动的进程不会受影响而重启
[root@centos awesome]# supervisorctl stop awesome
awesome: stopped
[root@centos awesome]# supervisorctl start awesome
awesome: started
[root@centos awesome]# supervisorctl status
awesome                          RUNNING   pid 30182, uptime 0:00:13

Test whether the supervisord process takes effect, find the process of app.py kill, you can find that a new id of app.py process appears

[root@centos awesome]# ps -aux | grep python
root     11340  0.0  1.4 573812 14660 ?        Ssl  Nov23   0:39 /usr/bin/python -Es /usr/sbin/tuned -l -P
root     30161  0.0  1.6 225936 17072 ?        Ss   17:23   0:00 /usr/bin/python /usr/bin/supervisord -c /etc/supervisord.conf
root     30182  0.0  2.6 250196 26612 ?        S    17:28   0:00 python3 /srv/awesome/www/app.py
root     30350  0.0  0.0 112704   972 pts/0    R+   18:00   0:00 grep --color=auto python
[root@centos awesome]# kill 30182
[root@centos awesome]# ps -aux | grep python
root     11340  0.0  1.4 573812 14660 ?        Ssl  Nov23   0:39 /usr/bin/python -Es /usr/sbin/tuned -l -P
root     30161  0.0  1.6 225936 17068 ?        Ss   17:23   0:00 /usr/bin/python /usr/bin/supervisord -c /etc/supervisord.conf
root     30364  0.0  2.6 249844 26440 ?        S    18:01   0:00 python3 /srv/awesome/www/app.py
root     30366  0.0  0.0 112704   976 pts/0    R+   18:01   0:00 grep --color=auto python


  • 2. Nginx: high-performance web server + responsible for reverse proxy;

Using Python's own asyncio, we have written an asynchronous high-performance server. However, we also need a high-performance Web server, choose Nginx here, it can handle static resources, and at the same time as a reverse proxy to send dynamic requests to Python code processing

Dynamic and static combination, our python server is dynamic and will be modified; Nginx is static, acting as a proxy, and more secure. For example, if the python server has a problem, it will not output debug information directly to the client because of negligence An Nginx server directly returns a 502 error to the client.

[External chain image transfer failed. The source site may have an anti-theft chain mechanism. It is recommended to save the image and upload it directly (img-I6JFuSpA-1581847379782) )]

[root@centos ~]# ps -aux | grep nginx
root       737  0.0  0.0 112704   968 pts/0    S+   10:00   0:00 grep --color=auto nginx
root     30865  0.0  0.2 120792  2100 ?        Ss   Nov27   0:00 nginx: master process nginx
nginx    30866  0.0  0.3 121180  3584 ?        S    Nov27   0:00 nginx: worker process

systemctl restart nginx.service/service nginx restart

systemctl stop nginx.service/service nginx stop

systemctl start nginx.service/service nginx start

systemctl status nginx.service/service nginx status

Because there is no interface on the Alibaba Cloud server and I do n’t know whether nginx starts normally, I can use curl to go to the web page content, and then copy it to win to see if the html page is displayed properly.

as follows:

[root@centos nginx]# curl http://127.0.0.1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
        <title>Test Page for the Nginx HTTP Server on Fedora</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <style type="text/css">
            /*<![CDATA[*/
            body {
                background-color: #fff;
                color: #000;
                font-size: 0.9em;
                font-family: sans-serif,helvetica;
                margin: 0;
                padding: 0;
            }
            :link {
                color: #c00;
            }
            :visited {
                color: #c00;
            }
            a:hover {
                color: #f50;
            }
            h1 {
                text-align: center;
                margin: 0;
                padding: 0.6em 2em 0.4em;
                background-color: #294172;
                color: #fff;
                font-weight: normal;
                font-size: 1.75em;
                border-bottom: 2px solid #000;
            }
            h1 strong {
                font-weight: bold;
                font-size: 1.5em;
            }
            h2 {
                text-align: center;
                background-color: #3C6EB4;
                font-size: 1.1em;
                font-weight: bold;
                color: #fff;
                margin: 0;
                padding: 0.5em;
                border-bottom: 2px solid #294172;
            }
            hr {
                display: none;
            }
            .content {
                padding: 1em 5em;
            }
            .alert {
                border: 2px solid #000;
            }

            img {
                border: 2px solid #fff;
                padding: 2px;
                margin: 2px;
            }
            a:hover img {
                border: 2px solid #294172;
            }
            .logos {
                margin: 1em;
                text-align: center;
            }
            /*]]>*/
        </style>
    </head>

    <body>
        <h1>Welcome to <strong>nginx</strong> on Fedora!</h1>

        <div class="content">
            <p>This page is used to test the proper operation of the
            <strong>nginx</strong> HTTP server after it has been
            installed. If you can read this page, it means that the
            web server installed at this site is working
            properly.</p>

            <div class="alert">
                <h2>Website Administrator</h2>
                <div class="content">
                    <p>This is the default <tt>index.html</tt> page that
                    is distributed with <strong>nginx</strong> on
                    Fedora.  It is located in
                    <tt>/usr/share/nginx/html</tt>.</p>

                    <p>You should now put your content in a location of
                    your choice and edit the <tt>root</tt> configuration
                    directive in the <strong>nginx</strong>
                    configuration file
                    <tt>/etc/nginx/nginx.conf</tt>.</p>

                </div>
            </div>

            <div class="logos">
                <a href="http://nginx.net/"><img
                    src="nginx-logo.png"
                    alt="[ Powered by nginx ]"
                    width="121" height="32" /></a>

                <a href="http://fedoraproject.org/"><img
                    src="poweredby.png"
                    alt="[ Powered by Fedora ]"
                    width="88" height="31" /></a>
            </div>
        </div>
    </body>
</html>

If the local computer can be accessed normally and the external network cannot be accessed, you need to check the security group configuration on Alibaba Cloud to see if port 80 and port 443 are open.

https://blog.csdn.net/lzl18918615216/article/details/80049471

https://helpcdn.aliyun.com/document_detail/25471.html

If it still doesn't work, you may need to configure firewall rules.

https://blog.csdn.net/lzl18918615216/article/details/80049471

Install under Ubuntu


1. Install Python

1、apt-get upgrade

2、apt-get update

Install python3.5 directly, and find that there is a problem installing distribute under 3.6

3、apt-get install python3.6

4、apt-get install python3.6-dev

ubuntu has python3.4 installed by default

root@ubuntu:/usr/bin# python3 -V
Python 3.4.3

So we need to change the default to python3.6

Set the default version of python:

root@ubuntu:/usr/bin# update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
update-alternatives: using /usr/bin/python2.7 to provide /usr/bin/python (python) in auto mode
root@ubuntu:/usr/bin# update-alternatives --list python
/usr/bin/python2.7
root@ubuntu:/usr/bin# python -V
Python 2.7.6

Set the default version of python3

root@ubuntu:/usr/bin# update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1
update-alternatives: using /usr/bin/python3.6 to provide /usr/bin/python3 (python3) in auto mode
root@ubuntu:/usr/bin# update-alternatives --list python3
/usr/bin/python3.6
root@ubuntu:/usr/bin# python3 -V
Python 3.6.2

5. Set pip:

  • apt-get install python3-pip    # Python3
  • apt-get install python-pip     # Python2

6. View pip3 -V

root@ubuntu:/usr/bin# pip3
Traceback (most recent call last):
  File "/usr/bin/pip3", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 1479, in <module>
    register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'

AttributeError:module ‘importlib._bootstrap’ has no attribute ‘SourceFileLoader’。

Finally found: distribute can only be installed in python 3.5.x version.

7, install apt-get install python3, apt-get install python3.5-dev switch to 3.5

root@ubuntu:/usr/bin# update-alternatives --config python3
There are 2 choices for the alternative python3 (providing /usr/bin/python3).

  Selection    Path                Priority   Status
------------------------------------------------------------
  0            /usr/bin/python3.6   1         auto mode
  1            /usr/bin/python3.5   1         manual mode
* 2            /usr/bin/python3.6   1         manual mode

Press enter to keep the current choice[*], or type selection number: 1
update-alternatives: using /usr/bin/python3.5 to provide /usr/bin/python3 (python3) in manual mode
root@ubuntu:/usr/bin# pip3 -V
pip 1.5.4 from /usr/lib/python3/dist-packages (python 3.5)

8. Update pip3

pip3 install --upgrade setuptools
2. Install the libraries and services required by the web server

1. Install mysql, view the mysql installation tutorial

安装完测试正常后,使用以下命令部署web的后台数据库框架
mysql -u root -p < schema.sql

2.pip3 install jinja2 aiomysql aiohttp

pip3 install idna_ssl cryptography

3.apt-get install libssl-dev openssh-server nginx supervisor dos2unix

4. Configure Supervisor: a tool to monitor service progress

Write a Supervisor configuration file awesome.conf and store it in /etc/supervisor/conf.d/ directory:

[program:awesome]

command     = /srv/awesome/www/app.py
directory   = /srv/awesome/www
user        = root
startsecs   = 3

redirect_stderr         = true
stdout_logfile_maxbytes = 50MB
stdout_logfile_backups  = 10
stdout_logfile          = /srv/awesome/log/app.log

Create awesome folder under srv.

Use fabfile_win.py to synchronize the project to ubuntu, remember to modify the ip and user name.

env.user = 'linye'
env.sudo_user = 'root'
# env.hosts = ['123.123.123.123']
env.host_string = '192.168.61.128' # 改成你的服务器ip

Create / srv / awesome / log / folder

service supervisor start

When it appears unix:///var/run/supervisor.sock no such file, create one by yourself, with permissions

touch /var/run/supervisor.sock
chmod 777 /var/run/supervisor.sock

5. Nginx: high-performance web server + responsible for reverse proxy;

The content in / etc / nginx / sites-available / default is changed as follows:

server {
    listen      80; # 监听80端口

    root       /srv/awesome/www;
    access_log /srv/awesome/log/access_log;
    error_log  /srv/awesome/log/error_log;

    # server_name awesome.liaoxuefeng.com; # 配置域名

    # 处理静态文件/favicon.ico:
    location /favicon.ico {
        root /srv/awesome/www;
    }

    # 处理静态资源:
    location ~ ^\/static\/.*$ {
        root /srv/awesome/www;
    }

    # 动态请求转发到9000端口:
    location / {
        proxy_pass       http://127.0.0.1:9000;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

/etc/init.d/nginx reload

Published 106 original articles · praised 76 · 130,000 visits +

Guess you like

Origin blog.csdn.net/Creator_Ly/article/details/93178538