首页 > 代码库 > Linux服务器软件安装备忘

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 #add17 default-character-set = utf818 character-set-server = utf819 collation-server = utf8_general_ci20 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.gztar -zvxf xxxconfiguremake && 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               destination10 Chain OUTPUT (policy ACCEPT)11 target     prot opt source               destination12 如何开启/关闭指定端口13 例如:14 开启81端口:15 iptables -I INPUT -i eth0 -p tcp --dport 81 -j ACCEPT16 iptables  -I OUTPUT -o eth0 -p tcp --sport 81 -j ACCEPT17 关闭81端口:18 iptables -I INPUT -i eth0 -p tcp --dport 81 -j DROP19 iptables -I OUTPUT -o eth0 -p tcp --sport 81 -j DROP20 然后保存21 /etc/rc.d/init.d/iptables save22 你可以使用lsof命令来查看某一端口是否开放.查看端口可以这样来使用.23 我就以81端口为例:24 lsof -i:8125 如果有显示说明已经开放了.如果没有显示说明没有开放

5.环境变量

1 Tomcat JVM配置--catalina.bat/catalina.sh2 windows3 set JAVA_OPTS = -Xmx512m -Xms512m -XX:MaxPermSize=256m4 linux5 JAVA_OPTS ="-server -Xmx400m -Xms400m -Xmn128m -XX:MaxPermSize=128m -XX:PermSize=128m"

6.项目直接访问

1 【Tomcat直接访问项目--去掉访问路径上的项目名称】2 修改Tomcat_Home/conf/server.xml3 <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 }

 

Linux服务器软件安装备忘