Technology stack
Luffy Xuecheng deployment vue + nginx + uwsgi + django + mysql + redis (that is, a key - value databases, database cache, memory database)
Deployment steps (step 4)
1. The deployment of the front vue
1 Download vue code decompression wget HTTPS: // files.cnblogs.com/files/pyyu/07-luffy_project_01.zip the unzip 07 - luffy_project_01.zip 2 . Configuration node environment, to compile the package vue codes to download the code package node HTTPS wget: // nodejs.org/download/release/v8.6.0/node-v8.6.0-linux-x64.tar.gz decompressor node code package the tar -zxvf node-V8. 6.0 -linux- x64.tar. gz configuration node PATH environment variable to modify the PATH to take effect vim / etc / Profile Source / etc / Profile 3 . verification node is configured correctly (node is like a python interpreter is like a pip npm package management tool) node - v npm- v 4 . Vue modify the code files since vue need to initiate a request to the background, to find uwsgi our architecture is hidden behind nginx uwsgi all, vue (port 80) is the first to find nginx (reverse proxy, port 9000) then nginx (reverse proxy, port 9000) reverse proxy to uwsgi (rear end of the address, 9001 ) modified as follows api.js path as / opt / s18luffy / 07 -luffy_project_01 / src / RESTful # here to change your own ip address server Sed -i " S / 127.0.0.1: 8000 / 192.168.226.128: 9000 / G " api.js Sed linux processing command strings is - I is to replace the result to the file " S / 127.0.0.1: 8000 /192.168.226.128:9000/g " # s interpretation is to replace the model / you want to replace the contents of / results you want to replace / G is a global replacement api.js you want to modify the operation of the file 5. Packaged vue, generate static folder dist sure you vue code file in the folder npm install # modules required to solve vue code depends npm run build # compile package 6 . When vue packaged correctly completed, generate a static file dist folder, then give nginx threw to deal with it! ! !
2. deploy the back-end uwsgi
1 download Luffy codes. Wget HTTPS: // files.cnblogs.com/files/pyyu/luffy_boy.zip 2 Install the new virtual environment to address environmental dependencies, you can rely on to solve the problem with requirements.txt. Vim requirements.txt # open, edit module dependency package information is written as follows certifi == 2018.11 . 29 the chardet == 3.0 . . 4 Crypto == 1.4 . . 1 the Django == 2.1 . . 4 Django -redis == 4.10 . 0 Django -rest-== Framework 0.1 . 0 djangorestframework == 3.9 . 0 IDNA == 2.8 Naked == 0.1 . 31 is PyCrypto == 2.6 . . 1 the pytz == 2018.7 PyYAML == 3.13 Redis == 3.0 . . 1 Requests == 2.21 . 0 shellescape == 3.4 . . 1 urllib3 == 1.24 . . 1 uWSGI = = 2.0 . 17.1 3 installing this file requirements.txt PIP3 install -i HTTPS: //-r requirements.txt pypi.douban.com/simple 4 using uwsgi to start Luffy Xuecheng backend. Start using uwsgi.ini profile way, as follows [uwsgi] # Django - Related Settings # at The Base Directory (Full path ) absolute path # fill items (first layer path) the chdir = / opt / s18luffy / luffy_boy # the Django ' S WSGI file # crm fill wsgi.py files in the directory path of the second layer Module1 = luffy_boy.wsgi # the the virtualenv (Full path) # fill in the virtual environment of absolute path Home = / root / Envs / s18luffy # Process - Related Settings # Master Master =to true # Number The maximum Processes of worker # uwsgi based multi-process, according to the cpu to optimize Processes = 4 # at The socket (use at The Full path to BE Safe # If you use nginx reverse proxy, fill out socket parameter # If you use a nginx reverse proxy, fill out socket parameter # If you use nginx reverse proxy, fill out socket parameter # If you use nginx reverse proxy, fill out socket parameter # If you use nginx reverse proxy, fill out parameters socket socket = 0.0 . 0.0 : 9001 #, if you have not nginx, wanted to test the backend directly through the browser, use HTTP #http = 0.0 . 0.0 : 9001 # Appropriate ... with the Permissions - May BE needed # chmod -socket = 664 ON the Clear Environment Exit # Vacuum = to true 5 . Also with a supervisor to manage Luffy background [Program: s18luffy] the Command = / root / Envs / s18luffy / bin / uwsgi --ini / opt / s18luffy / luffy_boy / uwsgi.ini stopasgroup = to true killasgroup = to true
3.nginx reverse proxy forwards
Nginx.conf modified as follows Hosting. 1 Server { # first virtual server listens on port 80 the listen 80 ; server_name 192.168 . 226.128 ; LOCATION / { the root / opt / s18luffy / 07 -luffy_project_01 / dist; index index.html; } } Hosting 2 Server { the listen 9000 ; server_name 192.168 . 226.128 ; LOCATION / { uwsgi_pass 0.0 .0.0 : 9001 ; the include uwsgi_params; } } restart commencement nginx
4. Start redis, Luffy Xuecheng use the sqllite, does not require mysql
Redis install yum - the y-# install command systemctl Start Redis Redis login command Redis - cli login command input to return a ping pong behalf login to start properly
5 .Windows access road to fly home Xuecheng, view the course list, perform alex account login account: alex Password: alex3714 after login, add django course information, you can view the shopping cart information, on behalf of proper start Luffy Xuecheng