阿里云机器配置环境 JDK1.8.0_171 + apache-tomcat-8.5.31 + Mysql 8.0.11 + NGINX + GIT (二),jdk1.8.0_171nginx
阿里云机器配置环境 JDK1.8.0_171 + apache-tomcat-8.5.31 + Mysql 8.0.11 + NGINX + GIT (二),jdk1.8.0_171nginx
第四部分: 安装NGINX,及部署VUE前端项目
[root@myname bin]# nginx -v
nginx version: nginx/1.12.2
参考链接:https://blog.csdn.net/wild46cat/article/details/78025042
1. 安装nginx yum install nginx
2. 为配置文件添加软连接 ln -s /etc/nginx/conf.d/default.conf nginx.conf
3. 把前端文件放在目录/usr/share/nginx/html/dist
4. 具体配置 nginx.conf
[root@myname nginx]# cat nginx.conf
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
#user nginx;
user root; //解决访问出现403的问题
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
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 /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
listen 8099 default_server; //前端访问的接口
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
#added by myname
root /usr/share/nginx/html/dist; //前端打包文件存放路径
index index.html;
#end added
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
# Settings for a TLS enabled server.
#
# server {
# listen 443 ssl http2 default_server;
# listen [::]:443 ssl http2 default_server;
# server_name _;
# root /usr/share/nginx/html;
#
# ssl_certificate "/etc/pki/nginx/server.crt";
# ssl_certificate_key "/etc/pki/nginx/private/server.key";
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 10m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
#
# # Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
#
# location / {
# }
#
# error_page 404 /404.html;
# location = /40x.html {
# }
#
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
# }
}
5. nginx -s reload
6. 访问http://your-server-ip:8099应该就能看到首页。
有可能存在关于跨域问题:
1. 后台:
public class ProcessInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o) throws Exception {
httpServletResponse.setHeader("Access-Control-Allow-Origin", "*");
httpServletResponse.setHeader("Access-Control-Allow-Headers", "Content-Type,Content-Length, Authorization, Accept,X_Requested_With,X-Requested-With");
httpServletResponse.setHeader("Access-Control-Allow-Credentials","true");
// httpServletResponse.setHeader("Content-type", "application/json"); //如果希望是JSON格式,取消注释
httpServletResponse.setHeader("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");
String method= httpServletRequest.getMethod();
if (method.equals("OPTIONS")){
httpServletResponse.setStatus(200);
return false;
}
System.out.println(method);
return true;
}
}
第五部分: git的安装
https://blog.csdn.net/u013256816/article/details/54743470
安装依赖的包
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker
下载git源码并解压
目前最新版本下载地址:https://github.com/git/git/releases/tag/v2.11.0
解压 tar zxvf git-2.11.0.tar.gz
cd git-2.11.0
编译安装
make prefix=/usr/local/git all
make prefix=/usr/local/git install
查看git
whereis git
git –version
配置环境变量
vim /etc/profile
加入export PATH=$PATH:/usr/local/git/bin
生效配置文件 source /etc/profile
配置git
1.设置用户名和email
[root@myname]# git config –global user.name “myname”
[root@myname]# git config –global user.email “youremail@domain.com”
此时$HOME目录下会新建一个.gitconfig文件
2.为github账号添加SSH keys
ssh-keygen -t ras -C “youremail@domain.com”
系统会提示key的保存位置(一般是~/.ssh目录)和指定口令,保持默认,连续三次即可
然后vim打开id_rsa.pub文件,粘贴到github账号管理的添加SSH KEY界面中
vim ~/.ssh/id_rsa.pub
然后将id_rsa.pub文件中的内容粘贴到gitub的“SSH and GPG keys”中。
可能遇到的问题:
1. Permissions 0644 for '/root/.ssh/id_rsa' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "/root/.ssh/id_rsa": bad permissions
Permission denied (publickey,password).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
解决方法:
chmod 0600 /root/.ssh/id_rsa
2. 查看连接的信息: ssh -vvv git@gitlab.yupaopao.cn
3. 如果在config文件中对同一个gitlab server设置了多个帐户,将会默认以第一个帐户信息去连接
git多帐户配置: https://www.jianshu.com/p/0ad3d88c51f4
评论暂时关闭