赞
踩
下载地址: http://nginx.org/en/download.html
本次下载版本为1.18.0
下载地址: https://sourceforge.net/projects/pcre/files/
可能的报错内容:
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre= option.
下载地址: https://www.openssl.org/source/
sudo tar zxvf nginx-1.18.0.tar.gz
...
cd nginx-1.18.0/
sudo ./configure --with-pcre=../pcre-8.45/
sudo make
sudo make install
vim ~/.zshrc
export PATH="/usr/local/nginx/sbin:$PATH"
source ~/.zshrc
cd /usr/local
sudo ./nginx
访问 localhost,安装成功
npm run build
打开nginx目录
cd /usr/local/nginx/conf
打开 nginx.conf 文件,添加服务器
root: 将接收到的资源根据/usr/local/nginx/html/dist文件夹去查找资源
index: 默认去上述路径中找到index.html或者index.htm
server {
listen 5050;
server_name localhost;
location / {
root /usr/local/nginx/html/dist;
index index.html index.htm;
# proxy_pass http://localhost:18080;
}
}
将dist目录上传到上面的指定路径,并启动nginx服务
cd /usr/local/nginx/sbin
sudo ./nginx
浏览器访问服务器地址 http://localhost:5050
nginx部署后不存在跨域问题
#nginx.conf ... http { server { listen 8082; //监听的端口 server_name localhost; location / { // 表示 以'/'开头的请求怎样处理 root html; //指定root文件夹为 上面提到的html文件夹 index index.html; //返回index.html } location /bpi{ // 表示 以'/bpi'开头的请求 怎样处理 proxy_pass http://localhost:8081; //以同样的蚕食向这个地址请求,并返回给客户端 } error_page 404 /index.html; //404的时候就返回index.html } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。