Open TemplarJQ opened 5 years ago
先开放数据库远程连接
grant all privileges on *.* to root@'%' identified by 'root'; # 所有权限给知道root密码的人
flush privileges;
安装java环境直接采用
chmod -R 777 XXX.rpm
rpm -ivh XXX.rpm
新建gethost.js
var g_host = "localhost:8090";
引入对应的js文件
<script src="./gethost.js" type="text/javascript"></script>
替换原本localhost的地方
url: "http://"+g_host+"/item/create",
chmod -R 777 openresty-1.13.6.2.tar.gz
tar -zxvf openresty-1.13.6.2.tar.gz
./configure # 进行编译
会报错,产生错误
./configure: error: the HTTP rewrite module requires the PCRE library.
应该按照官网指示安装新的依赖关系:官网
apt-get install libpcre3-dev \
libssl-dev perl make build-essential curl
目录结构
root@iZuf6ivhkgilwhtmycw9niZ://usr/local/openresty# ll
total 276
drwxr-xr-x 8 root root 4096 Jul 17 10:42 ./
drwxr-xr-x 12 root root 4096 Jul 17 10:42 ../
drwxr-xr-x 2 root root 4096 Jul 17 10:42 bin/
-rw-r--r-- 1 root root 22924 Jul 17 10:42 COPYRIGHT
drwxr-xr-x 6 root root 4096 Jul 17 10:42 luajit/
drwxr-xr-x 6 root root 4096 Jul 17 10:42 lualib/
drwxr-xr-x 6 root root 4096 Jul 17 10:42 nginx/
drwxr-xr-x 44 root root 4096 Jul 17 10:42 pod/
-rw-r--r-- 1 root root 224167 Jul 17 10:42 resty.index
drwxr-xr-x 5 root root 4096 Jul 17 10:42 site/
nginx的目录结构
root@iZuf6ivhkgilwhtmycw9niZ://usr/local/openresty/nginx# ll
total 24
drwxr-xr-x 6 root root 4096 Jul 17 10:42 ./
drwxr-xr-x 8 root root 4096 Jul 17 10:42 ../
drwxr-xr-x 2 root root 4096 Jul 17 10:42 conf/
drwxr-xr-x 2 root root 4096 Jul 17 10:42 html/
drwxr-xr-x 2 root root 4096 Jul 17 10:42 logs/
drwxr-xr-x 2 root root 4096 Jul 17 10:42 sbin/
这个里面的conf文件和nginx的原生是一样的,html文件夹放置html文件,sbin目录可以放置特殊的nginx,下载编译并结合,替换即可
具体命令
将本地的static文件下内容都上传到//usr/local/openresty/nginx/html文件夹下
scp -r * root@47.103.27.246://usr/local/openresty/nginx/html
首先修改规则实现动静分离,将所有文件copy到resources下面
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location /resources/ # 注意两边都有斜杠,是指命中之后进行操作{
alias /usr/local/openresty/nginx/html/resources/; # alias是替换的意思,这个斜杠也很重要!!
index index.html index.htm;
}
root@iZuf6ivhkgilwhtmycw9niZ://usr/local/openresty/nginx# ps -ef | grep nginx
root 17352 1 0 10:55 ? 00:00:00 nginx: master process sbin/nginx -c conf/nginx.conf
nobody 17655 17352 0 11:31 ? 00:00:00 nginx: worker process
root 17659 4492 0 11:31 pts/1 00:00:00 grep --color=auto nginx
root@iZuf6ivhkgilwhtmycw9niZ://usr/local/openresty/nginx# sbin/nginx -s reload
root@iZuf6ivhkgilwhtmycw9niZ://usr/local/openresty/nginx# ps -ef | grep nginx
root 17352 1 0 10:55 ? 00:00:00 nginx: master process sbin/nginx -c conf/nginx.conf
nobody 17661 17352 0 11:31 ? 00:00:00 nginx: worker process
root 17663 4492 0 11:31 pts/1 00:00:00 grep --color=auto nginx
对应的master进程没有变,但是对应的worker进程却发生了变化。
设置upstrem server
upstream backend_server {
server 172.19.228.205:8090 weight=1; # 注意用私有地址快一点
server ···
}
设置动态请求location为proxy pass路径
···
location / { # 其余都算作动态处理
proxy_pass http://backend_server;
proxy_set_header Host $http_host:$proxy_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
开启tomcat access log验证,只会损失一部分性能,但是用处很大,可以定位问题,并且观察消耗
# tomcat日志
server.tomcat.accesslog.enabled=true
server.tomcat.accesslog.directory=/var/www/java/seckillmall/tomcat
# 日志格式 h=ip地址,u=user,t=处理时长,r=请求第一行,s=状态码
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D
epoll多路复用,指的是socket
master worker进程模型
协程机制(非阻塞模型)
Nginx
简介
目的用途