Construction de la fondation 0-Python-environnement

installer sous la fenêtre


1. Installez Python

Téléchargez python-3.7.0-amd64.exe, installez-le directement à l'étape suivante, n'oubliez pas de vérifier Add Python 3.7 to PATH
https://www.python.org/downloads/release/python-370/

2. Installez les bibliothèques et les services requis par le serveur Web

1. Installez mysql, consultez le tutoriel d'installation de mysql

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

2. installer pipi jinja2 aiomysql aiohttp

3. Installez pyCharm64

Le développement de win doit avoir un environnement de développement intégré, il est très pratique d'utiliser pyCharm.

Téléchargez la version professionnelle et crackez, pour pouvoir écrire du code css, js
https://blog.csdn.net/u014044812/article/details/78727496

K71U8DBPNE-eyJsaWNlbnNlSWQiOiJLNzFVOERCUE5FIiwibGljZW5zZWVOYW1lIjoibGFuIHl1IiwiYXNzaWduZWVOYW1lIjoiIiwiYXNzaWduZWVFbWFpbCI6IiIsImxpY2Vuc2VSZXN0cmljdGlvbiI6IkZvciBlZHVjYXRpb25hbCB1c2Ugb25seSIsImNoZWNrQ29uY3VycmVudFVzZSI6ZmFsc2UsInByb2R1Y3RzIjpbeyJjb2RlIjoiSUkiLCJwYWlkVXBUbyI6IjIwMTktMDUtMDQifSx7ImNvZGUiOiJSUzAiLCJwYWlkVXBUbyI6IjIwMTktMDUtMDQifSx7ImNvZGUiOiJXUyIsInBhaWRVcFRvIjoiMjAxOS0wNS0wNCJ9LHsiY29kZSI6IlJEIiwicGFpZFVwVG8iOiIyMDE5LTA1LTA0In0seyJjb2RlIjoiUkMiLCJwYWlkVXBUbyI6IjIwMTktMDUtMDQifSx7ImNvZGUiOiJEQyIsInBhaWRVcFRvIjoiMjAxOS0wNS0wNCJ9LHsiY29kZSI6IkRCIiwicGFpZFVwVG8iOiIyMDE5LTA1LTA0In0seyJjb2RlIjoiUk0iLCJwYWlkVXBUbyI6IjIwMTktMDUtMDQifSx7ImNvZGUiOiJETSIsInBhaWRVcFRvIjoiMjAxOS0wNS0wNCJ9LHsiY29kZS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NTdVhSm38AknZlD+PTAsWGu9GyLmhti2EnVwGybSD2Dxmhxk3IPCkhKAK+pl0eWYGZWG3tJ9mZ7SowcXLWDFAk0lRJnKGFMTggrWjV8GYpw5bq23VmIqqDLgkNzuoog==

Installer sous Centos


1. Installez Python

Installez le compilateur gcc et zlib à l'avance lors de la compilation de zlib-devel

Télécharger le package d'installation Python

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

2. Décompressez

tar -zxvf Python-3.7.0.tgz

3. Compilez et installez le package

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

4. Ajouter des variables d'environnement

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

Parfois, l'erreur suivante se produit

ModuleNotFoundError: No module named '_ctypes'

Installez simplement comme suit:

yum install libffi-devel -y

