安装完centos后
一、更换国内源
sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup sudo vim /etc/yum.repos.d/CentOS-Base.repo内容如下
# CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # # [base] name=CentOS-$releasever - Base - mirrors.ustc.edu.cn baseurl=http://mirrors.ustc.edu.cn/centos/$releasever/os/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os gpgcheck=1 gpgkey=http://mirrors.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-6 #released updates [updates] name=CentOS-$releasever - Updates - mirrors.ustc.edu.cn baseurl=http://mirrors.ustc.edu.cn/centos/$releasever/updates/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates gpgcheck=1 gpgkey=http://mirrors.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-6 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras - mirrors.ustc.edu.cn baseurl=http://mirrors.ustc.edu.cn/centos/$releasever/extras/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras gpgcheck=1 gpgkey=http://mirrors.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-6 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus - mirrors.ustc.edu.cn baseurl=http://mirrors.ustc.edu.cn/centos/$releasever/centosplus/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus gpgcheck=1 enabled=0 gpgkey=http://mirrors.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-6 #contrib - packages by Centos Users [contrib] name=CentOS-$releasever - Contrib - mirrors.ustc.edu.cn baseurl=http://mirrors.ustc.edu.cn/centos/$releasever/contrib/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib gpgcheck=1 enabled=0 gpgkey=http://mirrors.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-6
yum makecache
备注:
可以开启ssh
sudo chkconfig sshd on sudo service sshd start
安装jdk
删除旧的
rpm -qa |grep java yum -y remove java-1.6.0-openjdk-1.6.0.35-1.13.7.1.el6_6.i686 yum -y remove java-1.7.0-openjdk-1.7.0.79-2.5.5.4.el6.i686
sudo yum -y install jdk-7u71-linux-i586.rpm
修改/etc/profile添加
export JAVA_HOME=/usr/java/jdk1.7.0_71 export PATH=$JAVA_HOME/bin:$PATH export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
二、下载并解压tomcat
tar -zxvf apache-tomcat-8.0.30.tar.gz mv apache-tomcat-8.0.30 /usr/local/tomcat1
更改catalina.sh
CATALINA_HOME=/usr/local/tomcat1
备注:
sudo yum install -y gcc gcc-c++ openssl libssl-dev
三、下载并安装ngnix
tar zxvf pcre-8.37.tar.gz cd pcre-8.37 ./configure make sudo make install tar zxvf zlib-1.2.8.tar.gz cd zlib-1.2.8 make sudo make install tar zxvf nginx-1.8.0.tar.gz cd nginx-1.8.0 ./configure make sudo make install
配置防火墙
1.sudo vim /etc/sysconfig/iptables 2.在-A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited代码上面加入-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT 3.sudo service iptables restart
启动
sudo /usr/local/nginx/sbin/nginx
问题:nginx error while loading shared libraries: libpcre.so.1
32位: 1.ldd $(which /usr/local/nginx/sbin/nginx)发现是libpcre.so.1 => not found 2. cd /lib/ 3. ln -s libpcre.so.0.0.1 libpcre.so.1 4.重新启动sudo /usr/local/nginx/sbin/nginx
配置ngnix
proxy.conf
proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; client_max_body_size 10m; client_body_buffer_size 128k; proxy_connect_timeout 300; proxy_send_timeout 300; proxy_read_timeout 300; proxy_buffer_size 4k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k;gzip.conf
gzip on; gzip_min_length 1000; gzip_types text/plain text/css application/javascript application/x-javascript;
ngnix.conf
#user nobody; worker_processes 1; #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; include gzip.conf; include proxy.conf; upstream localhost{ server localhost:8080; server localhost:8081; } server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { # root html; # index index.html index.htm; proxy_connect_timeout 3; proxy_send_timeout 30; proxy_read_timeout 30; proxy_pass http://localhost; } #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; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } # 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; # } #} }
三、安装memcached
tar zxvf memcached-1.4.25.tar.gz ./configure --prefix=/usr make sudo make install
启动
/usr/local/bin/memcached -d -m 2048 -u root -l localhost -p 11211 -c 1024 -P /tmp/memcached.pidtelnet localhost 11211
stats查看状态
四、复制一份tomcat2 用cp -Rp
改端口为8081
配置context.xml
<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager" memcachedNodes="n1:localhost:11211" sticky="false" sessionBackupAsync="false" lockingMode="auto" requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$" transcoderFactoryClass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory" />
index.jsp
<%=session.getId()%>
访问时不断刷新就可以看到sessionID一样。表示成功
资源都在http://pan.baidu.com/s/1dDNu1f7