blogSite

我是谁?我在哪儿?我在干什么?

View project on GitHub

阿里云Centos 7学习

利用yum源来安装jdk(此方法不需要配置环境变量)

  • 查看yum库中的java安装包 :> yum -y list java*
  • 安装需要的jdk版本的所有java程序:> yum -y install java-1.8.0-openjdk*
  • 查看java版本:> java -version
  • 安装完之后,默认的安装目录是在: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.151-1.b12.el7_4.x86_64

安装Tomcat 7

  • 安装Tomcat之前需要安装对应的JDK,查看版本~# java -version
  • 新建tomcat目录~# mkdir -p tomcat
  • 下载tomcat~/tomcat# wget https://www-eu.apache.org/dist/tomcat/tomcat-7/v7.0.94/bin/apache-tomcat-7.0.94.tar.gz(此处必须从官网下载Core下的链接处的文件,否则有可能文件不完整)
  • 解压tomcat~/tomcat# tar -zxvf apache-tomcat-7.0.94.tar.gz
  • 如果开始运行后JRE_HOME对应的目录不正确,修改文件中的JRE_HOME指向JDK的jre目录~/tomcat/apache-tomcat-7.0.94/bin# vi setclasspath.sh
          export JRE_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64/jre
    
  • 启动~/tomcat/apache-tomcat-7.0.94/bin# ./startup.sh
  • 解压完整后删除安装包> rm -rf apache-tomcat-7.0.94.tar.gz
  • 将Tomcat的端口号添加到阿里云的安全组策略中
  • 远程访问http://xx.xx.xx.xx:8080,测试是否成功
问题
  1. xx.xx.xx.xx 拒绝了我们的连接请求。
    • 可能是因为阿里云没有配置安全组策略,也可能是centos中没有相应的端口启动(用netstat -noa查看是否启动相应端口)

yum安装SVN

  • 执行安装命令[root@izlbxa6s5tlszn /]# yum install subversion
  • 查看svn版本[root@izlbxa6s5tlszn /]# svnserve --version
  • 建立版本库位置[root@izlbxa6s5tlszn /usr/local]# mkdir -p svnRepo,建子库/usr/local/svnRepo# mkdir -p currentProject
  • 创建版本库[root@izlbxa6s5tlszn /usr/local/svnRepo/currentProject]# svnadmin create /usr/local/svnRepo/currentProject
  • 配置用户密码[root@izlbxa6s5tlszn /usr/local/svnRepo/currentProject/conf]# vi passwd
          [users]
          # harry = harryssecret
          # sally = sallyssecret
          zz=123
    
  • 配置权限[root@izlbxa6s5tlszn /usr/local/svnRepo/currentProject/conf]# vi authz
          [groups]
          # harry_and_sally = harry,sally
          # harry_sally_and_joe = harry,sally,&joe
          coms=zz
    
          [/]
          @coms=rw
    
  • 修改配置文件[root@izlbxa6s5tlszn /usr/local/svnRepo/currentProject/conf]# vi svnserve.conf
          [general]
          # 匿名访问的权限,可以是read,write,none,默认为read
          anon-access = none
          # 使授权用户有写权限 
          auth-access = write
          # 密码数据库的路径 
          password-db = passwd
          # 访问控制文件 
          authz-db = authz
          # 认证命名空间,subversion会在认证提示里显示,并且作为凭证缓存的关键字 
          realm = /usr/local/svnRepo/currentProject
    
  • 启动svn[root@izlbxa6s5tlszn /]# svnserve -d -r /usr/local/svnRepo/currentProject
  • 停止svn[root@izlbxa6s5tlszn /]# killall svnserve
  • 检测SVN 端口[root@izlbxa6s5tlszn /]# netstat -ln |grep 3690
  • 更换SVN 端口[root@izlbxa6s5tlszn /]# svnserve -d -r /usr/local/svnRepo/currentProject --listen-port 3391
  • ps:默认端口3690

安装nginx

  • 安装依赖库
          yum -y install gcc-c++
          yum -y install pcre pcre-devel
          yum -y install zlib zlib-devel
          yum -y install openssl openssl-devel libssl-dev
    
  • 下载nginx
          wget http://nginx.org/download/nginx-1.15.12.tar.gz
    
  • 解压下载包
          tar -zxvf nginx-1.15.12.tar.gz
    
  • 启动nginx
          ./configure
    
  • 编译安装
          make
          make install
    
    • 查找安装路径whereis nginx
  • 启动和停止nginx
          cd /usr/local/nginx/sbin/
          ./nginx 
          ./nginx -s stop
          ./nginx -s quit
          ./nginx -s reload
    
    • ./nginx -s quit:此方式停止步骤是待nginx进程处理任务完毕进行停止。
    • ./nginx -s stop:此方式相当于先查出nginx进程id再使用kill命令强制杀掉进程。
  • 查询nginx进程
          ps aux|grep nginx
    
  • PS : nginx支持长连接(主要用于访问数据库)
    1. 进入安装文件解压位置执行命令 > ./configure --with-stream
    2. 在nginx.conf中增加stream配置
           stream {
               server {
                   listen 3306; #数据库服务器监听端口
                   proxy_connect_timeout 20s;
                   proxy_timeout 300s; # 设置客户端和代理服务器之间的超时时间,如果5分钟没操作将自动断开
                   proxy_pass z-f.synology.me:3306;
               }
           }
      
      Nginx常见问题
  • 启动nginx的nginx.pid错误
      nginx: [error] open() “/usr/local/nginx/logs/nginx.pid” failed (2: No such file or directory) 
      [root@izlbxa6s5tlszn sbin]# ./nginx -c /usr/local/nginx/conf/nginx.conf
    

参考文献

首页 > 学习总览 > OS笔记目录