1.Centos安装Mysql
--安装
yum install mysql-server 卸载 yum -e mysql-server
--设置为开机启动
chkconfig mysqld on
--启动mysql
service mysqld start
--设置root密码
mysqladmin -u root password 'xxx'
#双机热备
GRANT REPLICATION SLAVE ON *.* TO 'backup'@'192.168.1.33' IDENTIFIED BY 'backup_xxx';
#一般账号
--GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' IDENTIFIED BY 'password';
flush privileges;
乱码:
[mysqld]
#add
default-character-set = utf8
character-set-server = utf8
collation-server = utf8_general_ci
init_connect = 'SET collation_connection = utf_general_ci'
init_connect = 'SET NAMES utf8'
[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.防火墙:
Iptables:
启动iptables
service iptables start
iptables --list //*查看iptables规则集*//
下面是没有定义规划时iptables的样子:
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
如何开启/关闭指定端口
例如:
开启81端口:
iptables -I INPUT -i eth0 -p tcp --dport 81 -j ACCEPT
iptables -I OUTPUT -o eth0 -p tcp --sport 81 -j ACCEPT
关闭81端口:
iptables -I INPUT -i eth0 -p tcp --dport 81 -j DROP
iptables -I OUTPUT -o eth0 -p tcp --sport 81 -j DROP
然后保存
/etc/rc.d/init.d/iptables save
你可以使用lsof命令来查看某一端口是否开放.查看端口可以这样来使用.
我就以81端口为例:
lsof -i:81
如果有显示说明已经开放了.如果没有显示说明没有开放
5.环境变量
Tomcat JVM配置--catalina.bat/catalina.sh
windows
set JAVA_OPTS = -Xmx512m -Xms512m -XX:MaxPermSize=256m
linux
JAVA_OPTS ="-server -Xmx400m -Xms400m -Xmn128m -XX:MaxPermSize=128m -XX:PermSize=128m"
6.项目直接访问
【Tomcat直接访问项目--去掉访问路径上的项目名称】
修改Tomcat_Home/conf/server.xml
<Host> 下添加 <Context path="" docBase="项目路径" reloadable="true" />
path为访问路径,与request.getContextPath()返回值一样。
7.Nginx配置:
安装 pcre-devel openssl-devel
http{
#...
gzip on;
gzip_min_length 1k;
gzip_buffers 16 64k;
gzip_http_version 1.1;
gzip_comp_level 4;
gzip_types text/plain text/css application/xml image/png; #...
gzip_vary on;
sendfile on;
client_max_body_size 1024m;#附件上传
upstream e_learning{
server 192.168.1.30:8080;
server 192.168.1.31:8080;
ip_hash;
}
server{
listen 80;
server_name 192.168.1.34;
index index.jsp;
location / {
index index.jsp;
proxy_pass http://e_learning;
proxy_set_header Host $host;
proxy_set_header X-Real_IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location ^~ /upload/ {
expires 10d;
root /var/e_learning;
}
location ^~ /vod {
proxy_pass http://192.168.1.36:1935/vod/;
proxy_set_header Host $host;
proxy_set_header X-Real_IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location ~*\.(gif|jpg|png|js|css)$ {
expires 10d;
proxy_pass http://e_learning;
proxy_set_header Host $host;
proxy_set_header X-Real_IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}