步骤如下:
1、购买阿里云服务器,系统选择的是centos7;
2、安装nginx:
2.1、安装nginx所需要的环境,执行如下命令:
yum -y install gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel
2.2、进入usr下的/usr/local目录
cd /usr/local
#在local目录下创建 nginx文件夹
mkdir nginx
#进入nginx目录
cd nginx
2.3、在nginx文件夹中下载nginx,通过wget:
wget https://nginx.org/download/nginx-1.21.6.tar.gz
2.4、解压下载的nginx文件 tar xvf nginx-1.21.6.tar.gz 然后进入解压后的目录 cd nginx-1.21.6
2.5、配置(带有https模块)【需要进入解压后的目录】
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
2.6、编译和安装
编译:make; 安装:make install
2.7、启动、关闭 nginx 服务
启动:cd /usr/local/nginx/sbin ./nginx
启动使用公网域名后访问阿里云官网即可验证是否安装成功
关闭:cd /usr/local/nginx/sbin ./nginx -s stop
3、将vue项目进行打包:npm run build
4、将nginx.conf配置文件进行修改,
vim /usr/local/nginx/conf/nginx.conf
将配置文件的server_name改成公网ip即可。
5、将打包好的dist下面的几个文件使用xshell进行传输到nginx的html文件夹下即可。