当前位置:网站首页>Project and build Publishing
Project and build Publishing
2022-06-12 05:55:00 【Snow flies fast】
Front end project building
Why should front-end code be packaged
- Browsers can only recognize html、css、js Code , The browser can't recognize vue file
- Can't identify ES6
import exportCode , I can't tell CommonJS Mediumrequire module.export
modify vue.config.js Of publicPath Of / by .
module.exports = {
publicPath: '.'
}
Then the packaged project will dist Folder copy to Nginx Under the table of contents

When you are remote, you need to upload.conf in autoindex on; Comment out , Otherwise, the directory structure will be exposed
Automated Deployment
Back end Automated Deployment scripts
echo ' Start updating the server '
cd /root/admin/admin-immoc-node
echo ' Updating code ...'
git pull
echo ' Restarting service ...'
kill -9 `ps -ef|grep node|grep app.js|awk '{print $2}'`
node app.js & # &: Start in the background
echo ' Server started successfully '
Front end Automated Deployment scripts
echo ' Start updating the front end '
cd /root/admin/admin-immoc-vue
echo ' Updating code ...'
git pull
echo ' The front end starts to build ...'
npm i
npm run build:prod
echo ' The front end starts to be released ...'
rm -rf ~/upload/admin
mv dist ~/upload/admin
echo ' Front end started successfully '
Preliminary knowledge
Alibaba cloud ECS The server
Be careful :CentOS6 There are too many holes , Best use CentOS7 Above version ( If installed CentOS6 You can disable or replace the operating system )
# see Linux System version
lsb_release -a
establish ECS Server instance
- stay
more —— password / secret key —— Reset instance passwordRestart after changing the password in

- stay
more —— Network and security groups —— Security group configurationView inAll rules for intranet access directionView the corresponding open port

Use shell Just connect the tools

