AMH 社区首页
AMH社区 - 开放自由有价值的社区
[求助帖] 教程:AMH配置ngx_pagespeed tcmalloc提速 |
|
---|---|
caaol |
caaol 发表于 2013-11-04 16:05:58
查看美化版,AMH论坛排版好难看:http://www.wordpressnote.com/amh_ngx_pagespeed_tcmalloc/
最近一直在折腾VPS,入手一台ramnode的256 openvz,前面安装了centminmod,结果被ramnode官方停了两次,CPU负载超标。。。所以还是回归AMH面板。centminmod的集成ngx_pagespeed功能一直让我无法忘怀,所以今天也就给AMH折腾折腾! 参考资料: ngx_pagespeed 官方网站: [size=13px]https://github.com/pagespeed/ngx_pagespeed#how-to-build[/size] amh论坛: [size=13px]shell不是很流弊,先放出ssh操作,nginx mysql 加速 优化[/size] 准备开工
点赞,加油! (2分)
2013-11-04 16:05:58 1
|
caaol |
本帖最后由 caaol 于 2013-11-4 16:15 编辑
安装 ngx_pagespeed 安装扩展库 # These are for RedHat, CentOS, and Fedora. 下载ngx_pagespeed:$ sudo yum install gcc-c++ pcre-dev pcre-devel zlib-devel make # These are for Debian. Ubuntu will be similar. $ sudo apt-get install build-essential zlib1g-dev libpcre3 libpcre3-dev $ cd ~ 查看当前nginx加载模块 :$ wget <a href="https://github.com/pagespeed/ngx_pagespeed/archive/release-1.6.29.7-beta.zip" target="_blank">https://github.com/pagespeed/ngx ... e-1.6.29.7-beta.zip</a> $ unzip release-1.6.29.7-beta.zip # or unzip release-1.6.29.7-beta $ cd ngx_pagespeed-release-1.6.29.7-beta/ $ wget <a href="https://dl.google.com/dl/page-speed/psol/1.6.29.7.tar.gz" target="_blank">https://dl.google.com/dl/page-speed/psol/1.6.29.7.tar.gz</a> $ tar -xzvf 1.6.29.7.tar.gz # expands to psol/ /usr/local/nginx/sbin/nginx -V 备用(AMH安装完后默认加载的模块):./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module --with-http_gzip_static_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --without-http_uwsgi_module --without-http_scgi_module
下载nginx重新编译: cd /root wget <a href="http://amysql-amh.googlecode.com/files/nginx-1.2.9.tar.gz" target="_blank">http://amysql-amh.googlecode.com/files/nginx-1.2.9.tar.gz</a> tar zxf nginx-1.2.9.tar.gz cd nginx-1.2.9 ./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module --with-http_gzip_static_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --without-http_uwsgi_module --without-http_scgi_module <span style="color: #ff0000;">--add-module=$HOME/ngx_pagespeed-release-1.6.29.7-beta</span> make make install
回复
2013-11-04 16:06:19 2
|
caaol |
启用ngx_pagespeed:
编辑/usr/local/nginx/conf/nginx.conf { include mime.types; default_type application/octet-stream; server_names_hash_bucket_size 128; client_header_buffer_size 4k; large_client_header_buffers 4 4k; client_max_body_size 50m; sendfile on; tcp_nopush on; keepalive_timeout 60 60; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 16k; fastcgi_buffers 16 16k; fastcgi_busy_buffers_size 16k; fastcgi_temp_file_write_size 16k; fastcgi_intercept_errors on; tcp_nodelay on; server_tokens off; gzip on; gzip_min_length 1000; gzip_proxied expired no-cache no-store private auth; gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml application/rss+xml application/xhtml+xml application/atom_xml; gzip_disable "MSIE [1-6].(?!.*SV1)"; log_format access '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" $http_x_forwarded_for'; <span style="color: #ff0000;"> pagespeed on; pagespeed FileCachePath /var/ngx_pagespeed_cache;</span> include vhost/*.conf; server { listen 8888; server_name 23.226.224.248; index index.html index.htm index.php; root /home/wwwroot/index/web; fastcgi_buffer_size 4k; fastcgi_buffers 8 4k; fastcgi_busy_buffers_size 4k; gzip off; location ~ .*\.php$ { fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php; include fcgi.conf; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; } access_log /home/wwwroot/index/log/access.log combined; error_log /home/wwwroot/index/log/error.log crit; } server { listen 80 default; return 400; } } 红色的是加入的。 编辑/usr/local/nginx/conf/vhost/www.domain.com.conf server 重启nginx: amh nginx restart{ listen 80; server_name www.mbjbj.com; #server_name end index index.html index.htm index.php; #index end set $subdomain ''; root /home/wwwroot/www.mbjbj.com/web$subdomain; include rewrite/wordpress.conf; #rewrite end #error_page location ~ /ErrorPages/(400|401|403|404|405|502|503)\.html$ { root /home/wwwroot/www.mbjbj.com/web; } <span style="color: #ff0000;"># Ensure requests for pagespeed optimized resources go to the pagespeed # handler and no extraneous headers get set. location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" { add_header "" ""; } location ~ "^/ngx_pagespeed_static/" { } location ~ "^/ngx_pagespeed_beacon[ DISCUZ_CODE_1 ]quot; { } location /ngx_pagespeed_statistics { allow 127.0.0.1; deny all; } location /ngx_pagespeed_global_statistics { allow 127.0.0.1; deny all; } location /ngx_pagespeed_message { allow 127.0.0.1; deny all; } location /pagespeed_console { allow 127.0.0.1; deny all; }</span> location ~ .*\.php$ { fastcgi_pass unix:/tmp/php-cgi-www.mbjbj.com.sock; fastcgi_index index.php; include fcgi-host.conf; fastcgi_param DOCUMENT_ROOT /web$subdomain; fastcgi_param SCRIPT_FILENAME /web$subdomain$fastcgi_script_name; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp3|wma)$ { expires 30d; } location ~ .*\.(js|css)$ { expires 12h; } access_log /home/wwwroot/www.mbjbj.com/log/access.log combined; #access_log end error_log /home/wwwroot/www.mbjbj.com/log/error.log crit; #error_log end } $ curl -I 'http://localhost:8050/some_page/' | grep X-Page-Speed 显示X-Page-Speed: 1.6.29.7-...即成功,红色的地方换成你的网址这样做,开启了很多用不到的过滤器,后面再讲怎么具体配置 ngx_pagespeed。
回复
2013-11-04 16:09:28 3
|
ali |
占楼。。。
回复
2013-11-04 16:13:07 4
|
caaol |
安装 tcmalloc
参考 shell不是很流弊,先放出ssh操作,nginx mysql 加速 优化
回复
2013-11-04 16:17:14 5
|
894849635 |
顶楼主一个!
回复
2013-11-04 18:19:55 6
|
zmyamh |
不明觉硬啊
太厉害了!
回复
2013-11-04 20:08:48 7
|
tanyuxiang |
给力 等lz继续更新
回复
2013-11-04 20:41:34 8
|
Yusky |
辛苦了 支持 支持
回复
2013-11-04 20:45:41 9
|
amysql |
楼主来开发模块,方便大家使用。
回复
2013-11-05 10:58:54 10
AMH面板 - 好用高效低占用、安全可靠极稳定 |