zoukankan      html  css  js  c++  java
  • Linux服务器软件安装备忘

    1.Centos安装Mysql

     1 --安装
     2 yum install mysql-server   卸载 yum -e mysql-server
     3 --设置为开机启动
     4 chkconfig mysqld on
     5 --启动mysql
     6 service mysqld start
     7 --设置root密码
     8 mysqladmin -u root password 'xxx'
     9 #双机热备
    10 GRANT REPLICATION SLAVE ON *.* TO 'backup'@'192.168.1.33' IDENTIFIED BY 'backup_xxx';
    11 #一般账号
    12 --GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' IDENTIFIED BY 'password';
    13 flush privileges;
    14 乱码:
    15 [mysqld]
    16 #add
    17 default-character-set = utf8
    18 character-set-server = utf8
    19 collation-server = utf8_general_ci
    20 init_connect = 'SET collation_connection = utf_general_ci'
    21 init_connect = 'SET NAMES utf8'
    22 [mysqld_safe]

    2.安装Redis

    wget http://download.redis.io/releases/redis-2.8.7.tar.gz  or  http://download.redis.io/releases/redis-2.6.17.tar.gz
    tar -zvxf xxx
    configure
    make && make install  

    3.启动memcached

    memcached -d -m 100 -u root -p 11211 -P /tmp/memcached.pid

    4.防火墙:

     1 Iptables:
     2 启动iptables
     3 service iptables start
     4 iptables --list //*查看iptables规则集*//
     5 下面是没有定义规划时iptables的样子:
     6 Chain INPUT (policy ACCEPT)
     7 target     prot opt source               destination
     8 Chain FORWARD (policy ACCEPT)
     9 target     prot opt source               destination
    10 Chain OUTPUT (policy ACCEPT)
    11 target     prot opt source               destination
    12 如何开启/关闭指定端口
    13 例如:
    14 开启81端口:
    15 iptables -I INPUT -i eth0 -p tcp --dport 81 -j ACCEPT
    16 iptables  -I OUTPUT -o eth0 -p tcp --sport 81 -j ACCEPT
    17 关闭81端口:
    18 iptables -I INPUT -i eth0 -p tcp --dport 81 -j DROP
    19 iptables -I OUTPUT -o eth0 -p tcp --sport 81 -j DROP
    20 然后保存
    21 /etc/rc.d/init.d/iptables save
    22 你可以使用lsof命令来查看某一端口是否开放.查看端口可以这样来使用.
    23 我就以81端口为例:
    24 lsof -i:81
    25 如果有显示说明已经开放了.如果没有显示说明没有开放

    5.环境变量

    1 Tomcat JVM配置--catalina.bat/catalina.sh
    2 windows
    3 set JAVA_OPTS = -Xmx512m -Xms512m -XX:MaxPermSize=256m
    4 linux
    5 JAVA_OPTS ="-server -Xmx400m -Xms400m -Xmn128m -XX:MaxPermSize=128m -XX:PermSize=128m"

    6.项目直接访问

    1 【Tomcat直接访问项目--去掉访问路径上的项目名称】
    2 修改Tomcat_Home/conf/server.xml
    3 <Host> 下添加  <Context path="" docBase="项目路径" reloadable="true" />
    4 path为访问路径,与request.getContextPath()返回值一样。

    7.Nginx配置:

    安装 pcre-devel openssl-devel

     1 http{
     2  #...
     3  gzip on;
     4  gzip_min_length 1k;
     5  gzip_buffers 16 64k;
     6  gzip_http_version 1.1;
     7  gzip_comp_level 4;
     8  gzip_types text/plain text/css application/xml image/png; #...
     9  gzip_vary on;
    10  sendfile   on;
    11  client_max_body_size 1024m;#附件上传 
    12     upstream e_learning{
    13         server 192.168.1.30:8080;
    14         server 192.168.1.31:8080;
    15         ip_hash;
    16     }
    17     server{
    18         listen      80;
    19         server_name 192.168.1.34;
    20         index       index.jsp;
    21         location / {
    22             index   index.jsp;
    23             proxy_pass  http://e_learning;
    24             proxy_set_header    Host    $host;
    25             proxy_set_header    X-Real_IP   $remote_addr;
    26             proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
    27         }
    28         location ^~ /upload/ {
    29             expires 10d;
    30             root    /var/e_learning;
    31         }
    32         location ^~ /vod {
    33             proxy_pass http://192.168.1.36:1935/vod/;
    34             proxy_set_header    Host    $host;
    35             proxy_set_header    X-Real_IP   $remote_addr;
    36             proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
    37         }
    38         location ~*.(gif|jpg|png|js|css)$ {
    39             expires 10d;
    40             proxy_pass  http://e_learning;
    41             proxy_set_header    Host    $host;
    42             proxy_set_header    X-Real_IP   $remote_addr;
    43             proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
    44         }
    45     }
    46 }
  • 相关阅读:
    sqlite3 增删改查
    Charles 修改接口返回值
    矫正Django 时间不正确
    unittest 使用 HTMLTestRunner 生成测试报告
    unittest 使用例子
    pyppeteer
    linux源码编译-安装timescaledb数据库(中标麒麟+龙芯CPU) (转载)
    不会用java api对kafka topic进行创建、查询和删除,你也太out了(建议收藏)(转载)
    django 学习(转载)
    Docker 启动镜像(转载)
  • 原文地址:https://www.cnblogs.com/libaoting/p/4106412.html
Copyright © 2011-2022 走看看