html5网站正在建设中,义乌市场官方网站,软件下载的网站,wordpress主题原理1. 前端打包
执行如下命令#xff0c;构建前端代码#xff0c;构建成功后会在目录dist下生成构建完成的文件#xff0c;将dist整个文件夹拷贝到服务器中 npm install npm run build dev
2.nginx配置
进入nginx目录/usr/local/nginx/conf#xff0c;修改nginx.conf文件构建前端代码构建成功后会在目录dist下生成构建完成的文件将dist整个文件夹拷贝到服务器中 npm install npm run build dev
2.nginx配置
进入nginx目录/usr/local/nginx/conf修改nginx.conf文件将root参数路径指向你的构建文件
server {listen 80;server_name localhost;root /work/lsw-web-system/dist;index index.html index.htm; #处理vue-router路径Start#如果找不到路径则跳转到router变量中寻找,找到了就默认进入index.htmllocation / { try_files $uri $uri/ /index.html last;index index.html index.htm;}#处理访问时不能访问到接口的问题location /sdb_platform{#后端接口地址proxy_pass http://10.44.157.202:8080;add_header Content-Type text/plain;charsetutf-8;add_header Access-Control-Allow-Origin *;add_header Access-Control-Allow-Credentials true;add_header Access-Control-Allow-Methods GET, POST;}
}3.nginx 的安装
安装nginx作为web服务器
安装前需要安装PCRE库
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz
安装zlib库
wget http://zlib.net/zlib-1.2.11.tar.gz
安装openssl
wget https://www.openssl.org/source/openssl-1.0.1t.tar.gz 先解压之后切换到具体库目录下分别执行以下命令 注意openssl./config make make install ./configure make make install
正式开始安装nginx
wget http://nginx.org/download/nginx-1.1.10.tar.gz
tar -zxvf nginx-1.1.10.tar.gz
cd nginx-1.1.10
./configure --sbin-path/usr/local/nginx/nginx --conf-path/usr/local/nginx/nginx.conf --pid-path/usr/local/nginx/nginx.pid --with-http_ssl_module --with-pcre../pcre-8.42 --with-zlib../zlib-1.2.11 --with-openssl../openssl-1.1.1a --with-http_stub_status_module --usernginx --groupnginx如果只执行./configure会出现一个问题./nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory 用ldd $(which /usr/local/nginx/sbin/nginx) 进行查看 切换到/usr/lib 或者/usr/lib64 目录下建立软链接ln -s libpcre.so.0.0.1 libpcre.so.1 软连接建立以后启动nginx会成功
4.Nginx 常用命令
前提切换到nginx目录的sbin目录下可以执行以下命令 ./nginx #快速停止或关闭Nginx./nginx -s stop#正常停止或关闭Nginx./nginx -s quit#配置文件修改重装载命令./nginx -s reload将对象之间的相互依赖关系交给 IOC 容器来管理并由 IOC 容器完成对象的注入。