Construcción de entorno de base de 0-Python

instalar debajo de la ventana


1. Instalar Python

Descargue python-3.7.0-amd64.exe, instálelo directamente en el siguiente paso, recuerde verificar Add Python 3.7 to PATH
https://www.python.org/downloads/release/python-370/

2. Instale las bibliotecas y servicios requeridos por el servidor web

1. Instale mysql, vea el tutorial de instalación de mysql

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

2.pip3 instalar jinja2 aiomysql aiohttp

3. Instalar pyCharm64

El desarrollo de win debe tener un entorno de desarrollo integrado, es muy conveniente usar pyCharm.

Descargue la versión profesional y crack, para que pueda escribir css, código js
https://blog.csdn.net/u014044812/article/details/78727496

K71U8DBPNE-eyJsaWNlbnNlSWQiOiJLNzFVOERCUE5FIiwibGljZW5zZWVOYW1lIjoibGFuIHl1IiwiYXNzaWduZWVOYW1lIjoiIiwiYXNzaWduZWVFbWFpbCI6IiIsImxpY2Vuc2VSZXN0cmljdGlvbiI6IkZvciBlZHVjYXRpb25hbCB1c2Ugb25seSIsImNoZWNrQ29uY3VycmVudFVzZSI6ZmFsc2UsInByb2R1Y3RzIjpbeyJjb2RlIjoiSUkiLCJwYWlkVXBUbyI6IjIwMTktMDUtMDQifSx7ImNvZGUiOiJSUzAiLCJwYWlkVXBUbyI6IjIwMTktMDUtMDQifSx7ImNvZGUiOiJXUyIsInBhaWRVcFRvIjoiMjAxOS0wNS0wNCJ9LHsiY29kZSI6IlJEIiwicGFpZFVwVG8iOiIyMDE5LTA1LTA0In0seyJjb2RlIjoiUkMiLCJwYWlkVXBUbyI6IjIwMTktMDUtMDQifSx7ImNvZGUiOiJEQyIsInBhaWRVcFRvIjoiMjAxOS0wNS0wNCJ9LHsiY29kZSI6IkRCIiwicGFpZFVwVG8iOiIyMDE5LTA1LTA0In0seyJjb2RlIjoiUk0iLCJwYWlkVXBUbyI6IjIwMTktMDUtMDQifSx7ImNvZGUiOiJETSIsInBhaWRVcFRvIjoiMjAxOS0wNS0wNCJ9LHsiY29kZSI6IkFDIiw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knZlD+PTAsWGu9GyLmhti2EnVwGybSD2Dxmhxk3IPCkhKAK+pl0eWYGZWG3tJ9mZ7SowcXLWDFAk0lRJnKGFMTggrWjV8GYpw5bq23VmIqqDLgkNzuoog==

Instalar bajo Centos


1. Instalar Python

Instale el compilador gcc y zlib de antemano al compilar zlib-devel

Descargar el paquete de instalación de Python

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

2. Descomprimir

tar -zxvf Python-3.7.0.tgz

3. Compile e instale el paquete

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

4. Agregar variables de entorno

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

A veces ocurre el siguiente error

ModuleNotFoundError: No module named '_ctypes'

Simplemente instale de la siguiente manera:

yum install libffi-devel -y

5. Compruebe si tiene éxito, ejecute el siguiente código

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. Modifique la versión predeterminada de Python (este paso puede no ser necesario, ya que hará que supervisorctl no se inicie, supervisorctl solo puede ejecutarse en python2)

1. Verifique que la versión predeterminada de Python sea 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. Modifique la ruta de Python predeterminada del sistema, porque al ingresar comandos de Python en el terminal, el valor predeterminado es apuntar a 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. Abra una nueva terminal, ingrese al entorno de python a través del comando python, puede ver que hemos señalado nuestro python 3.7.0 recién instalado:

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. Después de cambiar el python predeterminado, encontré un error al instalar usando yum

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

6. Debido a que yum depende de python, entonces aquí modificamos el python predeterminado, debemos modificar yum, para que se ejecute a la versión anterior:

vi /usr/bin/yum   

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

7. Si hay otros errores, es posible que deba modificar los dos archivos.

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. Instale las bibliotecas y servicios requeridos por el servidor web

1. Instale mysql, vea el tutorial de instalación de mysql

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

2.pip3 instalar jinja2 aiomysql aiohttp

3.yum install openssh-server nginx supervisor dos2unix

Las siguientes dos herramientas se usan aquí

  • 1. Supervisor: una herramienta para monitorear el proceso de servicio;

