apache和tomcat和nginx的命令以及维护优化的技巧

1.nginx 

   命令:  启动  start nginx

             停止   nginx -s stop

             重启   nginx -s reload

   配置参数

             http:{

             server_tokens off;
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    access_log off;
    keepalive_timeout 10;
    client_header_timeout 10;
    client_body_timeout 10;
    reset_timedout_connection on;
    send_timeout 10;
    gzip on;
    gzip_disable "msie6";
    gzip_proxied any;
    gzip_min_length 1000;
    gzip_comp_level 4;
    gzip_types text/plain text/css application/json application/x-javascript application/xml text/xml application/xml+rss text/javascript;

 

 

       } 

 

2. apache 

2.1主要讲讲配置二级域名,查阅了一些资料,刚开始弄了好久没弄明白,原来可以通过一种简单的方式来解决   

比如有网站域名  yeegee.com   想在服务器上,通过二级域名来控制访问不同目录

假设有两个web项目  bbsproj  项目 ,  videoproj 项目  ,  想达到的效果,是通过设置二级域名

bbs.yeegee.com来访问bbsproj 项目主页 ,video.yeegee.com来访问videoproj项目主页,那么就要进行如下设置:

1.打开conf/httpd.conf,启用http代理

LoadModule proxy_module modules/mod_proxy.so

LoadModule proxy_connect_module modules/mod_proxy_connect.so

LoadModule proxy_http_module modules/mod_proxy_http.so

  注意,同时也要配置下面这句(支持多站点)

LoadModule vhost_alias_module modules/mod_vhost_alias.so

2.2引用外部配置文件

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

如果前面有#号,请去掉。

2.3.配置httpd-vhosts.conf,  以下是实际项目中用到的配置文件,请君品鉴:

<VirtualHost *:80>
    ServerAdmin chenyb12345@163.com
    ServerName www.yeegee.com
    ServerAlias www.yeegee.com
    ProxyPass / http://www.yeegee.com:801
    ProxyPassReverse / http://www.yeegee.com:801
    ErrorLog "logs/www.yeegee.com-error.log"
    CustomLog "logs/www.yeegee.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
    ServerAdmin chenyb12345@163.com
    ServerName download.yeegee.com
    ServerAlias download.yeegee.com
    ProxyPass / http://download.yeegee.com:802
    ProxyPassReverse / http://download.yeegee.com:802
    ErrorLog "logs/download.yeegee.com-error.log"
    CustomLog "logs/download.yeegee.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
    ServerAdmin chenyb12345@163.com
    ServerName taxi.yeegee.com
    ServerAlias taxi.yeegee.com
    ProxyPass / http://taxi.yeegee.com:803
    ProxyPassReverse / http://taxi.yeegee.com:803
    ErrorLog "logs/taxi.yeegee.com-error.log"
    CustomLog "logs/taxi.yeegee.com-access.log" common
</VirtualHost>


<VirtualHost *:80>
    ServerAdmin chenyb12345@163.com
    ServerName wx.yeegee.com
    ServerAlias wx.yeegee.com
    ProxyPass / http://wx.yeegee.com:8710/
    ProxyPassReverse / http://wx.yeegee.com:8710/
    ErrorLog "logs/wx.yeegee.com-error.log"
    CustomLog "logs/wx.yeegee.com-access.log" common
</VirtualHost> 

<VirtualHost *:80>
    ServerAdmin chenyb12345@163.com
    ServerName trace.chengchengda.com
    ServerAlias trace.chengchengda.com
    ProxyPass / http://121.196.236.198:8000/gtopTracker/
    ProxyPassReverse / http://121.196.236.198:8000/gtopTracker/
    ProxyPassReverseCookiePath /gtopTracker /
    ErrorLog "logs/wx.chengchengda.com-error.log"
    CustomLog "logs/wx.chengchengda.com-access.log" common
</VirtualHost>

 

**  ProxyPassReverseCookiePath  是为了在转发时,cookie的级别从 /gtopTracker 提升到 / ,这样,就不会出现session失效的问题了。

 

 配好之后,重启服务器,就可以通过  wx.yeegee.com访问8710端口所在服务器的项目了,如果是需要指定到myapp项目怎么办呢?  很简单,把上面的 http://wx.yeegee.com:8710/ 改成   http://wx.yeegee.com:8710/myapp/   就ok了。  记住,不能少反斜杠哦。

关于windows 服务器上,如果访问量很大,需要配置的是conf/extra/httpd-mpm.conf

<IfModule mpm_winnt_module>
    ThreadsPerChild        450  
    MaxConnectionsPerChild 10000
</IfModule>
 

根据实际需要做好相应配置即可。

3.tomcat 主要记录一下启动配置参数

修改bin/catalina.bat 在首行写入这句

set JAVA_OPTS=-server -Xms128m -Xmx256m -Xss512k -XX:+AggressiveOpts -XX:+UseBiaseLocking -XX:PermSize=256M -XX:MaxNewSize=256M -XX:+DisableExplicitGC -XX:MaxTenuringThreshold=31 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -Djava.awt.headless=true -XX:MaxPermSize=256m 

具体什么意思,百度查下吧,我就偷个懒。。。

下次抽个时间整理一下oracle数据库的优化,oracle的内容比这要多很多。。

希望这次的内容能够对你有所帮助,如有错误欢迎批评指正,如果有兴趣,可以发邮件到我的Email: chenyb12345@163.com。希望和各位成为好朋友,欢迎大家一起讨论,一起进步。

 

4.nginx二级域名转发配置

http {
    include  mime.types;
  
    default_type  application/octet-stream;
    charset utf-8;
    server_tokens off;
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    access_log off;
    client_max_body_size 50m;
    keepalive_timeout 10;
    client_header_timeout 10;
    client_body_timeout 10; 
    reset_timedout_connection on;
    send_timeout 10;
    gzip on;
    gzip_disable "msie6";
    gzip_proxied any;
    gzip_min_length 1000;
    gzip_comp_level 4;
    gzip_types text/plain text/css application/json application/x-javascript application/xml text/xml application/vnd.apple.mpegurl video/mp2t application/xml+rss text/javascript;

    server {
        listen      80;
	server_name a.domain.com;	
        location / {
            root www;
        }
		
      }

    server{
	listen 80;
	server_name b.domain.com;
	location / { 
		proxy_pass http://127.0.0.1:8080/demo1/;
		proxy_redirect default;
		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_set_header Cookie $http_cookie; 
		proxy_connect_timeout 30;


	}
    } 

     server{
	listen 80;
	server_name wx.domain.com;
	location / { 
		proxy_pass http://127.0.0.1:8081/demo2/;
		proxy_redirect default;
		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_set_header Cookie $http_cookie; 
		proxy_connect_timeout 30; 

	}
    } 

    
}

 

 

 

 

 

 


 


 

 

 

转载于:https://my.oschina.net/u/2457585/blog/626855

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值