springboot dubbo(zookeeper) nginx前后端分离 linux服务器环境安装

2021/04/12 13:40
阅读数 278

一:软件准备

1. jdk-8u151-linux-x64.tar.gz 

2. zookeeper-3.3.6.tar.gz

3. nginx-1.9.12.tar.gz

资源整合下载:jdk-8u151+maven-3.3.9+nginx-1.9.12+zookeeper-3.3.6+tomcat-8.5.23+redis-2.6

https://download.csdn.net/download/ssyujay/10571972

二:jdk安装配置

1.进入Liunx系统

2.使用命令行,创建java安装目录

    进入目录cd /usr ,再创建java安装目录mkdir java

3.把jdk-8u151-linux-x64.tar.gz复制到java目录下

4.把jdk-8u151-linux-x64.tar.gz解压到当前目录

    tar -zxvf jdk-8u151-linux-x64.tar.gz 

5.配置java环境变量

    使用命令vi /etc/profile,

    再文件最后加上(因为后面会安装zookeeper,所以这块加上了zookeeper配置)

export JAVA_HOME=/usr/java/jdk1.8.0_151
export JRE_HOME=/usr/java/jdk1.8.0_151/jre
export ZOOKEEPER_HOME=/usr/local/zookeeper/zookeeper-3.3.6/
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin:$ZOOKEEPER_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/jt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
export JAVA_HOME JRE_HOME ZOOKEEPER_HOME PATH CLASSPATH

    使用命令source /etc/profile,配置生效

6.查看安装情况

    使用命令java -version

 

三:zookeeper安装配置

1.进入Liunx系统

2.使用命令行,创建zookeeper安装目录

    进入目录cd /usr/local ,再创建zookeeper安装目录mkdir zookeeper

3.把zookeeper-3.3.6.tar.gz复制到zookeeper目录下

4.把zookeeper-3.3.6.tar.gz解压到当前目录

    tar -zxvf zookeeper-3.3.6.tar.gz

5.进入zookeeper文件目录

    cd /usr/local/zookeeper/zookeeper-3.3.6

6.创建文件夹

    mkdir data,        mkdir logs

7.进入zookeeper文件配置目录

   cd /usr/local/zookeeper/zookeeper-3.3.6/conf

8.创建zoo.cfg配置文件

  touch zoo.cfg

  并写入


tickTime=2000
initLimit=10
syncLimit=5
dataDir=/usr/local/zookeeper/zookeeper-3.3.6/data
dataLogDir=/usr/local/zookeeper/zookeeper-3.3.6/logs
clientPort=2181

9.配置zookeeper环境变量,由于在安装jdk的时候已经安装配置,这步省略

10.进入启动目录

  /usr/local/zookeeper/zookeeper-3.3.6/bin

11.启动zookeeper

  ./zkServer.sh start

注:如果在启动时可能会出现“zookeeper_server.pid: No such file or directory”这种问题,参考

https://blog.csdn.net/u010457406/article/details/50972875

 

四:nginx安装配置

1.进入Liunx系统

2.使用命令行,创建nginx安装目录

    进入目录cd /usr/local ,再创建nginx安装目录mkdir nginx

3.把nginx-1.9.12.tar.gz复制到nginx目录下

4.把nginx-1.9.12.tar.gz解压到当前目录

    tar -zxvf nginx-1.9.12.tar.gz

5.进入nginx文件目录

    cd /usr/local/nginx/nginx-1.9.12

6.使用命令./configure,检查配置信息

    错误1:./configure: error: the HTTP rewrite module requires the PCRE library.

    使用安装命令     yum -y install pcre-devel

    错误2:./configure: error: the HTTP gzip module requires the zlib library.

    使用安装命令    yum -y install openssl openssl-devel

7.编码,使用编译命令make

8.安装,使用安装命令make install

9.编辑nginx.conf

    进入nginx配置目录 cd /usr/local/nginx/conf

    修改配置文件 vi nginx.conf


#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 {
    ssi on;
    ssi_silent_errors on;
    ssi_types text/shtml;

    include       mime.types;
    default_type  application/octet-stream;
    client_max_body_size     50m;
		client_header_timeout    1m;
		client_body_timeout      1m;
		proxy_connect_timeout     60s;
		proxy_read_timeout      1m;
		proxy_send_timeout      1m;

    #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       80;
        server_name  127.0.0.1;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
             root   /usr/local/tomcat/test/yui-ui;
            index  admin/view/index.html;
            
            location ~ .*\.(jpg|jpeg|gif|png|swf|htm|html|json|xml|svg|woff|ttf|eot|map|ico)$ {
		expires 10d;
	    }
	    location ~ .*\.(js|css)?$ {
		expires 1h;
	    }
	    location ~* \.(css|js|jpg|jpeg|gif|png|swf|htm|html|json|xml|svg|woff|ttf|eot|map|ico)$ {
		if (-f $request_filename) {
		    break;
		}
	    }
	    
	    proxy_set_header Host $http_host;
			proxy_set_header X-Real-IP $remote_addr;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			proxy_set_header X-Forwarded-Proto $scheme;
			proxy_set_header X-NginX-Proxy true;
	    
	    location ^~/sys {
		    	proxy_pass       http://127.0.0.1:8082;
	    }
	    location ^~/general {
		    	proxy_pass       http://127.0.0.1:8084;
	    }
	    location ^~/prod {
		    	proxy_pass       http://127.0.0.1:8086;
	    }
	    location ^~/weixin {
		        proxy_pass       http://127.0.0.1:8088;
	    }
	    location ^~/sched {
		        proxy_pass       http://127.0.0.1:8090;
	    }
	    location ^~/online {
		    	proxy_pass       http://127.0.0.1:8092;
	    }
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

		
		
    }


}

10.进入启动目录

    cd /usr/local/nginx/sbin
11.启动服务
    ./nginx

12.创建测试文件夹

    cd /usr/local

    mkdir tomcat            mkdir test            mkdir yui-ui           mkdir  admin            mkdir  view            touch index.html

13.浏览器打开

 

展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部