I. purchase server
Here are some notes
- When you choose to configure linux system, you'd better choose centos7 + instead of centos6+
- To configure the development port, it is better to open the common port and the operation port to prevent the subsequent nginx startup page from being unable to access the ip. Generally, the port permission is not open
- The default server account name is root
II. Update the system installation package (very important)
- yum update -y
- yum -y groupinstall "Development tools"
- yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel psmisc libffi-devel
3. Install mysql
cd ~
-
You can also download the installation package from wget http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
You can also upload the installation package directly
yum -y install mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql-community-server
systemctl start mysqld.service
systemctl status mysqld.service
grep "password" /var/log/mysqld.log (view initial password)
mysql -uroot -p (login mysql)
Change Password
ALTER USER 'root'@'localhost' IDENTIFIED BY 'YWy1234?';
IV. install Redis
1)Go to user root >: cd ~ 2)download redis-5.0.5 >: wget http://download.redis.io/releases/redis-5.0.5.tar.gz 3)Unzip the installation package >: tar -xf redis-5.0.5.tar.gz 4)Enter target file >: cd redis-5.0.5 5)Compiling environment >: make 6)Copy environment to specified path to complete installation >: cp -r ~/redis-5.0.5 /usr/local/redis 7)To configure redis Can start in the background: modify the content below >: vim /usr/local/redis/redis.conf daemonize yes 8)Configuration modification complete >: esc >: :wq 9)Establish a soft connection >: ln -s /usr/local/redis/src/redis-server /usr/bin/redis-server >: ln -s /usr/local/redis/src/redis-cli /usr/bin/redis-cli 10)Background operation redis >: redis-server & ctrl + c 11)test redis Environmental Science >: redis-cli ctrl + c 12)Close redis service >: pkill -f redis -9
V. installation of Python 3.6
1) go to the user root directory >: cd ~ 2) download or upload Python 3.6.7 >: wget https://www.python.org/ftp/python/3.6.7/Python-3.6.7.tar.xz 3) decompress the installation package >: tar -xf Python-3.6.7.tar.xz 4) enter the target file >: cd Python-3.6.7 5) configure the installation path / usr/local/python3 >: ./configure --prefix=/usr/local/python3 6) compile and install >: make && sudo make install 7) establish soft connection: terminal command python3, pip3 >: ln -s /usr/local/python3/bin/python3.6 /usr/bin/python3 >: ln -s /usr/local/python3/bin/pip3.6 /usr/bin/pip3 8) delete the installation package and files: >: rm -rf Python-3.6.7 >: rm -rf Python-3.6.7.tar.xzVi. configure pip image source
1)Establish pip Configuration path >: mkdir ~/.pip 2)Enter the directory to edit the configuration file: fill in the following content cd ~/.pip && vim pip.conf [global] index-url = http://pypi.douban.com/simple [install] use-mirrors =true mirrors =http://pypi.douban.com/simple/ trusted-host =pypi.douban.com
VII. Install virtual environment
1)Installation dependency >: pip3 install virtualenv >: pip3 install virtualenvwrapper 2)Establish virtual environment soft connection >: ln -s /usr/local/python3/bin/virtualenv /usr/bin/virtualenv 3)Configure virtual environment: fill in the following >: vim ~/.bash_profile VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3 source /usr/local/python3/bin/virtualenvwrapper.sh 4)Exit editing status >: esc 5)Save changes and exit >: :wq 6)Update profile content >: source ~/.bash_profile 7)Virtual environment default root:~/.virtualenvs
VIII. Install uwsgi in pip3
1)Install in real environment pip3 install uwsgi 2)Establish a soft connection ln -s /usr/local/python3/bin/uwsgi /usr/bin/uwsgi
IX. installation of Nginx
1) go to the user root directory >: cd ~ 2) Download nginx1.13.7 >: wget http://nginx.org/download/nginx-1.13.7.tar.gz 3) decompress the installation package >: tar -xf nginx-1.13.7.tar.gz 4) enter the target file >: cd nginx-1.13.7 5) configure the installation path / usr/local/nginx >: ./configure --prefix=/usr/local/nginx 6) compile and install >: make && sudo make install 7) establish soft connection: terminal command nginx >: ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx 8) delete the installation package and files: >: rm -rf nginx-1.13.7 >: rm -rf nginx-1.13.7.tar.xz 9) test the nginx environment, the server runs nginx, and the local access server ip >: nginx >: domain name or IP bound by server: 80X. Nginx common commands
1) start up >: nginx 2) turn off nginx >: nginx -s stop 3) restart nginx >: nginx -s reload 4) check the port and close it forcibly >: ps -aux|grep nginx >: kill < PID: process number >Xi. Front end deployment
1. In the project, the ip requested with the backend is changed to the ip of the server (there is no fixed writing method, which can be flexibly set according to its own project) Front end project packaging cnpm run build (project directory execution) After packing, there will be a dist folder, as long as he is good Upload to ~ (root) Move and rename mv ~/dist /home/htmlXII. Back end deployment
1)Content to be modified online settings.py DEBUG = False ALLOWED_HOSTS = [ '39.100.107.176' # Public ip address ] CORS_ORIGIN_ALLOW_ALL = True # Allow all cross domains CORS_ORIGIN_WHITELIST = [ ] 2 )Upload and move/home/project 3 )Configure in advance uwsgi Set up vim /home/project/Your background project name/Configured file name.xml The contents written in it are as follows: <uwsgi> <socket>127.0.0.1:8808</socket> <!-- Internal port, custom --> <chdir>/home/project/Your background project name/</chdir> <!-- Project path --> <module>xxxx.wsgi</module> <!-- xxxx by wsgi.py Directory name--> <processes>4</processes> <!-- Process number --> <daemonize>uwsgi.log</daemonize> <!-- log file --> </uwsgi> Save and exit
XIII. Export local dependency, server installation dependency
Enter backstage project pip3 freeze > packages.txt Upload packages.txt to the server pip3 install -r packages.txtXIV. Database migration (no database correlation can be ignored)
Playing with DJANGO migration is exactly the same as executing commands in CMD.15. Configure online startup
vim /usr/local/nginx/conf/nginx.conf //Write as follows: events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; server { listen 8000; server_name 127.0.0.1; # Change to your own domain name, no domain name change to 127.0.0.1:80 charset utf-8; location / { include uwsgi_params; uwsgi_pass 127.0.0.1:8808; # The port should be the same as that configured in uwsgi uwsgi_param UWSGI_SCRIPT wsgi.py Directory name.wsgi; #Directory name of wsgi.py +. WSGI uwsgi_param UWSGI_CHDIR /home/project/Project path/; # Project path } # New configuration static file location /static { alias /home/project/Project path/wsgi.py Directory name/static; } } server { listen 80; server_name 127.0.0.1; # Change to your own domain name, no domain name change to 127.0.0.1:80 charset utf-8; location / { root /home/html; # html access path index index.html; # html file name try_files $uri $uri/ /index.html; # Solve 404 problem of single page application refresh } } } //Save exit
XVI. Start service
pkill -f uwsgi -9 uwsgi -x /home/project/Project path/luffyapi.xml nginx
If there are changes, you need to restart the service to take effect