银河麒麟系统+飞腾CPU部署nginx(运⾏vue项⽬)
⽬录
部署nginx
前⾔
写在前⾯:
由于我的系统root⽤户⽆法登录,所以下⾯的命令我都⽤sudo执⾏的,如果你的系统可以登录root,记得⼀定要⽤root⽤户进⾏操作哦,还要记得把下⾯命令前⾯的sudo删掉;(不⽤root⽤户真的会碰到好多问题)
切换root⽤户命令:su root
之后输⼊密码就好;
我部署nginx主要为了运⾏基于vue框架的前端项⽬,这⾥只是做个记录,希望能帮到有需要的你们;
注意:如复制命令,请先注意⼀下我遇到的问题,因为我是边写边运⾏的,有些问题可能你们遇不到哦,
因为我不是⽤root⽤户操作的;正⽂
输⼊命令下载组件(在⾃⼰喜欢的⽬录,我⽤的⽬录是/usr/local/nginx):
注:这⾥最好别跟我⼀样,因为忘记了nginx安装正好是安装在这个⽬录下的,所以把这些安装包安到这⾥后⾯⼀看会很乱(不影响使⽤,这⾥我以后也会改的,这次弄的⽐较急,抱歉哦⼤家)
--下载组件
sudo wget /download/nginx-1.10.
sudo wget /source/openssl-fips-2.0.
sudo wget zlib/zlib-1.2.
sudo wget netix.dl.sourceforge/project/pcre/pcre/8.40/pcre-8.
--解压组件
sudo tar -zxvf nginx-1.10.
sudo tar -zxvf openssl-fips-2.0.
sudo tar -zxvf pcre-8.
sudo tar -zxvf zlib-1.2.
--安装组件
cd openssl-fips-2.0.10/
sudo ./config && make && make install
cd ../pcre-8.40/
//sudo ./configure && make && make install 我⽤这段命令执⾏后报如下错误
//Makefile:2970: recipe for target 'install' failed
//make: *** [install] Error 2
sudo apt install libpcre3-dev //这⾥是由于我⽤上⾯的命令报错,改⽤这个命令后安装成功
pcre-config --version //之后⽤如下命令检查是否安装成功
cd ../nginx-1.10.2/
//
//sudo ./configure && make && make install 我⽤这段命令报如下错误:
/*致命错误:can't create objs/src/core/nginx.o: 权限不够
objs/Makefile:353: recipe for target 'objs/src/core/nginx.o' failed
make[1]: *** [objs/src/core/nginx.o] Error 2
make[1]: Leaving directory '/usr/local/nginx/nginx-1.10.2'
Makefile:8: recipe for target 'build' failed
make: *** [build] Error 2*/
//之后我⼀⾏⼀⾏执⾏,提⽰安装成功
sudo ./configure;
sudo make;
sudo make install;
//但是启动nginx的时候⼜报如下错误
/*
nginx: [alert] could not open error log file: open() "/usr/local/nginx/logs/error.log" failed (13: Permission denied) 2021/06/04 16:39:02 [emerg] 17309#0: mkdir() "/usr/local/nginx/client_body_temp" failed (13: Permission denied) */
//经过检查原因是我⽤的不是root⽤户,对这个⽂件夹没有权限,所以我⼜给这个⽂件夹附了权限,命令如下
sudo chown -R kylin nginx///如果你想附给某个⽤户,把kylin换成对应⽤户名就好
//之后启动nginx
cd /usr/local/nginx/sbin;
sudo ./nginx;
//停⽌nginx
/usr/local/nginx/sbin/nginx -s stop
nginx基本命令:
/usr/local/nginx/sbin/nginx#启动
/usr/local/nginx/sbin/nginx -s stop(quit、reload)#停⽌/重启
/usr/local/nginx/sbin/nginx -h#命令帮助
vi /usr/local/nginx/f#配置⽂件
修改nginx配置⽂件;
vi /usr/local/nginx/f
我的配置⽂件内容如下(我的vue项⽬路径为:/data/dist):
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include pes;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 8081;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
# index index.html index.htm;
location /{
try_files $uri $uri//index.html;
root /data/dist;
index index.html index.htm;
}
#error_page 404/404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500502503504/50x.html;
location =/50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass 127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME/scripts$fastcgi_script_name; # include fastcgi_params;
#}
# deny access to .htaccess files,if Apache's document root
# concurs with nginx's one
#
#location ~/\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration #
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location /{
# root html;
# index index.html index.htm;
nginx部署前端项目# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location /{
# root html;
# index index.html index.htm;
# }
#}
}
之后启动nginx;
运⾏后端程序(java -jar **.jar);
打开浏览器输⼊url(localhost:8081/#/main);
页⾯显⽰正常,部署成功
附⾔
后端框架:springboot
前端框架:vue
全为最基础的框架,只是链接达梦数据库,在页⾯上显⽰出数据库内信息;想查看框架搭建内容可以点下⾯链接进⼊哦:
如果有要源码的可以私信我,⼀起交流。(持续更新中)
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论