If you use ssh Command direct connection , Want to log in without secret :
ssh-keygen -t rsa
ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected]
# After you enter the password, the Number of key(s) added
# You can also modify hosts file , Direct login
vim /etc/hosts
xxx immoc # Add this content
ssh [email protected]
After connection , Do not operate for a period of time , Auto disconnect found , This avoids automatic disconnection :
vim /etc/ssh/sshd_config
# Modify the timeout interval and times , after :wq Save and exit
ClientAliveInterval 600
ClientAliveCountMax 3
service sshd restart
Node
install nvm, It will be downloaded to /root/.nvm
# install
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
# Set up nvm Automatic operation
echo "source ~/.nvm/nvm.sh" >> ~/.bashrc
source ~/.bashrc
install node
- Try to install
v12Under version node, Otherwise, it could go wrong
nvm install node
# View all installed version numbers
nvm ls-remote
# Install the specified version node, Here are the two versions I installed
nvm install v8.17.0
nvm install v11.15.0
nvm use v11.15.0
Nginx
Install dependent commands :
yum -y install pcre*
yum -y install openssl*
CentOS6 The following errors may be reported :
Report errors :
Loading mirror speeds from cached hostfile http://mirrors.cloud.aliyuncs.com/centos/6/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found" Try other mirrors .cd /etc/yum.repos.d vim CentOS-Base.repo # Put... In the file $releasever All changed 7 :%s/$releasever/7/g yum clean all && yum makecacheReport errors :
http://mirrors.cloud.aliyuncs.com/epel/6/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"cd /etc/yum.repos.d vim epel.repo # hold enabled=1 Change it to enabled=0 yum clean all && yum makecacheOf course, it can also be done directly , Find a source on the Internet and replace it ( The main reason is 2020 year 12 month 2 After number CentOS6 The update package is off the shelf )
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
After solving the error, execute the installation dependency command , Then download nginx:
tar command
-zYes gzip Attribute-xdecompression-vShow all processes-fUse file name , This parameter is the last one , Only the file name can be followed
cd ~
mkdir nginx
cd nginx
wget http://nginx.org/download/nginx-1.12.2.tar.gz
tar -zxvf nginx-1.12.2.tar.gz
Output make and gcc, Check that both are installed :
# If gcc No installation
yum -y install gcc gcc-c++
# If make No installation
yum -y install autoconf automake make
Perform configuration
# Use sh or ./ Executable files
./configure
# Compile the source code
make -j4
# install
make install
# Check nginx Is the installation successful , Whether the configuration file can be read
/usr/local/nginx/sbin/nginx -t
# Create soft link
ln -s /usr/local/nginx/sbin/nginx nginx
start-up nginx
# start-up nginx
nginx
# see nginx process
ps -ef|grep nginx
change nginx To configure
cd /usr/local/nginx/conf/
vim nginx.conf
# And then 80 Port to 9000
user root;
include /root/nginx/*.conf; # Above the last brace
# restart nginx service
nginx -s reload
modify /root/nginx/nginx.conf As follows , establish upload Catalog
- The production environment does not recommend
autoindex on;Turn on
server {
listen 80;
server_name localhost;
root /root/nginx/upload;
autoindex on;
add_header Cache-Control "no-cache, must-revalidate";
location / {
add_header Access-Control-Allow-Origin *;
}
}
Git
install Git
yum install -y git
# uninstall git
yum remove -y git
adopt yum install git, The version is older . You can install its dependencies first
mkdir imooc-ebook
cd imooc-ebook
# Installation dependency
yum install -y curl-devel expat-devel gettext-devel openssl-devel zlib-devel
yum install -y gcc perl-ExtUtils-MakeMaker
yum install -y tcl build-essential tk gettext
After installing the dependency, you can go through wget To install the latest Git
wget https://github.com/git/git/archive/v2.9.2.tar.gz
tar -zxvf v2.9.2.tar.gz
cd git-2.9.2
# compile
make prefix=/usr/local/git all
# install
make prefix=/usr/local/git install
At this time, it cannot be used directly Git Of , Need to create a soft link
cd /usr/bin
ln -s /usr/local/git/bin/git git
Password free login
ssh-keygen -t rsa -C '[email protected]'
# Put the secret key in SSH keys in
cat ~/.ssh/id_rsa.pub
git clone [email protected]:llwodexue/vue-node-mooc.git
MySQL
install
yum install -y mysql-server
CentOS 7 Will be submitted to the : There are no packages available mysql-server
# download mysql Of repo Source
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
# install nrm package , After that mysql repo Source
rpm -ivh mysql-community-release-el7-5.noarch.rpm
# Can be installed
yum install -y mysql-server
start-up mysql
# Check mysql state
service mysqld
service mysqld start
CentOS 7 Will be submitted to the :The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl
# start-up mysql service
systemctl start mysqld
# Check mysql state
systemctl status mysqld
I like this version mysql No initial password , If there is an initial password , You can use the following command to view
cat /var/log/mysqld.log |grep password
Sign in
mysql -u root -p
# mysql8.0 Version update password
alter user 'root'@'localhost' identified by 'root';
# mysql5.6 Version update password
UPDATE user SET Password = PASSWORD('root') WHERE user = 'root';
FLUSH PRIVILEGES;
Add... To the alicloud security group mysql Port number

After adding, you can't connect , It needs to be specific ip Have the ability of remote connection
use mysql;
# mysql8.0
create user 'root'@'%' identified with mysql_native_password by 'root';
grant all privileges on *.* to 'root'@'%';
flush privileges;
# mysql5.6
GRANT ALL PRIVILEGES ON *.* TO root@'%' IDENTIFIED BY 'root';
FLUSH PRIVILEGES;
Modify the back-end code , hold env Change it to prod
- Remember to give 8089 Add port to security group
let UPLOAD_PATH, UPLOAD_URL, OLD_UPLOAD_URL
let dbHost, dbUser, dbPwd
if (env === 'dev') {
UPLOAD_PATH = 'E:/upload/admin-upload-ebook'
UPLOAD_URL = 'http://127.0.0.1:8089/admin-upload-ebook'
OLD_UPLOAD_URL = 'http://127.0.0.1:8089/book/res/img'
dbHost = 'localhost'
dbUser = 'root'
dbPwd = 'root'
dbPort = 3008
} else {
UPLOAD_PATH = '/root/nginx/upload/admin-upload-ebook'
UPLOAD_URL = 'http://47.95.217.159:8089/admin-upload-ebook'
OLD_UPLOAD_URL = 'http://47.95.217.159:8089/book/res/img'
dbHost = '47.95.217.159'
dbUser = 'root'
dbPwd = 'root'
dbPort = 3006
}
The domain name is not here , After filing, you can analyze it , The final deployment effect is as follows :

边栏推荐
- Database Experiment 2: data update
- merge sort
- yolov5
- Divide a folder image into training set and test set
- Select gb28181, RTSP or RTMP for data push?
- Laravel8 authentication login
- nRF52832自定義服務與特性
- 网络加速谁更猛?CDN领域再现新王者
- Redis transaction
- Market trend report, technical innovation and market forecast of Chinese stump crusher
猜你喜欢

Thesis reading_ Figure neural network gin

March 22, 2021

POI, easyexcel framework use
![[gin] gin framework for golang web development](/img/15/68c4fd217555f940b3cd3d10fcd54f.jpg)
[gin] gin framework for golang web development

Select gb28181, RTSP or RTMP for data push?

Data integration framework seatunnel learning notes

Special materials | household appliances, white electricity, kitchen electricity

Quickly master makefile file writing
![[long time series prediction] the [4] autocorrelation mechanism of aotoformer code explanation](/img/12/27531fc791b3f49306385831309c5e.png)
[long time series prediction] the [4] autocorrelation mechanism of aotoformer code explanation

MySQL 主从,6 分钟带你掌握
随机推荐
[Yu Yue education] basic reference materials of accounting of Nanjing Normal University
Halcon 3D 1 Reading 3D data
The application could not be installed: INSTALL_ FAILED_ TEST_ ONLY
【长时间序列预测】Aotoformer 代码详解之[4]自相关机制
C WMI query remote Win32_ Operatingsystem class
Execute sh script to prompt "[[: not found" solution. The difference between Bash and sh
数据库实验一:数据定义实验指导
数据库实验三:数据查询
CCF noi2022 quota allocation scheme
[PowerShell] command line output and adding system environment variables
Liunx Foundation
XML parameter schema, the same MTK SW version is compatible with two different sets of audio parameters
MySQL 主从,6 分钟带你掌握
数据集成框架SeaTunnel学习笔记
[long time series prediction] the [4] autocorrelation mechanism of aotoformer code explanation
beginning一款非常优秀的emlog主题v3.1,支持Emlog Pro
Flutter monitors application lifecycle status
从传统网络IO 到 IO多路复用
Database Experiment 3: data query
C语言-数组的定义方式