标签:param 编译安装 one esc https nginx安装 服务器 err ase
1.安装编译工具及库文件
# yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel pcre-devel
gcc、gcc-c++ # 主要用来进行编译相关使用
openssl、openssl-devel # 一般当配置https服务的时候就需要这个了
zlib、zlib-devel # 主要用于文件的解压缩
pcre、pcre-devel # Nginx的rewrite模块和HTTP核心模块会用到PCRE正则表达式语法
make # 遍历
make install # 安装
2.创建nginx目录
1)进入/usr/local目录下
# cd /usr/local
2)创建nginx文件
# mkdir nginx
3.下载并解压nginx
1)进入nginx文件下
# cd /usr/local/nginx
2)下载nginx安装包
# wget https://nginx.org/download/nginx-1.18.0.tar.gz
3)解压
# tar -zxvf nginx-1.18.0.tar.gz
4.进入安装包目录
# cd /usr/local/nginx-1.18.0
5.编译安装nginx,默认安装到 /usr/local/nginx中
./configure
make && make install
6.进入到/usr/local/nginx/sbin目录,启动nginx
# ./nginx
7.查看启动的 nginx 进程
ps -ef|grep nginx
8、查看是否可以访问
# curl localhost:80
出现html脚本代表可以访问
9.对项目进行打包
1)在vscode中打开项目路径下的终端,输入npm run build
2)打包完成后,会在项目路径生产一个dist的文件,将dist文件重命名为dist-atp(命名可自定义)
3)将dist-atp文件上传到服务器的/usr/local/nginx/html路径下
10.配置nginx.conf
cd /usr/local/nginx/conf
vim nginx.conf
对红色部分的内容做修改
1 #user nobody; 2 #启动的进程数量 3 worker_processes 1; 4 5 #error_log logs/error.log; 6 #error_log logs/error.log notice; 7 #error_log logs/error.log info; 8 9 #pid logs/nginx.pid; 10 11 12 events { 13 #单个进程并发量 14 worker_connections 1024;#总并发量=单个进程并发量*启动的进程数量 15 } 16 17 18 http { 19 include mime.types; 20 default_type application/octet-stream; 21 22 #log_format main ‘$remote_addr - $remote_user [$time_local] "$request" ‘ 23 # ‘$status $body_bytes_sent "$http_referer" ‘ 24 # ‘"$http_user_agent" "$http_x_forwarded_for"‘; 25 26 #access_log logs/access.log main; 27 28 sendfile on; 29 #tcp_nopush on; 30 31 #keepalive_timeout 0; 32 keepalive_timeout 65;#连接服务器超时时长65s 33 34 #gzip on; 35 36 #虚拟主机配置 37 38 server {#一个虚拟主机配置,多个虚拟机就配置多个 39 listen 8888; 40 server_name 123.57.1.35; #域名解析 41 42 #charset koi8-r; 43 44 #access_log logs/host.access.log main; 45 46 location / {#配置默认访问页 47 # root html; 48 #try_files $uri $uri/ @router; 49 root /usr/local/nginx/html/dist-atp; 50 index index.html index.htm;#访问的首页 51 } 52 location ./ { 53 # 代理转发到后台服务接口,注意后面英文分号;不要少了 54 proxy_pass http://123.57.1.35:8090/jeecg-boot/swagger-ui.html; 55 } 56 57 location @router{ 58 rewrite ^.*/index.html last; 59 } 60 61 #error_page 404 /404.html; 62 63 # redirect server error pages to the static page /50x.html 64 # 65 error_page 500 502 503 504 /50x.html; 66 location = /50x.html { 67 root html; 68 } 69 70 # proxy the PHP scripts to Apache listening on 127.0.0.1:80 71 # 72 #location ~ \.php$ { 73 # proxy_pass http://127.0.0.1; 74 #} 75 76 # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 77 # 78 #location ~ \.php$ { 79 # root html; 80 # fastcgi_pass 127.0.0.1:9000; 81 # fastcgi_index index.php; 82 # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; 83 # include fastcgi_params; 84 #} 85 86 # deny access to .htaccess files, if Apache‘s document root 87 # concurs with nginx‘s one 88 # 89 #location ~ /\.ht { 90 # deny all; 91 #} 92 } 93 94 95 # another virtual host using mix of IP-, name-, and port-based configuration 96 # 97 #server { 98 # listen 8000; 99 # listen somename:8080; 100 # server_name somename alias another.alias; 101 102 # location / { 103 # root html; 104 # index index.html index.htm; 105 # } 106 #} 107 108 109 # HTTPS server 110 # 111 #server { 112 # listen 443 ssl; 113 # server_name localhost; 114 115 # ssl_certificate cert.pem; 116 # ssl_certificate_key cert.key; 117 118 # ssl_session_cache shared:SSL:1m; 119 # ssl_session_timeout 5m; 120 121 # ssl_ciphers HIGH:!aNULL:!MD5; 122 # ssl_prefer_server_ciphers on; 123 124 # location / { 125 # root html; 126 # index index.html index.htm; 127 # } 128 #} 129 130 }
保存文件
按esc
:wq
11.查看nginx.conf配置是否正确
/usr/local/nginx/sbin/nginx -t
12.重启nginx
# ./nginx -s reload
13.在浏览器输入域名:端口进行访问
附件内容如下:
启动,重启,停止nginx
cd /usr/local/nginx/sbin/
./nginx #启动
./nginx -s stop #停止
./nginx -s quit #退出
./nginx -s reload #重启 修改配置后重新加载生效<br><br>./nginx -s reopen :重新打开日志文件<br>
./nginx -s quit:此方式停止步骤是待nginx进程处理任务完毕进行停止。
./nginx -s stop:此方式相当于先查出nginx进程id再使用kill命令强制杀掉进程。
启动方法二
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
停止方法二
ps -ef|grep nginx #查询进程号
kill -QUIT 主进程号 #从容停止
kill -TERM 主进程号 #快速停止
kill -9 主进程号 #强制停止
注:访问外网ip(注意如果是阿里云服务器需要先配置安全组规则)
标签:param 编译安装 one esc https nginx安装 服务器 err ase
原文地址:https://www.cnblogs.com/wendy-0901/p/13376130.html