在 function.php 中加入以下的 php 碼
[code]
function utf8_trim($str) {
$len = strlen($str);
for ($i=strlen($str)-1; $i>=0; $i-=1){
$hex .= ' '.ord($str[$i]);
$ch = ord($str[$i]);
if (($ch & 128)==0) return(substr($str,0,$i));
if (($ch & 192)==192) return(substr($str,0,$i));
}
return($str.$hex);
}
function mul_excerpt ($excerpt) {
$myexcerpt = substr($excerpt,0,500);
return utf8_trim($myexcerpt) . '... ';
}
add_filter('the_excerpt', 'mul_excerpt');
add_filter('the_excerpt_rss', 'mul_excerpt');
[/code]
2010年12月15日
2010年12月14日
Wordpress 安裝外掛或主題時, 資料夾權限問題
前一篇發現了 Wordpress 安裝外掛或主題時, 資料夾權限問題, 變成要另裝 vsFTP 才能上傳的問題, 在 WordPress搬家注意事項之資料夾、權限設定, 這篇文章得到更方便的解決方法:
開啟 wordpress 根目錄下的「wp-config.php」文件,在最後一行上添加下方代碼。
即可!
開啟 wordpress 根目錄下的「wp-config.php」文件,在最後一行上添加下方代碼。
/** 設定新主機資料夾權限 **/
if(is_admin()) {
add_filter('filesystem_method', create_function('$a', 'return "direct";' ));
define( 'FS_CHMOD_DIR', 0751 );
}即可!
2010年12月11日
安裝 wordpress 在 ubuntu 10.04
上次發現將 wordpress 安裝在 ubuntu 10.04 上, 媒體檔案上傳時,就可以用中文檔名 (在 windows 平台上不行),但要安裝佈景主題 (theme) 或外掛 (plugin) 時,竟要輸入 “Connection Information“ :
在 Google 一番之後,我安裝了 vsftp, 並修改了 /etc/vsftpd.conf 這個預設的資訊檔, 裡面多半採用預設值即可,只有一個特別要注意的是
要特別加上 # 號,否則會出現:
這種問題。本以為是目錄權限設定不好,但弄了很久,才猜到可能是上述的 FTP 上傳後 unmask 的問題,加上#之後,果然就正常了!
註:
1. vsFTP 帳號用原來的 ubuntu 帳號即可
2. 重新啟動 vsFTP 的指令:
4. /etc/vsftpd.conf 檔中的重要內容
Hostname:127.0.0.1等資訊。這在安裝在 windows 平台時是沒見過的。看起來是要 ubuntu 上裝一個 FTP server。
FTP Username:
FTP Password:
Connection Type:
在 Google 一番之後,我安裝了 vsftp, 並修改了 /etc/vsftpd.conf 這個預設的資訊檔, 裡面多半採用預設值即可,只有一個特別要注意的是
#local_umask=022
要特別加上 # 號,否則會出現:
Could not create directory. /var/www/wp-content/XXX ...
這種問題。本以為是目錄權限設定不好,但弄了很久,才猜到可能是上述的 FTP 上傳後 unmask 的問題,加上#之後,果然就正常了!
註:
1. vsFTP 帳號用原來的 ubuntu 帳號即可
2. 重新啟動 vsFTP 的指令:
sudo /etc/init.d/vsftpd start3. 其它參考指令
netstat -ntulp |grep 21
netstat -ntulp |more
sudo /etc/init.d/apache2 restart
4. /etc/vsftpd.conf 檔中的重要內容
listen=YES
anonymous_enable=NO
local_enable=YES
write_enable=YES
#local_umask=022
#anon_upload_enable=YES
#anon_mkdir_write_enable=YES
dirmessage_enable=YES
use_localtime=YES
xferlog_enable=YES
#connect_from_port_20=YES
#chown_uploads=YES
#chown_username=whoever
secure_chroot_dir=/var/run/vsftpd/empty
pam_service_name=vsftpd
rsa_cert_file=/etc/ssl/private/vsftpd.pem
2010年12月10日
Apache 2 - sites.available 的設定
以下本來是試 Apache::ASP 和 mono,看可否在 ubuntu + apache 之下,跑以前寫的 asp 程式。但是發現它們多是適用 asp.net 的架構, 而不是最早以前 IIS 下的簡單 asp 語法。
看來是要忍痛放棄 IIS 了...
<VirtualHost *:80>
RewriteEngine On
RewriteOptions Inherit
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
Alias /asp_web "/home/XXX/asp_web/"
<Directory "/home/XXX/asp_web/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
SetHandler mono
DirectoryIndex index.aspx default.asp index.asp index.htm index.html
</Directory>
</VirtualHost>
轉程式碼, 參見 HTML encoder
看來是要忍痛放棄 IIS 了...
<VirtualHost *:80>
RewriteEngine On
RewriteOptions Inherit
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
Alias /asp_web "/home/XXX/asp_web/"
<Directory "/home/XXX/asp_web/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
SetHandler mono
DirectoryIndex index.aspx default.asp index.asp index.htm index.html
</Directory>
</VirtualHost>
轉程式碼, 參見 HTML encoder
2010年11月10日
Wordpress MU 的設定
程式名稱:WordPress MU
官方網站:http://mu.wordpress.org/
程式下載:按這裡
備註事項:從WordPress3.0起整合於WordPress,所以直接下載WordPress。
假設你己裝好 Apache, PHP5, mySQL
註: 要開始設定 WP, 首先要連上的網址是:
http://xx.xx.xx.xx/wp-admin/
才會啟動以上的設定程序
1. 要先安裝 WP 的單人版 (可參見: 如何架設安裝WordPress部落格?)
2. 裝好後, 修改 WP 目錄中的 wp-config.php, 在以下
/* That’s all, stop editing! Happy blogging. */
的上方加入一行:
3. 重新整理部落格後台,點擊左方【工具】 (Tools)→「網誌網路」(Network),進入後請將網誌網路的標題和聯絡信箱設定好,並點擊﹝安裝﹞(Install)。
重新安裝一次 WP 時, 要刪除原在在 mySQL 中已建好的 schema (資料庫), 再重新建 schema)
4. 在剛剛改過的 wp-config.php 中相同的位置, 加入以下:
7. 開啟 Apache 的 rewrite 功能
先啟動 rewrite 模組, 在終端機中下指令:
然後修改 /etc/apache2/sites-available 中的 default 檔, 將其中的 AllowOverride NONE, 改成 AllowOverride All, 如下
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
8. 重新啟動 apache, 在終端機中下指令
==如果無法內建安裝外掛、佈景==
(試過 wp 4.2 on Mint 7)
在 wp-config.php 中的最後,加上幾行如下,即可啟動內建安裝:
if(is_admin()) {
add_filter('filesystem_method', create_function('$a', 'return "direct";' ));
define( 'FS_CHMOD_DIR', 0751 );
}
參見:
=== see also ===
Re: Where is Apache installed on Ubuntu?
Apache config files are in /etc/apache
Apache log files are in /var/log/apache
Apache libs are in /usr/lib/apache
Other files can be in /usr/share/apache, /var/lib/apache
官方網站:http://mu.wordpress.org/
程式下載:按這裡
備註事項:從WordPress3.0起整合於WordPress,所以直接下載WordPress。
假設你己裝好 Apache, PHP5, mySQL
註: 要開始設定 WP, 首先要連上的網址是:
http://xx.xx.xx.xx/wp-admin/
才會啟動以上的設定程序
1. 要先安裝 WP 的單人版 (可參見: 如何架設安裝WordPress部落格?)
2. 裝好後, 修改 WP 目錄中的 wp-config.php, 在以下
/* That’s all, stop editing! Happy blogging. */
的上方加入一行:
define('WP_ALLOW_MULTISITE', true);
請另在「/var/www/wp-content」目錄下新建一個資料夾「blogs.dir」並設定資料夾屬性為「777」,讓用戶可上傳檔案。3. 重新整理部落格後台,點擊左方【工具】 (Tools)→「網誌網路」(Network),進入後請將網誌網路的標題和聯絡信箱設定好,並點擊﹝安裝﹞(Install)。
重新安裝一次 WP 時, 要刪除原在在 mySQL 中已建好的 schema (資料庫), 再重新建 schema)
4. 在剛剛改過的 wp-config.php 中相同的位置, 加入以下:
即在這一行 define('WP_ALLOW_MULTISITE', true); 的下方, 加入
define( 'MULTISITE', true );5. 在 wp-config.php 相同的子目錄下,新增一個 .htaccess 檔, 再貼上
define( 'SUBDOMAIN_INSTALL', false ); $base = '/';
define( 'DOMAIN_CURRENT_SITE', 'xxx.xxx.xxx' );
define( 'PATH_CURRENT_SITE', '/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
6. 這樣應該就可以啟動 Wordpress MU 了, 如果子網站無法連結, 應該是 Apache 的 rewrite 功能未開啟7. 開啟 Apache 的 rewrite 功能
先啟動 rewrite 模組, 在終端機中下指令:
sudo a2enmod rewrite(在 ubuntu 中, Apache 的預設安裝路徑是 /etc/apache)
然後修改 /etc/apache2/sites-available 中的 default 檔, 將其中的 AllowOverride NONE, 改成 AllowOverride All, 如下
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
8. 重新啟動 apache, 在終端機中下指令
sudo /etc/init.d/apache2 restart這樣應該就完成了!
==如果無法內建安裝外掛、佈景==
(試過 wp 4.2 on Mint 7)
在 wp-config.php 中的最後,加上幾行如下,即可啟動內建安裝:
if(is_admin()) {
add_filter('filesystem_method', create_function('$a', 'return "direct";' ));
define( 'FS_CHMOD_DIR', 0751 );
}
另見: Wordpress 的上傳檔案大小限制
參見:
- [教學]如何架設WordPress MU 多用戶部落格?http://sofree.cc/wordpress-mu/
- Where is Apache installed on Ubuntu? http://ubuntuforums.org/showthread.php?t=35695
- Enable Apache Rewrite For Your Wordpress
=== see also ===
Re: Where is Apache installed on Ubuntu?
Apache config files are in /etc/apache
Apache log files are in /var/log/apache
Apache libs are in /usr/lib/apache
Other files can be in /usr/share/apache, /var/lib/apache
2010年7月11日
Ubuntu Enterprise Cloud, UEC
Eucalyptus Beginner’s Guide – UEC Edition
Chapter 1 – Introduction to UEC and its components
雲端運算安裝 Ubuntu Enterprise Cloud install
HAProxy 當 server load balancer
硬體 Citrix / Alteon / Foundry 這些 SLB hardware device
BalanceNG
Crossroads
LVS 好像比較是 系統備援 (see http://www.ibm.com/developerworks/linux/library/l-linux-ha/index.html)
訂閱:
文章 (Atom)