El objetivo principal de esta herramienta es utilizar Supervisor para iniciar nuestro proceso app.py, de modo que si hay un problema con el proceso app.py, el registro se guardará y reiniciará.

Use echo_supervisord_conf para generar el archivo de configuración predeterminado, que se guarda en supervisord.conf

echo_supervisord_conf > /etc/supervisord.conf

Modifique las dos últimas líneas de /etc/supervisord.conf

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

Agregue el archivo de configuración awesome.conf en /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

Para ver quién posee los permisos de www para ejecutar, configure quién es el usuario en awesome.conf anterior.

[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

Referencia: 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

Pruebe si el proceso de supervisión surte efecto, encuentre el proceso de app.py kill, puede encontrar que aparece una nueva identificación del proceso app.py

[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: servidor web de alto rendimiento + responsable del proxy inverso;

Usando el propio asyncio de Python, hemos escrito un servidor asíncrono de alto rendimiento. Sin embargo, también necesitamos un servidor web de alto rendimiento, elija Nginx aquí, puede manejar recursos estáticos y, al mismo tiempo, un proxy inverso para enviar solicitudes dinámicas al procesamiento de código Python

Combinación dinámica y estática, nuestro servidor Python es dinámico y se modificará; Nginx es estático, actúa como proxy y es más seguro. Por ejemplo, si el servidor Python tiene un problema, no generará información de depuración directamente al cliente debido a negligencia. Un servidor Nginx devuelve directamente un error 502 al cliente.

[Falló la transferencia de la imagen de la cadena externa, el sitio de origen puede tener un mecanismo de cadena antirrobo, se recomienda guardar la imagen y cargarla directamente (img-I6JFuSpA-1581847379782) (https://cdn.liaoxuefeng.com/cdn/files/attachments/0014328837392452ed92e4e2938456ec83812000457ec8491252ed92e4e293845622cd9491252ed92e4e2938456ec8491252ed92e4e2938456ec8381252456ec8 )]

[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

Como no hay una interfaz en el servidor de Alibaba Cloud y no sé si nginx se inicia normalmente, puedo usar curl para ir al contenido de la página web y luego copiarlo para ganar y ver si la página html se muestra correctamente.

Como sigue:

[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 se puede acceder a la computadora local normalmente y no se puede acceder a la red externa, debe verificar la configuración del grupo de seguridad en Alibaba Cloud para ver si el puerto 80 y el puerto 443 están abiertos.

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

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

Si todavía no funciona, es posible que deba configurar las reglas del firewall.

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

Instalar bajo Ubuntu


1. Instalar Python

1, actualización apt-get

2, apt-get update

Instale python3.5 directamente y descubra que hay un problema al instalar distribuir bajo 3.6

3, apt-get install python3.6

4 、 apt-get install python3.6-dev

ubuntu tiene python3.4 instalado por defecto

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

Por lo tanto, debemos cambiar el valor predeterminado a python3.6

Establezca la versión predeterminada 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

Establecer la versión predeterminada 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. Establecer pip:

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

6. Ver 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 : el módulo 'importlib._bootstrap' no tiene el atributo 'SourceFileLoader'。

Finalmente encontrado: distribuir solo se puede instalar en la versión python 3.5.x.

7, instale apt-get install python3, apt-get install python3.5-dev cambie a 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. Actualizar pip3

pip3 install --upgrade setuptools
2. Instale las bibliotecas y servicios requeridos por el servidor web

1. Instale mysql, vea el tutorial de instalación de mysql

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

2.pip3 instalar jinja2 aiomysql aiohttp

pip3 instalar criptografía idna_ssl

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

4. Configure Supervisor: una herramienta para monitorear el progreso del servicio

Escriba un archivo de configuración de Supervisor awesome.conf y guárdelo en el directorio /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

Crea una carpeta impresionante en srv.

Use fabfile_win.py para sincronizar el proyecto con ubuntu, recuerde modificar la ip y el nombre de usuario.

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

Crear / srv / awesome / log / folder

service supervisor start

Cuando aparezca unix:///var/run/supervisor.sock no such file, cree uno usted mismo, con permisos

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

5. Nginx: servidor web de alto rendimiento + responsable del proxy inverso;

El contenido en / etc / nginx / sites-available / default se cambia de la siguiente manera:

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

106 artículos originales publicados · 76 elogiados · 130,000 visitas +

Supongo que te gusta

Origin blog.csdn.net/Creator_Ly/article/details/93178538
Recomendado
Clasificación