精华内容
下载资源
问答
  • 1.上传下载yum install lrzszsz下载rz上传2....3.安装javarpm -ivh jdk-8u161-linux-x64.rpm4.安装mysqlyum install libaioyum -y remove mariadb-libs-5.5*rpm -ivh mysql-community-common-5.7.21...

    1.上传下载

    yum install lrzsz

    sz下载

    rz上传

    2.安装压缩命令

    yum install -y unzip zip;

    3.安装java

    rpm -ivh jdk-8u161-linux-x64.rpm

    4.安装mysql

    yum install libaio

    yum -y remove mariadb-libs-5.5*

    rpm -ivh mysql-community-common-5.7.21-1.el7.x86_64.rpm

    rpm -ivh mysql-community-libs-5.7.21-1.el7.x86_64.rpm

    rpm -ivh mysql-community-client-5.7.21-1.el7.x86_64.rpm

    启动配置mysql

    vi  /etc/my.cnf

    在[mysqld]下添加:

    skip-grant-tables=1

    service mysqld restart

    mysql -u root -p

    update user set host='%' where host='localhost';

    update user set authentication_string = password('xxx'), password_expired = 'N', password_last_changed = now() where user = 'root';

    再把上面的skip-grant-tables=1去掉,这样就可以密码登录了。

    mysql5.7默认分组字段必须在查询字段里,修改这个配置:

    mysql命令行,执行命令

    select @@sql_mode;

    这样就可以查出sql_mode的值,复制这个值,在my.cnf中添加配置项(把查询到的值删掉only_full_group_by这个选项,其他的都复制过去):

    sql_mode=STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION;

    再加一行,设置默认编码

    character-set-server=utf8

    设置innodb缓存,加快查询速度,其值按自己机器定:

    innodb_buffer_pool_size=256M

    5.安装nginx

    yum install gcc-c++

    yum install -y pcre pcre-devel

    yum install -y zlib zlib-devel

    yum install -y openssl openssl-devel

    下载并解压nginx-1.10.2,进入nginx-1.10.2目录

    chmod a+x ./configure

    ./configure

    make

    make install

    安装成功了,查找安装路径:

    whereis nginx

    cd /usr/local/nginx/sbin/

    启动: ./nginx

    退出:./nginx -s quit

    nginx的负载均衡:

    cd /usr/local/nginx/conf

    vi nginx.conf

    http{

    include /usr/local/nginx/conf.d/*.conf;

    }

    进入conf.d文件夹,编辑自己网站xx.conf,假如域名是www.xx.com,本地启动了两个端口8280 8281:

    upstream tomcats{

    server 127.0.0.1:8280;

    server 127.0.0.1:8281;

    }

    server {

    listen 80;

    server_name www.xx.com;

    index index.html;

    location / {

    #上面配置的服务器组

    proxy_pass http://tomcats;

    proxy_set_header Host $host;

    proxy_set_header X-Real-IP $remote_addr;

    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    proxy_connect_timeout90;

    proxy_send_timeout90;

    proxy_read_timeout90;

    client_max_body_size10m;

    client_body_buffer_size1m;

    proxy_buffer_size64k;

    proxy_buffers 32 32k;

    proxy_busy_buffers_size128k;

    proxy_temp_file_write_size1m;

    limit_conn perip 5;

    limit_conn perserver 20;

    limit_rate 100k;

    index index.html index.htm index.jsp;

    }

    }

    漏洞修复

    yum -y install wget

    评论:

    c03a9631116ca909d04eed710ec0ffd7.png

    提交

    展开全文
  • Ubuntu 16.04安装mysql Java nginx环境 替换ubuntu安装源的地址,将其替换成国内的阿里源。(vim /etc/apt/sources.list) # deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ ...

    替换ubuntu安装源的地址,将其替换成国内的阿里源。(vim    /etc/apt/sources.list)

    # deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted
    
    deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
    
    deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
    
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
    
    deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
    
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
    
    deb http://mirrors.aliyun.com/ubuntu/ xenial universe
    
    deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
    
    deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
    
    deb http://archive.canonical.com/ubuntu xenial partner
    
    deb-src http://archive.canonical.com/ubuntu xenial partner
    
    deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
    
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
    
    deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
    
    deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse

     

    • apt-get update  apt-get upgrade
    • 安装ssh服务   apt-get install openssh-server

    • 安装mysql服务  (apt-get install mysql-server)
    • 更改mysql配置,允许远程访问,将下图位置注释。(vim   /etc/mysql/mysql.conf.d/mysqld.cnf)

     

    • 进入mysql,选中mysql表,再输入下列语句。(1.use mysql )
    • GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY 123456' with GRANT OPTION;
    • flush privileges;
    • 重启 mysql   (/etc/init.d/mysql restart)
    • service mysql  restart
    • 安装java   (sudo apt-get install openjdk-8-jre-headless)
    • 安装 nginx ( sudo  apt-get install  nginx)
    展开全文
  • 关于Linux环境Nginx安装与调试以及PHP安装参考此文即可:http://blog.csdn.PHPlinux版本:64位CentOS 6.4Nginx版本:nginx1.8.0php版本:php5.5.28 &php5.4.44所谓多版本多版本PHP就是php5.4和5.5以及其他版本在...

    关于Linux环境Nginx安装与调试以及PHP安装参考此文即可:http://blog.csdn.PHP

    linux版本:64位CentOS 6.4

    Nginx版本:nginx1.8.0

    php版本:php5.5.28 & php5.4.44

    所谓多版本多版本PHP就是php5.4和5.5以及其他版本在同一台服务器。

    假如php5.5是主版本已经安装在/usr/local/php目录下,那么再安装其他版本的php再指定不同安装目录即可。

    安装第二个版本的PHP

    # wget http://cn2.php.net/get/php-5.4.44.tar.gz/from/this/mirror

    # tar zxvf php-5.4.44.tar.gz

    # cd php-5.4.44

    #./configure --prefix=/usr/local/php5.4.44 \

    --with-curl \

    --with-freetype-dir \

    --with-gd \

    --with-gettext \

    --with-iconv-dir \

    --with-kerberos \

    --with-libdir=lib64 \

    --with-libxml-dir \

    --with-mysql \

    --with-mysqli \

    --with-openssl \

    --with-pcre-regex \

    --with-pdo-mysql \

    --with-pdo-sqlite \

    --with-pear \

    --with-png-dir \

    --with-xmlrpc \

    --with-xsl \

    --with-zlib \

    --enable-fpm \

    --enable-bcmath \

    --enable-libxml \

    --enable-inline-optimization \

    --enable-gd-native-ttf \

    --enable-mbregex \

    --enable-mbstring \

    --enable-pcntl \

    --enable-shmop \

    --enable-soap \

    --enable-sockets \

    --enable-sysvsem \

    --enable-xml \

    --enable-zip

    # make &&  make install

    # cp -R ./sapi/fpm/php-fpm.conf /usr/local/php5.4.44/etc/php-fpm.conf

    # cp php.ini-development /usr/local/php5.4.44/lib/php.ini

    # cp -R ./sapi/fpm/php-fpm /etc/init.d/php-fpm5.4.44

    修改php-fpm.conf的侦听端口为9001,因为主版本5.5.28是侦听9000。

    ; Note: This value is mandatory.

    listen = 127.0.0.1:9001

    启动php-fpm

    #  /etc/init.d/php-fpm5.4.44

    php安装成功查看进程

    #ps aux|grep php

    这样就已经起好php-fpm了。

    配置Nginx

    增加一段新的端口8054的配置并指向到9001以及指定目录即可:

    server {

    listen       8054;

    server_name  localhost;

    location / {

    #root   html;

    root /usr/www5.4.44;

    index  index.html index.htm;

    }

    error_page   500 502 503 504  /50x.html;

    location = /50x.html {

    root   html;

    }

    location ~ \.php$ {

    root html;

    fastcgi_pass 127.0.0.1:9001;

    fastcgi_index index.php;

    include fastcgi_params;

    fastcgi_param SCRIPT_FILENAME /usr/www5.4.44$fastcgi_script_name;

    }

    }

    nginx的配置文件nginx.conf在

    # cd /usr/local/nginx/conf

    完整的nginx配置如图:

    #user nobody;

    worker_processes 4;

    #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 {

    include mime.types;

    default_type application/octet-stream;

    #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 localhost;

    #charset koi8-r;

    #access_log logs/host.access.log main;

    location / {

    #root html;

    root /usr/www;

    index index.html index.htm;

    }

    #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;

    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80

    #

    #location ~ \.php$ {

    # proxy_pass http://127.0.0.1;

    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

    #

    #location ~ \.php$ {

    # root html;

    # fastcgi_pass 127.0.0.1:9000;

    # fastcgi_index index.php;

    # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;

    # include fastcgi_params;

    #}

    location ~ \.php$ {

    root html;

    fastcgi_pass 127.0.0.1:9000;

    fastcgi_index index.php;

    include fastcgi_params;

    fastcgi_param SCRIPT_FILENAME /usr/www$fastcgi_script_name;

    }

    # deny access to .htaccess files, if Apache's document root

    # concurs with nginx's one

    #

    #location ~ /\.ht {

    # deny all;

    #}

    }

    server {

    listen 8054;

    server_name localhost;

    location / {

    #root html;

    root /usr/www5.4.44;

    index index.html index.htm;

    }

    error_page 500 502 503 504 /50x.html;

    location = /50x.html {

    root html;

    }

    location ~ \.php$ {

    root html;

    fastcgi_pass 127.0.0.1:9001;

    fastcgi_index index.php;

    include fastcgi_params;

    fastcgi_param SCRIPT_FILENAME /usr/www5.4.44$fastcgi_script_name;

    }

    }

    # another virtual host using mix of IP-, name-, and port-based configuration

    #

    #server {

    # listen 8000;

    # listen somename:8080;

    # server_name somename alias another.alias;

    # location / {

    # root html;

    # index index.html index.htm;

    # }

    #}

    # HTTPS server

    #

    #server {

    # listen 443 ssl;

    # server_name localhost;

    # ssl_certificate cert.pem;

    # ssl_certificate_key cert.key;

    # ssl_session_cache shared:SSL:1m;

    # ssl_session_timeout 5m;

    # ssl_ciphers HIGH:!aNULL:!MD5;

    # ssl_prefer_server_ciphers on;

    # location / {

    # root html;

    # index index.html index.htm;

    # }

    #}

    }

    重启nginx

    # /usr/local/nginx/sbin/nginx -s reload

    注意需要防火墙增加新端口的开启,不然无法访问:

    防火墙配置

    注意如果你希望在本地机器例如xp访问虚拟机的网页,如果是centos6需要修改防火墙启动80端口

    # cd /etc/sysconfig

    修改iptables文件,或者直接用vim编辑

    # vim /etc/sysconfig/iptables

    添加下面一行,打开防火墙80端口:

    -A INPUT -m state --state NEW -m tcp -p tcp --dport 8054 -j ACCEPT

    重启防火墙

    # /etc/init.d/iptables restart

    测试是否成功,查看phpinfo()

    本文由来源 21aspnet,由 system_mush 整理编辑,其版权均为 21aspnet 所有,文章内容系作者个人观点,不代表 Java架构师必看 对观点赞同或支持。如需转载,请注明文章来源。

    展开全文
  • java操作nginx

    2019-09-23 03:07:39
    一,判断程序的部署环境nginx还是windows /** * 判断操作系统是不是windows * * @return true:是win false:是Linux */ public static boolean judgeOs() { String os = System.getPrope...

    一,判断程序的部署环境是nginx还是windows

        /**
         * 判断操作系统是不是windows
         * 
         * @return true:是win false:是Linux
         */
        public static boolean judgeOs() {
            String os = System.getProperty("os.name").toLowerCase();
            if (os != null && os.startsWith("windows")) {
                return true;
            } else {
                return false;
            }
        }

     

    二,开启nginx

    (1)开启windows系统的ngin

        /**
         * 开启windows系统的nginx
         * @throws IOException
         */
        private static void startWinProc() throws IOException{
            String myExe = "cmd /c start nginx";
            String CONFPREFIXURL = System.getProperty("user.dir") + File.separator + "nginx" 
                    + File.separator + "windows";
    
            File dir = new File(CONFPREFIXURL);
            String[] str = new String[] {};
            // 执行命令
            Runtime.getRuntime().exec(myExe, str, dir);
        }

     

    (2)开启linux系统的nginx

        /**
         * 开启linux的nginx
         * @throws IOException
         */
        private static void startLinuxProc() throws IOException {
            System.out.println("开启进程:" + "nginx");
            String command1 = "/usr/local/nginx/sbin/nginx";
    
            String pro = executeCmd2(command1);
            System.out.println(pro);
        }

     

    (3)跨平台开启Nginx

        /**
         * 跨平台启动nginx
         * 
         * @throws IOException
         */
        private static void startProc() throws IOException {
            if (judgeOs()) {
                startWinProc();
            } else {
                startLinuxProc();
            }
        }

     

    三,关闭nginx

    (1)关闭windows系统的nginx

        
        /**
         *关闭windows系统的nginx 
         * @throws IOException
         */
        public static void  KillWin() throws IOException{
            executeCmd("taskkill /F /IM " + "nginx.exe");
        }

     

    (2)关闭linux系统的nginx

        /**
         * 关闭linux系统的nginx
         * @throws IOException
         */
        private static void killLinuxProc() throws IOException {
            String command = "pkill -9 nginx";
            executeCmd(command);
        }

     

    (3)nginx的跨平台关闭

        /**
         * 跨平台关闭nginx 
         * @throws IOException
         */
        public static void killProc() throws IOException {
            if(judgeOs()){
                KillWin();
            }else{
                killLinuxProc();
            }
        }

     

    四,获取项目所在的磁盘位置

            String CONFPREFIXURL = System.getProperty("user.dir");
            System.out.println(CONFPREFIXURL);

     

    五,获取项目所在主机ip

        /**
         * 获取项目部署环境的ip
    *
    @return */ public static String getIP() { String url = "";; try { for (Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces(); e.hasMoreElements(); ) { NetworkInterface item = e.nextElement(); for (InterfaceAddress address : item.getInterfaceAddresses()) { if (item.isLoopback() || !item.isUp()) { continue; } if (address.getAddress() instanceof Inet4Address) { Inet4Address inet4Address = (Inet4Address) address.getAddress(); url =inet4Address.getHostAddress(); } } } //url = InetAddress.getLocalHost().getHostAddress(); } catch (SocketException e) { throw new RuntimeException(e); } return url; }

    更多获取系统变量的方法:https://www.cnblogs.com/excellencesy/p/11278889.html

    六,完整工具类

    package com.googosoft.until;
    
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.net.Inet4Address;
    import java.net.InterfaceAddress;
    import java.net.NetworkInterface;
    import java.net.SocketException;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.util.ArrayList;
    import java.util.Enumeration;
    import java.util.List;
    
    public class NginxUtil {
    
        /**
         * 
         * @return 1:代理重启成功 2:进程未开启 3:进程关闭时出错 4:进程启动时出错
         */
        public static int reStartProc() {
    
            int flag = 0;
            if (findProcess()) {
                // 进程没开启
                try {
                    killProc();
                } catch (IOException e) {
                    e.printStackTrace();
                    System.err.println("nginx.exe" + "线程开启失败");
                } finally {
                    if (findProcess()) {
                        flag = 3;// 关闭失败
                    }
                }
    
                try {
                    startProc();
                } catch (IOException e) {
                    e.printStackTrace();
                } finally {
                    if (findProcess()) {
                        flag = 1;// 开启成功
                    } else {
                        flag = 4;// 启动失败
                    }
                }
    
            } else {
                // 进程未开启
                flag = 2;
            }
            return flag;
        }
    
        /**
         * 关闭nginx进程
         * 
         * @return 1:进程关闭成功 2:进程没有开启 3:进程关闭失败
         */
        public static int stop() {
            int flag = 0;
    
            if (findProcess()) {
                // 进程开启了
                try {
                    killProc();
                } catch (IOException e) {
                    e.printStackTrace();
                    System.err.println("nginx.exe" + "线程关闭失败");
                } finally {
                    if (!findProcess()) {
                        flag = 1;// 关闭成功
                    } else {
                        flag = 3;// 关闭失败
                    }
                }
            } else {
                // 进程没开启
                flag = 2;
            }
            return flag;
    
        }
    
        /**
         * 跨平台关闭nginx
         * 
         * @throws IOException
         */
        public static void killProc() throws IOException {
            if (judgeOs()) {
                KillWin();
            } else {
                killLinuxProc();
            }
        }
    
        /**
         * 关闭windows系统的nginx
         * 
         * @throws IOException
         */
        public static void KillWin() throws IOException {
            executeCmd("taskkill /F /IM " + "nginx.exe");
        }
    
        /**
         * @desc 执行cmd命令
         */
        public static String executeCmd(String command) throws IOException {
            Runtime runtime = Runtime.getRuntime();
            Process process = runtime.exec("cmd /c " + command);
            // Process process = runtime.exec( command);
            BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream(), "UTF-8"));
            String line = null;
            StringBuilder build = new StringBuilder();
            while ((line = br.readLine()) != null) {
                System.out.println(line);
                build.append(line);
            }
            return build.toString();
        }
    
        /**
         * @desc 执行cmd命令
         */
        public static String executeCmd2(String command) throws IOException {
            Runtime runtime = Runtime.getRuntime();
            Process process = runtime.exec(command);
            BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream(), "UTF-8"));
            String line = null;
            StringBuilder build = new StringBuilder();
            while ((line = br.readLine()) != null) {
                System.out.println(line);
                build.append(line);
            }
            return build.toString();
        }
    
        /**
         * @desc 判断进程是否开启
         */
        public static boolean findProcess() {
            String processName = "nginx.exe";
            BufferedReader bufferedReader = null;
            try {
                Process proc = Runtime.getRuntime().exec("tasklist -fi " + '"' + "imagename eq " + processName + '"');
                bufferedReader = new BufferedReader(new InputStreamReader(proc.getInputStream()));
                String line = null;
                while ((line = bufferedReader.readLine()) != null) {
                    if (line.contains(processName)) {
                        return true;
                    }
                }
                return false;
            } catch (Exception ex) {
                ex.printStackTrace();
                return false;
            } finally {
                if (bufferedReader != null) {
                    try {
                        bufferedReader.close();
                    } catch (Exception ex) {
                    }
                }
            }
        }
    
        /**
         * 关闭linux系统的nginx
         * 
         * @throws IOException
         */
        private static void killLinuxProc() throws IOException {
            String command = "pkill -9 nginx";
            executeCmd(command);
        }
    
        /**
         * 打印进程的状态
         * 
         * @param programName1
         */
        public static void logStatus() {
            boolean flag = findProcess();
            if (flag) {
                System.out.println();
                System.err.println("nginx.exe" + "进程状态:开启");
                System.out.println();
            } else {
                System.out.println();
                System.err.println("nginx.exe" + "进程状态:关闭");
                System.out.println();
            }
        }
    
        /**
         * 开启linux的nginx
         * @throws IOException
         */
        private static void startLinuxProc() throws IOException {
            System.out.println("开启进程:" + "nginx");
            String command1 = "/usr/local/nginx/sbin/nginx";
    
            String pro = executeCmd2(command1);
            System.out.println(pro);
        }
    
        /**
         * windows平台开启
         * 
         * @throws IOException
         *             1:开启成功 2:开启失败 3:已开启
         */
        public static int start() {
            int flag = 0;
    
            if (!findProcess()) {
                // 进程开启了
                try {
                    startProc();
                } catch (IOException e) {
                    e.printStackTrace();
                    System.err.println("nginx.exe" + "线程关闭失败");
                } finally {
                    if (findProcess()) {
                        flag = 1;// 开启成功
                    } else {
                        flag = 2;// 开启失败
                    }
                }
            } else {
                // 进程已经开启
                flag = 3;
            }
            return flag;
        }
    
        /**
         * 跨平台启动nginx
         * 
         * @throws IOException
         */
        private static void startProc() throws IOException {
            if (judgeOs()) {
                startWinProc();
            } else {
                startLinuxProc();
            }
        }
    
        /**
         * 开启windows系统的nginx
         * 
         * @throws IOException
         */
        private static void startWinProc() throws IOException {
            String myExe = "cmd /c start nginx";
            String CONFPREFIXURL = System.getProperty("user.dir") + File.separator + "nginx" + File.separator + "windows";
    
            File dir = new File(CONFPREFIXURL);
            String[] str = new String[] {};
            // 执行命令
            Runtime.getRuntime().exec(myExe, str, dir);
        }
    
        /**
         * 判断操作系统是不是windows
         * 
         * @return true:是win false:是Linux
         */
        public static boolean judgeOs() {
            String os = System.getProperty("os.name").toLowerCase();
            if (os != null && os.startsWith("windows")) {
                return true;
            } else {
                return false;
            }
        }
    
        /**
         * 获取项目部署环境的ip
         * 
         * @return
         */
        public static String getIP() {
            String url = "";
            ;
            try {
                for (Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces(); e.hasMoreElements();) {
                    NetworkInterface item = e.nextElement();
                    for (InterfaceAddress address : item.getInterfaceAddresses()) {
                        if (item.isLoopback() || !item.isUp()) {
                            continue;
                        }
                        if (address.getAddress() instanceof Inet4Address) {
                            Inet4Address inet4Address = (Inet4Address) address.getAddress();
                            url = inet4Address.getHostAddress();
                        }
                    }
                }
                // url = InetAddress.getLocalHost().getHostAddress();
            } catch (SocketException e) {
                throw new RuntimeException(e);
            }
            return url;
        }
    
        /**
         * 判断某个字符串是否是数字
         * 
         * @param str
         * @return
         */
        public static boolean isNumer(String str) {
            for (int i = 0; i < str.length(); i++) {
                if (!Character.isDigit(str.charAt(i))) {
                    return false;
                }
            }
            return true;
        }
    
        /**
         * 以行为单位读取文件,常用于读面向行的格式化文件
         * 
         * @return
         */
        public static int getPort() {
            String fileName = getConfAddr();
            int port = -1;
            File file = new File(fileName);
            BufferedReader reader = null;
            String lastLine = "";
            try {
                reader = new BufferedReader(new FileReader(file));
                String tempString = null;
                // 一次读入一行,直到读入null为文件结束
                while ((tempString = reader.readLine()) != null) {
                    if (!tempString.trim().startsWith("#") && tempString.trim().length() != 0) {
                        // System.out.println(tempString.trim());
                        if ("server {".equals(lastLine.trim())) {
                            String content = tempString.trim();
                            if (content.startsWith("listen") && content.endsWith(";")) {
                                String number = content.replace("listen", "").replace(";", "").trim();
                                if (isNumer(number))
                                    port = Integer.parseInt(number);
                            }
                        }
                        lastLine = tempString;
                    }
                }
                reader.close();
            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                if (reader != null) {
                    try {
                        reader.close();
                    } catch (IOException e1) {
                    }
                }
            }
    
            return port;
        }
    
        public static String getConfAddr() {
            String CONFPREFIXURL = System.getProperty("user.dir") + File.separator + "nginx" + File.separator;
            if (judgeOs()) {
                CONFPREFIXURL = CONFPREFIXURL + "windows" + File.separator + "conf" + File.separator + "nginx.conf";
            } else {
                // linux的处理
            }
            return CONFPREFIXURL;
        }
    
        public static void main(String[] args) {
    
        }
    
    }

     

    转载于:https://www.cnblogs.com/excellencesy/p/11278994.html

    展开全文
  • 监控Nginx监控Nginx搭建实验环境在zabbix_agent机器上安装nginx服务配置nginx的yum源 编辑yum仓库:vi /etc/yum.repos.d/nginx.repo粘贴:[nginx]name=nginx repobaseurl=http://nginx.org/packages/centos/7/$...
  • java源码部署总结:环境nginx+tomcat部署方式:源码部署1源码目录/chroot2/test/schedule 目录下面就是所有源码了2tomcat位置: /usr/local/tomcat/apache-tomcat-scheduleweb-test主要配置文件server.xml主要注意:...
  • 搭建Nginx+Java环境

    2020-06-28 07:40:16
    1.8.4 搭建Nginx+Java环境 Apache对Java的支持很灵活,它们的结合度也很高,例如Apache+Tomcat和Apache+resin等都可以实现对Java应用的支持。Apache一般采用一个内置模块来和Java应用服务器打交道。与Apache相比,...
  • <div><p>执行./vhost.sh选择java环境并且强制跳转https选择y,但是对应的nginx配置文件里并没有强制跳转https的代码,希望可以修复一下。</p><p>该提问来源于开源项目:oneinstack/oneinstack</p>...
  • 1、查看nginx安装目录 输入命令 ps -ef | grep nginx 1.在阿里云先给自己的域名申请一个(可以是免费证书)对应的https证书 2.下载证书 3.在服务器查看nginx的安装位置,然后在安装位置创建cert目录,上传证书的...
  • JAVA的安装 参考源网站:https://blog.csdn.net/qq_39295044/article/details/87282943@Lloyd-He 一、卸载服务器上老版本 java rpm -qa | grep jdk 如有老版本java 执行上述命令后会展示已安装的java各个版本 ...
  • 搭建nginx+java环境

    2016-12-15 10:57:55
    《高性能Linux服务器构建实战:运维监控、性能调优与集群应用》第1章轻量级HTTP服务器Nginx,本章主要介绍了对高性能HTTP服务器Nginx的安装、配置、管理和...本节为大家介绍搭建Nginx+Java环境。AD:1.8.4 搭建Ngi...
  • ubuntu 采坑记录一、前言二、安装 Java 环境三、MySQL 自行配置四、Nginx 配置五、防火墙配置 一、前言 眼看 11 月份自己的云服务器的一年期限要过期了。最近也没有特别的活动,就抓紧时间买了一年的学生机。装的是 ...
  • 搭建java 环境 安装nginx linux基础命令创建用户useradd $用户名 passwd $用户名查看Linux机器是32位还是64位uname -a; i686 or x86_64搭建java 环境 在usr目录下建立java安装目录 cd /usr mkdir java 将jdk-8u60-...
  • 搭建Nginx+JAVA环境

    2015-09-19 13:25:00
    搭建Nginx+JAVA环境Apache对Java的支持很灵活,他们的结合度也很高,例如Apache+Tomcat和Apache+resin等都可以实现对Java应用的支持。Apache一般采用一个内置模块来和Java应用服务器打交道。与Apache相比,Nginx在...
  • Nginx部署链接:[Linux服务器Java编程环境部署大纲指南](https://blog.csdn.net/LvJzzZ/article/details/106459712)一、安装方式及补充说明二、安装依赖三、下载并解压四、编译安装并检查版本五、启动Nginx六、...
  • C开发的IDE很多,为什么使用Eclipse?原因: 1. 历史原因:使用eclipse时间长,比较熟悉。... 安装gcc apt-get install build-essesials 安装JAVA apt-get install Oracle-jdk8-installer 下载eclipse wget ...
  • Nginx的产生 它的"同行"Apache吧Nginx同Apache一样都是一种WEB服务器基于REST架构风格以统一资源描述符(Uniform Resources Identifier)URI或者统一资源定位符(Uniform Resources Locator)URL作为沟通依据通过HTTP...
  • 运行 java 和 javac 命令测试 java 是否安装成功.       下载tomcat.   wget http://mirror.bjtu.edu.cn/apache/tomcat/tomcat-7/v7.0.22/bin/apache-tomcat-7.0.22.tar.gz   tar -...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 2,242
精华内容 896
关键字:

java环境nginx

java 订阅