标签归档:优化

wordpress代码精简和优化

1.css和JS压缩 可以使用yuicompressor 在线压缩 压缩时其他选择不勾

2.head 代码精简 去除不需要的代码功能 

主题functions.php里面

/**
* Disable Our Feed Urls
*/
function disable_our_feeds() {
wp_die( __('目前不提供 RSS 功能,请前往我们的<a href="'. get_bloginfo('url') .'">首页</a>。') );
}

add_action('do_feed', 'disable_our_feeds', 1);
add_action('do_feed_rdf', 'disable_our_feeds', 1);
add_action('do_feed_rss', 'disable_our_feeds', 1);
add_action('do_feed_rss2', 'disable_our_feeds', 1);
add_action('do_feed_atom', 'disable_our_feeds', 1);
remove_action('wp_head', 'feed_links_extra', 3);//清除feed信息
remove_action('wp_head', 'feed_links', 2);//清除feed信息

remove_action('wp_head', 'rsd_link');//清除离线编辑器接口
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'wp_shortlink_wp_head',10,0);
remove_action('wp_head', 'wp_generator');//去除版本信息
remove_action('wp_head', 'index_rel_link');
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head',10,0);//清除前后文信息

还有就是include里面的default-filters.php 优先

//Actions 里面注视 或者去除

// Actions
add_action( 'wp_head',             'wp_enqueue_scripts',              1     );
//add_action( 'wp_head',             'feed_links',                      2     );
//add_action( 'wp_head',             'feed_links_extra',                3     );
//add_action( 'wp_head',             'rsd_link'                               );
//add_action( 'wp_head',             'wlwmanifest_link'                       );
add_action( 'wp_head',             'adjacent_posts_rel_link_wp_head', 10, 0 );
add_action( 'wp_head',             'locale_stylesheet'                      );
add_action( 'publish_future_post', 'check_and_publish_future_post',   10, 1 );
add_action( 'wp_head',             'noindex',                          1    );
add_action( 'wp_head',             'wp_print_styles',                  8    );
add_action( 'wp_head',             'wp_print_head_scripts',            9    );
//add_action( 'wp_head',             'wp_generator'                           );
add_action( 'wp_head',             'rel_canonical'                          );
add_action( 'wp_footer',           'wp_print_footer_scripts',         20    );
//add_action( 'wp_head',             'wp_shortlink_wp_head',            10, 0 );
add_action( 'template_redirect',   'wp_shortlink_header',             11, 0 );
add_action( 'wp_print_footer_scripts', '_wp_footer_scripts'                 );
add_action( 'init',                'check_theme_switched',            99    );
add_action( 'after_switch_theme',  '_wp_sidebars_changed'                   );

// Feed Generator Tags
foreach ( array('commentsrss2_head','rdf_header', 'atom_head', 'comments_atom_head', 'opml_head', 'app_head' ) as $action ) {
	add_action( $action, 'the_generator' );

3.去除页面里面的评论 RSS 文章 RSS wordpress.org

include下面的default-widgets.php  查找Meta widget class

删除或者注释

<li><a href="<?php bloginfo('rss2_url'); ?>" title="<?php echo esc_attr(__('Syndicate this site using RSS 2.0')); ?>"><?php _e('Entries <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
 <li><a href="<?php bloginfo('comments_rss2_url'); ?>" title="<?php echo esc_attr(__('The latest comments to all posts in RSS')); ?>"><?php _e('Comments <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
 <li><a href="<?php esc_attr_e( 'http://wordpress.org/' ); ?>" title="<?php echo esc_attr(__('Powered by WordPress, state-of-the-art semantic personal publishing platform.')); ?>"><?php
 /* translators: meta widget link text */
 _e( 'WordPress.org' );
 ?></a></li>

OK 清理下来清爽多了 

debian 内存优化精简

网上copy来的命令:

apt-get -y purge apache2-* bind9-* xinetd samba-* nscd-* portmap sendmail-* sasl2-bin
apt-get -y purge lynx memtester unixodbc python-* odbcinst-* sudo tcpdump ttf-*
apt-get remove acpi acpi-support-base acpid eject man-db manpages nano vim laptop-detect bsdmainutils busybox dmidecode4
apt-get install automake wget zip unzip make time
pdksh 替代 bash
apt-get install pdkshchsh -s /bin/pdksh
//sudo apt-get install pdksh
//chsh -s /bin/pdksh
用 Dropbear 替代 OpenSSH
touch /etc/ssh/sshd_not_to_be_run
apt-get install dropbear
vi /etc/default/dropbear
/etc/init.d/dropbear start
syslog-ng 替代 rsyslog
apt-get install sysklogd && dpkg –purge rsyslog
apt-get autoremove && apt-get clean

数据库mysql优化:
wget http://www.day32.com/MySQL/tuning-primer.sh
chmod 755 tuning-primer.sh
sh tuning-primer.sh
http://www.unxmail.com/wp-content/uploads/2009/07/my-lxadmin-centos.cnf 文件内容:

[mysqld]
port = 3306
socket = /var/lib/mysql/mysql.sock
skip-locking
key_buffer = 16K
max_allowed_packet = 1M
table_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 64K
skip-bdb
skip-innodb
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
#safe-updates
[isamchk]
key_buffer = 8M
sort_buffer_size = 8M
[myisamchk]
key_buffer = 8M
sort_buffer_size = 8M
[mysqlhotcopy]
interactive-timeout

更改名字为my.cnf 覆盖 /etc/my.cnf 文件,然后重新启动mysql数据库