利用宝塔安装一套linux开发环境

  1. 更新yum,并且更换阿里镜像源
删除yum文件
cd /etc/yum.repos.d/    进入yum核心目录
ls
sun.repo
rm -rf *    删除之前配置的本地源
ls
配置阿里镜像源
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
配置扩展包
wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
yum clean all
yum makecache
  1. 安装jdk8
检索jdk列表
yum list | grep jdk
选择合适的安装
yum install java-1.8.0-openjdk-devel.x86_64
验证
java -version
  1. 安装宝塔(centos安装脚本)
yum install -y wget && wget -O install.sh https://download.bt.cn/install/install_6.0.sh && sh install.sh ed8484bec
  1. 使用宝塔安装mysql、redis、kafka、nacos、nginx
    mysql、redis、kafka、nacos统统不开放外网访问
  2. 配置nginx转发mysql、redis、kafka、nacos
    这里的mysql、redis、kafkanacos有所不同
    mysql等服务是tcp协议,而nacos是使用的http协议
user  www www;
worker_processes auto;
error_log  /www/wwwlogs/nginx_error.log  crit;
pid        /www/server/nginx/logs/nginx.pid;
worker_rlimit_nofile 51200;


stream {
    upstream mysqlProxy {
       hash $remote_addr consistent;
       server 127.0.0.1:3306 weight=5 max_fails=3 fail_timeout=30s;
    }
    upstream redisProxy {
       hash $remote_addr consistent;
       server 127.0.0.1:6379 weight=5 max_fails=3 fail_timeout=30s;
    }
    upstream kafkaProxy {
       hash $remote_addr consistent;
       server 127.0.0.1:9092 weight=5 max_fails=3 fail_timeout=30s;
    }
    server {
       listen 11009;
       proxy_connect_timeout 10s;
       proxy_timeout 300s;
       proxy_pass redisProxy;
    }
    server {
       listen 11008;
       proxy_connect_timeout 10s;
       proxy_timeout 300s;
       proxy_pass mysqlProxy;
    }
    server {
       listen 11007;
       proxy_connect_timeout 10s;
       proxy_timeout 300s;
       proxy_pass kafkaProxy;
    }
  	
    log_format tcp_format '$time_local|$remote_addr|$protocol|$status|$bytes_sent|$bytes_received|$session_time|$upstream_addr|$upstream_bytes_sent|$upstream_bytes_received|$upstream_connect_time';
  
    access_log /www/wwwlogs/tcp-access.log tcp_format;
    error_log /www/wwwlogs/tcp-error.log;
    include /www/server/panel/vhost/nginx/tcp/*.conf;
}

events
    {
        use epoll;
        worker_connections 51200;
        multi_accept on;
    }

http
    {
    include       mime.types;
		include proxy.conf;
        lua_package_path "/www/server/nginx/lib/lua/?.lua;;";

        default_type  application/octet-stream;

        server_names_hash_bucket_size 512;
        client_header_buffer_size 32k;
        large_client_header_buffers 4 32k;
        client_max_body_size 50m;

        sendfile   on;
        tcp_nopush on;

        keepalive_timeout 60;

        tcp_nodelay on;

        fastcgi_connect_timeout 300;
        fastcgi_send_timeout 300;
        fastcgi_read_timeout 300;
        fastcgi_buffer_size 64k;
        fastcgi_buffers 4 64k;
        fastcgi_busy_buffers_size 128k;
        fastcgi_temp_file_write_size 256k;
		fastcgi_intercept_errors on;

        gzip on;
        gzip_min_length  1k;
        gzip_buffers     4 16k;
        gzip_http_version 1.1;
        gzip_comp_level 2;
        gzip_types     text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/json image/jpeg image/gif image/png font/ttf font/otf image/svg+xml application/xml+rss text/x-js;
        gzip_vary on;
        gzip_proxied   expired no-cache no-store private auth;
        gzip_disable   "MSIE [1-6]\.";

        limit_conn_zone $binary_remote_addr zone=perip:10m;
		limit_conn_zone $server_name zone=perserver:10m;

        server_tokens off;
        access_log off;
  server 
    {						
        listen       11005;		
        # server_name  www.test001.com;		
        
	    	location / {	
		      	proxy_pass http://127.0.0.1:8848/nacos/;
        }
    }
    
  server 
    {
        listen       80;
        # 这里可以指定每一个块会被那个服务器处理
        # server_name  127.0.0.1;
        
        location / {
            root   html;
            index  index.html index.htm;
        }
        
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
    
include /www/server/panel/vhost/nginx/*.conf;
}
  1. 调整kafka配置
    这样配置是可以将kafka转发到nginx的11007端口
    但是在消费的时候会提示连接断开或者无法获取连接
    修改kafka配置文件
    listeners配置kafka服务的地址
    advertised.listeners配置nginx转发的地址
listeners=PLAINTEXT://127.0.0.1:9092
# 外部代理地址                                
advertised.listeners=PLAINTEXT://127.0.0.1:11007
  1. 编写生产者和消费者测试
    在这里插入图片描述

补充:有条件的可以把nginx放在公网即可,并且可以利用nginx限制ip

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

YonChao

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值