Tag Archives: wordpress

自动备份mysql数据库并发送到Email方法

Posted on 18. Dec, 2009 by Yao Yuan.

0

所以写了个自动备份mysql数据库的脚本,再加上gmail这个G级邮箱,备份多少数据都可以了…下面是代码:

mysqldump -uuser -ppassword –databases db1 db2 db3 > /home/website/backups/databackup.sql
tar zcf /home/website/backups/databackup.sql.tar.gz /home/website/backups/
echo “主题:数据库备份” | mutt -a /home/website/backups/databackup.sql.tar.gz -s “内容:数据库备份” www@gmail.com
rm -r /home/website/backups/*

将上面的代码保存为automysqlbackup.sh
然后利用crontab 实现动备份,在ssh下,

crontab -e

输入以下内容:

00 00 * * * /home/website/automysqlbackup.sh

这样就实现了每天00:00自动备份mysql数据库并发送到Email

简单的说明下吧.
第一句是一次性备份多个数据库,这个要你用root权限的用户才可以的..-u后面的是数据库用户名 -p后面的是数据库密码 无需空格 db1 db2 db3为你需要备份的数据库名.
如果你的数据库用户名没有root这个权限,可以改为这样

mysqldump -uuser -ppassword db1 > /home/website/backups/db1.sql
mysqldump -uuser -ppassword db2 > /home/website/backups/db1.sql
mysqldump -uuser -ppassword db3 > /home/website/backups/db1.sql

第二句是将 backups 文件夹里面的数据文件压缩为文件名:databackup.sql.tar.gz

第三句是将压缩了的数据库文件发送到指定的邮箱…..

其中的主题:数据库备份 ,就是邮件的主题, 内容:数据库备份,就是邮件的内用,

/home/website/backups/databackup.sql.tar.gz 为附件

www@gmail.com为要发送的Email

Continue Reading

Fix WordPress automaticlly upgrade wordpress upgrade automatically ‘Could not copy file……’

Posted on 27. Nov, 2009 by Yao Yuan.

0

I had moved my weblog to a cheapest vps server, it used to on a share hosting. but at the same time, the problem came . i can not use automaticlly upgrade of wordpress. it’s told me that ‘Could not copy file……’, and i need to fill the ftp infomations when i do it.
i found a funcion get_filesystem_method , the explanation of it

(FTP) it only uses this when it detects that files it creates have the wrong owner name

so, it’s clear… the owner of the dir and php process is different.

login ssh, do this

chown -R apache dir

it’s ok now.

Continue Reading

摆脱mySQL,让WordPress投奔SQLite

Posted on 19. May, 2009 by Yao Yuan.

0
WordPress默认就是与mySQL搭配的,这次要为wordpress换一个数据库搭档,但这并不是说mySQL如何的不优秀,但在10万以下的低并发访问,SQLite这样的单文件轻量级数据库系统性能优异,体积小、读取速度快、容量大,免费、开源,其实更适合像blog、或中小型站点的这种场景的数据库应用。
4 c- g- p! v5 d/ w6 W3 z
3 L2 b6 h7 P5 i/ u$ s

如果你需要独立为数据库服务支付购买,或者并不满意主机系统繁杂的mySQL数据服务,倒真的是应该尝试一下SQLite这样的轻量级数据库。6 L, P: b# {% i+ Q! W
SQLite官网:http://www.sqlite.org
系统环境依赖要求:8 N4 i$ e’ H2 m! }3 W1 c
主机php套件必须支持SQLite和PDO扩展(不过放心,常见系统都是完美支持的);SQLite的数据库信息存于独立文件中,该文件及文件夹必须要求读写权限。很简单,就这些要求。
升级更换wordpress数据系统:+ M1 @( \0 l9 c
这里指出一个简易的方法:首先在wordpress后台中使用“工具-导出”功能导出.xml文件。
然后,下载SQLite的wordpress功能插件-“PDO(SQLite) For WordPress”,将压缩包中的db.php和pdo文件夹放置到wp-content文件夹中。
! u, b6 L4 J’ d5 C# Q2 I0 q
然后,编辑wp-config.php文件,在图示位置加入“define(’DB_TYPE’, ’sqlite’);”。3 C, \1 x/ ^& z’ S2 W+ B1 l1 t
7 `- j- Z  R* _* _2 J
至此,重新访问wordpress已经启动了新的安装界面,如同安装,完后使用前面导出的.xml文件,回到wordpress后台然后“导入”即可恢复原数据,然后自行配置一下插件和主题,此时SQLite已经完全开始服役,所有数据读写皆交由SQLite处理。如果此间出现错误,请检查wp-content目录下是否自动生成了database目录,该目录下是否生成了相应的数据库文件myblog.sqlite和.htaccess文件,是否赋予可读写权限?  \: d+ [0 U0 P. E( M3 L+ `; K
SQLite能最大限度的降低建站成本,降低维护难度,又能很好的规避mySQL的缺点,SQLite为中小型数据应用很有前景。

Continue Reading

How to Fix Unexpected WordPress Database Table Error

Posted on 06. Mar, 2009 by Yao Yuan.

0

Two days ago, out of nowhere, a particular table in the WordPress in hongkiat.com went corrupted. The ‘wp_comments‘ table of the WordPress database just crashed without signs, warnings nor error messages. So how did I came to know? Here are the symptoms:

  • If you try to back up your database, you’ll be thrown with this error message – wp_comments is marked as crashed and should be repaired when using LOCK TABLES
  • Recent comments widget appears blank.
  • Top commenter widget appears blank.
  • Comment posted will not be written into DB, therefore will not be shown.
  • Comments section in WP Admin appears to have zero records.

After searching the Internet high and low in hoping to find similar cases to help me identify and fix the problem, I end up with nothing. So I tried it my way and luckily enough, I managed to solved it. I thought writing the entry out will not only help those who suffered the same, also keep myself reminded just in case I hit on this error again in the future.

The fix / Solution

To fix this, you must have access to the wordpress database, either via PhpMyAdmin or Secure Shell (SSH). Most shared hosting account comes with phpMyAdmin, but either option you should be extremely careful because you dealing with the database. Any wrong move will cause more data lost.

PhpMyAdmin

phpmyadmin-fix.gif

In PhpMyadmin, select the WordPress database and look for the error table. In my case, the ‘wp_comments‘ table. Check it, and scroll all the way down and look for ‘With selected‘ drop-down box. Select Repair table and things should be alright.

Secure Shell

SSH fix

  1. Login to your shell
  2. Enter ‘mysql -u username -p database_name‘ to access databases
  3. Enter ’show databases;’ to view all databases
  4. Enter ‘use database_name;‘ to engage the database
  5. Enter ‘show tables;‘ to show all tables within the database
  6. Enter ‘check table wordpress_table_name‘ to verify this is the corrupted table
  7. Fix it with ‘repair table wordpress_table_name
  8. Enter ‘check table wordpress_table_name‘ again to make sure it’s fixed

Step 3 and 5 are not necessary if you are familiar with your databases and tables. Hope this helps.

Continue Reading

WordPress Theme That Mimics Mac OS X Leopard – Leopress

Posted on 06. Mar, 2009 by Yao Yuan.

0

leopress

here’s the WordPress theme that gets very close to a Mac OS X Leopard – Leopress. Leopress tries to look like the Mac’s Finder, and I think it’s pretty close. One good reason why you will want to use WordPress themes that mimic other interface is – it kinda camouflage your blogging activity, hiding them from bosses or superiors who passes by.

View demo | Download Leopress

Continue Reading

Widgetize non-widget WordPress theme

Posted on 06. Mar, 2009 by Yao Yuan.

0

widgetize non widget theme
Consider this – If you found a WordPress theme that you like so much but it is not widget-supported, don’t give up just yet. Methods below helps you to widgetize non-widget theme to a drag-drop widget theme. Download Widget plugin from Automattic, upload them accordingly and follow the 2 steps below.

Step 1

Look for functions.php (Create one if you don’t have). Insert the following code into it, save and close. We are done with functions.php. Basically what this codes does is – it register the sidebar as dynamic.

<?php
if ( function_exists(’register_sidebar’) )
register_sidebar();
?>

Step 2

Here’s how a typical sidebar.php will look like.

<div id=”sidebar”>
<h2>Search this site</h2>
<div id=”searchdiv”>
<form id=”searchform” method=”get” action=”<?php echo $_SERVER['PHP_SELF']; ?>”>
<input type=”text” name=”s” id=”s” size=”20″/>
<input name=”sbutt” type=”submit” value=”Go” alt=”Submit” />
</form>
</div>
<h2><?php _e(’Archives’); ?></h2>
<ul><?php wp_get_archives(’type=monthly’); ?></ul>
<h2><?php _e(’Categories’); ?></h2>
<ul><?php list_cats() ?></ul>
<h2><?php _e(’Meta’); ?></h2>
<ul>
<?php wp_register(); ?>
<li><a href=”<?php bloginfo(’rss2_url’); ?>”>RSS</a></li>
<li><?php wp_loginout(); ?></li>
</ul>
<?php wp_meta(); ?>
</div>

What you need to do here is to enclose an an-if statement into sidebar.php. The addition of codes are in bold.

<div id=”sidebar”>
<h2>Search this site</h2>
<div id=”searchdiv”>
<form id=”searchform” method=”get” action=”<?php echo $_SERVER['PHP_SELF']; ?>”>
<input type=”text” name=”s” id=”s” size=”20″/>
<input name=”sbutt” type=”submit” value=”Go” alt=”Submit” />
</form>
</div>
//
<?php if ( !function_exists(’dynamic_sidebar’)
|| !dynamic_sidebar() ) : ?> // added

//
<h2><?php _e(’Archives’); ?></h2>
<ul><?php wp_get_archives(’type=monthly’); ?></ul>
<h2><?php _e(’Categories’); ?></h2>
<ul><?php list_cats() ?></ul>
<h2><?php _e(’Meta’); ?></h2>
<ul>
<?php wp_register(); ?>
<li><a href=”<?php bloginfo(’rss2_url’); ?>”>RSS</a></li>
<li><?php wp_loginout(); ?></li>
</ul>
<?php wp_meta(); ?>
//
<?php endif; ?> // added
//
</div>

That’s it. The theme now is now widgetized. You can now do the drag-drops like the widget themes. Here’s a goodWordPress widget resource.

Continue Reading

Execute PHP in WordPress post, page and Widget Sidebar

Posted on 06. Mar, 2009 by Yao Yuan.

0

If you are still struggling on how to insert PHP Codes inside particular blog post, page or a widget sidebar for execution; the following tutorial is for you.

Executing PHP codes in WordPress Page/Post

Installation

  1. Download phpexec.txt
  2. Rename phpexec.txt to phpexec.php
  3. Upload to /wp-content/plugins/ directory
  4. Activate the plug-in from WordPress administration menu

Usage

Anywhere in your post/pages where you want to execute a PHP Codes, insert <phpcode> before your php codes and </phpcode> your php codes.

<phpcode>
	<?php
		echo "Current date and time: ";
		echo date("l dS of F Y h:i:s A");
	?>
</phpcode>

Security

If you are running a blog with multiple users, you need to determine who can run this plug-in. Alter the settings in your Administration Menu. Options -> PHPExec

Executing PHP codes in WordPress widget sidebar

Installation

  1. Download execphp.txt
  2. Rename execphp.txt to execphp.php
  3. Upload to /wp-content/plugins/ directory
  4. Activate the plug-in from WordPress administration menu

Usage

This plug-in work like a normal text widget except that it allows execution of PHP Codes. You can create up to 9 instances of this widget.

Continue Reading

Something Useful for creating a WordPress theme

Posted on 06. Mar, 2009 by Yao Yuan.

0

people wanting to know how to create a WordPress theme. Here’s some resources I’ve found useful for putting one together:

  • Graphic design:
    • Useful to have: Photoshop/Fireworks or the like to create your graphics
    • For inspiration: sites like Netdiver, Design Melt Down, CSS Beauty, Unmatched Style etc can help sometimes.
    • Color scheme ideas: Colorschemer, Daily Color Scheme and Flickr (photos are a brilliant source for color combinations). Flip through your favourite magazines (I love looking through my How Magazines and books for ideas. Look at how you’ve designed your house/bedroom/office – what color combinations do you like?
    • Fonts: DaFont for free fonts and Linotype for purchasing professional fonts.
    • Images: SXC for free photos and iStockPhoto for inexpensive illustrations and photos.
  • XHTML/CSS templating:
  • Understanding how WordPress themes are put together. I can’t emphasise enough how important the WordPress manual is. Don’t miss the Stepping into templates information.
  • Understanding “the loop” and various WordPress tags.
  • Knowing when and how to install plugins. WP-Plugins.net has many plugins, but doing a Google or delicious search for “WordPress plugin” and then the type of plugin you’re wanting will help you find many others.
  • Knowing at least a little bit of PHP if you don’t want to feel so scared by WordPress tags, the loop, plugins and your templates. There’s some tutorials on W3Schools which can help.

Have you found any others which you find essential?

Continue Reading

My wp’s theme “elements-of-seo”

Posted on 07. Oct, 2008 by Yao Yuan.

0

Elements of SEO WordPress Theme is not designed by me,but Drew Stauffer. i had a little changed. and it passed xthml successfuly.if you like it you can download it for free.

[...]

Continue Reading

MY wp need update again (﹁ ﹁)~

Posted on 18. Sep, 2008 by Yao Yuan.

0

MY wp need update again,and something wrong with this theme.

But i have no time to care about it now.

i think i’ll do it at this weekend ……make a mark here

Continue Reading