5. Vérifiez si elle réussit, exécutez le code suivant

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. Modifiez la version par défaut de python (cette étape peut ne pas être nécessaire, car elle entraînera le non-démarrage de supervisorctl, supervisorctl ne peut s'exécuter que sur python2)

1. Vérifiez que la version par défaut de python est 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. Modifiez le chemin Python par défaut du système, car lorsque vous entrez des commandes Python dans le terminal, la valeur par défaut est de pointer vers 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. Ouvrez un nouveau terminal, entrez dans l'environnement python via la commande python, vous pouvez voir que nous avons pointé notre python 3.7.0 nouvellement installé:

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. Après avoir changé le python par défaut, j'ai trouvé une erreur lors de l'installation à l'aide de yum

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

6. Parce que yum dépend de python, donc ici nous modifions le python par défaut, nous devons modifier yum, afin qu'il s'exécute sur l'ancienne version:

vi /usr/bin/yum   

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

7. S'il y a d'autres erreurs, vous devrez peut-être modifier les deux fichiers

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. Installez les bibliothèques et les services requis par le serveur Web

1. Installez mysql, consultez le tutoriel d'installation de mysql

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

2. installer pipi jinja2 aiomysql aiohttp

3. installer yum opensh-server superviseur nginx dos2unix

Les deux outils suivants sont utilisés ici

  • 1. Superviseur: un outil pour surveiller le processus de service;

L'objectif principal de cet outil est d'utiliser Supervisor pour démarrer notre processus app.py, de sorte que s'il y a un problème avec le processus app.py, le journal sera enregistré et redémarré.

Utilisez echo_supervisord_conf pour générer le fichier de configuration par défaut, qui est enregistré dans supervisord.conf

echo_supervisord_conf > /etc/supervisord.conf

Modifiez les deux dernières lignes de /etc/supervisord.conf

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

Ajoutez le fichier de configuration awesome.conf dans /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

Pour voir à qui appartiennent les autorisations du www à exécuter, configurez qui est l'utilisateur dans awesome.conf ci-dessus

[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

Référence: 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

Testez si le processus de supervision prend effet, recherchez le processus de suppression de app.py, vous pouvez constater qu'un nouvel identifiant de processus app.py apparaît

[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: serveur Web hautes performances + responsable du proxy inverse;

En utilisant le propre asyncio de Python, nous avons écrit un serveur asynchrone hautes performances. Cependant, nous avons également besoin d'un serveur Web hautes performances, choisissez Nginx ici, il peut gérer des ressources statiques, et en même temps qu'un proxy inverse pour envoyer des requêtes dynamiques au traitement de code Python

Combinaison dynamique et statique, notre serveur python est dynamique et sera modifié; Nginx est statique, agissant comme un proxy et plus sécurisé. Par exemple, si le serveur python a un problème, il ne sortira pas les informations de débogage directement au client en raison d'une négligence. Un serveur Nginx renvoie directement une erreur 502 au client.

[Le transfert d'image de la chaîne externe a échoué, le site source peut avoir un mécanisme de chaîne antivol, il est recommandé d'enregistrer l'image et de la télécharger directement (img-I6JFuSpA-1581847379782) (https://cdn.liaoxuefeng.com/cdn/files/attachments/0014328837392452ed92e4e2938456e9d49c )]

[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

Comme il n'y a pas d'interface sur le serveur Alibaba Cloud et que je ne sais pas si nginx démarre normalement, je peux utiliser curl pour accéder au contenu de la page Web, puis le copier pour gagner pour voir si la page html s'affiche correctement.

Comme suit:

[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>

Si l'ordinateur local est accessible normalement et que le réseau externe n'est pas accessible, vous devez vérifier la configuration du groupe de sécurité sur Alibaba Cloud pour voir si le port 80 et le port 443 sont ouverts.

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

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

Si cela ne fonctionne toujours pas, vous devrez peut-être configurer des règles de pare-feu.

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

Installer sous Ubuntu


1. Installez Python

1, mise à niveau apt-get

2, mise à jour apt-get

Installez python3.5 directement et trouvez qu'il y a un problème lors de l'installation de distribuer sous 3.6

3. 、 apt-get install python3.6

4 、 apt-get install python3.6-dev

ubuntu a python3.4 installé par défaut

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

Nous devons donc changer la valeur par défaut en python3.6

Définissez la version par défaut de 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

Définir la version par défaut de 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. Réglez pip:

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

6. Voir 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 : le module 'importlib._bootstrap' n'a pas d'attribut 'SourceFileLoader'。

Enfin trouvé: distribuer ne peut être installé qu'en version python 3.5.x.

7, installez 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. Mettre à jour pip3

pip3 install --upgrade setuptools
2. Installez les bibliothèques et les services requis par le serveur Web

1. Installez mysql, consultez le tutoriel d'installation de mysql

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

2. installer pipi jinja2 aiomysql aiohttp

pip3 installe la cryptographie idna_ssl

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

4. Configurer Supervisor: un outil pour suivre la progression du service

Écrivez un fichier de configuration Supervisor awesome.conf et stockez-le dans le répertoire /etc/supervisor/conf.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

Créez un dossier génial sous srv.

Utilisez fabfile_win.py pour synchroniser le projet avec ubuntu, n'oubliez pas de modifier l'ip et le nom d'utilisateur.

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

Créez / srv / awesome / log / folder

service supervisor start

Lorsqu'il apparaît unix:///var/run/supervisor.sock no such file, créez-en un vous-même, avec des autorisations

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

5. Nginx: serveur Web hautes performances + responsable du proxy inverse;

Le contenu de / etc / nginx / sites-available / default est modifié comme suit:

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 recharger

Publié 106 articles originaux · loué 76 · 130 000 visites +

Je suppose que tu aimes

Origine blog.csdn.net/Creator_Ly/article/details/93178538
conseillé
Classement