当前位置:网站首页>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 :

边栏推荐
- C language - how to define arrays
- Halcon 3D 深度图转换为3D图像
- Who is more fierce in network acceleration? New king reappeared in CDN field
- nRF52832自定义服务与特性
- [untitled]
- CCF noi2022 quota allocation scheme
- Automatic annotation of target detection based on lffd model to generate XML file
- XML参数架构,同一MTK SW版本兼容两套不同的音频参数
- Role and understanding of proc/cmdline
- Brief introduction to project development process
猜你喜欢

Heap classical problem

Filter的注解配置

How to split a row of data into multiple rows in Informix database

Simple introduction to key Wizard

Available RTMP and RTSP test addresses of the public network (updated in March, 2021)

Un mois de DDD hépatique.

Thesis reading_ Figure neural network gin

Halcon 3D 深度图转换为3D图像

yolov5

Introduction to sringmvc
随机推荐
Flutter monitors application lifecycle status
Rtmp/rtsp/hls public network real available test address
beginning一款非常优秀的emlog主题v3.1,支持Emlog Pro
[GPIO] 如何通过adb shell 修改/显示 GPIO 状态
数据库实验一:数据定义实验指导
A month's worth of DDD will help you master it
Leetcode dynamic programming
Golang idea configures the agent to improve the speed of packages downloaded by go get
Role and understanding of proc/cmdline
log4j 1. X upgrade to 2 Solution of X dependency incompatibility
The application could not be installed: INSTALL_ FAILED_ TEST_ ONLY
Special materials | household appliances, white electricity, kitchen electricity
Error the main class com xxx. yyy. Application
Research Report on market supply and demand and strategy of China's digital camera lens industry
Webrtc AEC process analysis
基于LFFD模型目标检测自动标注生成xml文件
MySQL master-slave, 6 minutes to master
March 22, 2021
nus_data_handler源码解读结构体等数据类型
China embolic coil market trend report, technical innovation and market forecast