CentOS-7 搭建 Vue-element-admin
1、克隆項目
# 進入項目部署目錄
cd /var/www/
# 下載項目
git clone https://github.com/PanJiaChen/vue-element-admin.git
.
├── babel.config.js
├── build
├── jest.config.js
├── jsconfig.json
├── LICENSE
├── mock
├── package.json
├── plopfile.js
├── plop-templates
├── postcss.config.js
├── public
├── README.es.md
├── README.ja.md
├── README.md
├── README.zh-CN.md
├── src
├── tests
└── vue.config.js
2、進入項目目錄
cd vue-element-admin
3、安裝依賴
# 更換 npm 源
npm config set registry https://registry.npm.taobao.org/
npm set sass_binary_site https://npm.taobao.org/mirrors/node-sass
# 更新依賴
npm install --unsafe-perm
也可以臨時使用taobao源安裝
#
npm install --registry=https://registry.npm.taobao.org --unsafe-perm
#
sudo npm i node-sass --sass_binary_site=https://npm.taobao.org/mirrors/node-sass --unsafe-perm
4、本地開發 啓動項目
npm run dev
> [email protected] dev /var/www/vue-element-admin
> vue-cli-service serve
INFO Starting development server...
10% building 2/2 modules 0 activeℹ 「wds」: Project is running at http://localhost:9527/
ℹ 「wds」: webpack output is served from /
ℹ 「wds」: Content not from webpack is served from /var/www/vue-element-admin/public
ℹ 「wds」: 404s will fallback to /index.html
98% after emitting CopyPlugin
DONE Compiled successfully in 69864ms 上午10:36:10
App running at:
- Local: http://localhost:9527/
- Network: http://172.20.10.6:9527/
Note that the development build is not optimized.
To create a production build, run npm run build.
配置防火牆
# 查看防火牆【服務】狀態
systemctl status firewalld
# 查看防火牆【運行】狀態
firewall-cmd --state
# 開啓
service firewalld start
# 重啓
service firewalld restart
# 臨時關閉
service firewalld stop
# 永久關閉
systemctl disable firewalld.service
# 查詢端口是否開放
firewall-cmd --query-port=8080/tcp
# 開放9527端口
firewall-cmd --permanent --add-port=9527/tcp
firewall-cmd --permanent --add-port=8080-8085/tcp
# 移除端口
firewall-cmd --permanent --remove-port=8080/tcp
# 查看防火牆的開放的端口
firewall-cmd --permanent --list-ports
# 重啓防火牆(修改配置後要重啓防火牆)
firewall-cmd --reload
配置 SELinux
# 臨時關閉 SELinux
setenforce 0
# 臨時打開 SELinux
setenforce 1
# 查看 SELinux 狀態
getenforce
# 開機關閉 SELinux
# 編輯 /etc/selinux/config 文件,將 SELinux 的值設置爲 disabled。
vi /etc/selinux/config
SELINUX=disabled