Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Ubuntu 設定-Wordpress 設定

sudo gedit /etc/apt/sources.list

剩下
deb http://ftp.twaren.net/Linux/Ubuntu/ubuntu/ hardy main restricted
deb-src http://ftp.twaren.net/Linux/Ubuntu/ubuntu/ hardy main restricted
deb http://ftp.twaren.net/Linux/Ubuntu/ubuntu/ hardy-updates main restricted
deb-src http://ftp.twaren.net/Linux/Ubuntu/ubuntu/ hardy-updates main restricted
deb http://ftp.twaren.net/Linux/Ubuntu/ubuntu/ hardy universe
deb-src http://ftp.twaren.net/Linux/Ubuntu/ubuntu/ hardy universe
deb http://ftp.twaren.net/Linux/Ubuntu/ubuntu/ hardy-updates universe
deb-src http://ftp.twaren.net/Linux/Ubuntu/ubuntu/ hardy-updates universe
deb http://ftp.twaren.net/Linux/Ubuntu/ubuntu/ hardy multiverse
deb-src http://ftp.twaren.net/Linux/Ubuntu/ubuntu/ hardy multiverse
deb http://ftp.twaren.net/Linux/Ubuntu/ubuntu/ hardy-updates multiverse
deb-src http://ftp.twaren.net/Linux/Ubuntu/ubuntu/ hardy-updates multiverse
deb http://tw.archive.ubuntu.com/ubuntu/ hardy-backports main restricted universe multiverse
deb-src http://tw.archive.ubuntu.com/ubuntu/ hardy-backports main restricted universe multiverse
deb http://ftp.twaren.net/Linux/Ubuntu/ubuntu/ hardy-security main restricted
deb-src http://ftp.twaren.net/Linux/Ubuntu/ubuntu/ hardy-security main restricted
deb http://ftp.twaren.net/Linux/Ubuntu/ubuntu/ hardy-security universe
deb-src http://ftp.twaren.net/Linux/Ubuntu/ubuntu/ hardy-security universe
deb http://ftp.twaren.net/Linux/Ubuntu/ubuntu/ hardy-security multiverse
deb-src http://ftp.twaren.net/Linux/Ubuntu/ubuntu/ hardy-security multiverse

hostname 設好才能裝 LAMP


sudo gedit /etc/hosts

內容
127.0.0.1 localhost
127.0.1.1 lesta.webhop.org Ahaha (前面是去申請來的,後面是裝 ubuntu 時幫電腦取的名字)
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

裝 LAMP
sudo apt-get -y install apache2
sudo apt-get -y install php5 libapache2-mod-php5 php5-gd php-pear php5-mysql
sudo apt-get -y install mysql-server mysql-client filezilla
wordpress 先不裝

設定 MySQL
mysql -uroot -p
[這邊會要你幫 root 設個密碼]
CREATE DATABASE blog;
GRANT ALL PRIVILEGES ON blog.* TO wordpress@localhost IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
EXIT

裝 wordpress
http://wordpress.org/download/
抓來解在/var/www/,把 wordpress 資料夾改名 blog

設定 wordpress
sudo cp /var/www/blog/wp-config-sample.php /var/www/blog/wp-config.php
sudo gedit /var/www/blog/wp-config.php

define('ABSPATH', '/var/www/blog/');
// ** MySQL settings ** //
define('DB_NAME', 'blog'); // The name of the database
define('DB_USER', 'wordpress'); // Your MySQL username
define('DB_PASSWORD', 'password'); // …and password
define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value
define('DB_CHARSET', 'utf8′);
define('DB_COLLATE', ”);

wordpress 初回設定
http://localhost/blog/wp-admin
(新版的會一直要下載 phtml 檔,先把瀏覽器的 cache 的快取都清掉就可成功執行)

備份不能 import
sudo chmod 777 那個資料夾
弄完記得 chmod 改回

裝 ddclinet(用 synaptic 裝非常簡單)


或是 sudo apt-get -y install ddclient

sudo gedit /etc/ddclient.conf

## ddclient configuration file


daemon=600 # check every 600 seconds
syslog=yes # log update msgs to syslog
mail-failure=lestaang@gmail.com # Mail failed updates to user
pid=/var/run/ddclient.pid # record PID in file.
## Detect IP with our CheckIP server
use=web, web=checkip.dyndns.com/, web-skip='IP Address'
## DynDNS username and password here
login=帳號
password=密碼
## Default options
protocol=dyndns2
server=members.dyndns.org
## Dynamic DNS hosts
lesta.webhop.org

讓別人能看得到我的 wordpress
option | general
WordPress address (URL):
Blog address (URL):
調整成非 localhost 的網址

要設 permalink 者最好是早點設定,以下和 htaccess 及 permalink 有關

搬動 wordpress 到別的資料夾
原文請見:http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory
(感覺類似轉址)
希望把檔案移到 wordpress 目錄下 http://xxx.com/wordpress
又希望使用者可以打原本根目錄的網址就可使用 http://xxx.com/
1.做一個新資料夾叫 wordpress
2.進 wordpress 的 option
3.WordPress address(URL) 改成檔案所在 http://xxx.com/wordpress
4.Blog address (URL) 是別人可能打的網址 http://xxx.com/
5.按 update
6.可以把檔案全搬進 wordpress 資料夾內了
7.現在把資料夾的 index.php 和.htaccess 復製到別人可能打的網址 http://xxx.com/
8.打開 copy 來的 index.php
9.搜尋 ./wp-blog-heager.php 改成 ./wordpress/wp-blog-heager.php
10.現在新的管理介面會在 http://xxx.com/wordpress/wp-admin
但使用 http://xxx.com/可連進你的網頁
11.如有設定 permalinks(在 option 下),則.htaccess 會自動更新(沒有的話就新增一個,或記得權限要打開 chm
od 666)
也可手動把內容貼上

options/permalinks
/%category%/%year%/%monthnum%/%post_id%

在 apache2 下要讓 .htaccess 可以生效


sudo a2enmod rewrite
sudo gedit /etc/apache2/apache2.conf

下面填上 wordpress 的資料夾位置


<Directory “/var/www/blog/”>
AllowOverride All
</Directory>

更改.htacess 設定
sudo gedit /var/www/blog/.htaccess

加上
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>

壓縮(主要是文字檔部份)
sudo a2enmod deflate
sudo gedit /var/www/blog/.htaccess (就是剛剛那個檔)
加上
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE application/atom
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/postscript
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/x-java
AddOutputFilterByType DEFLATE x-world/x-vrml
AddOutputFilterByType DEFLATE image/x-ms-bmp
AddOutputFilterByType DEFLATE image/svg+xml
</IfModule>

最後記得
sudo /etc/init.d/apache2 restart

用 adsl 架站想要個 free 的網域名稱 (DynDNS with ddclient)


本來我是有個 no-ip 的帳號,其實很好用介面簡單清楚,也用很久了
但是如果 adsl 要自己架站用到動態 ip 就得升級了
只好跳到 DynDNS 了,申請帳號和認證就不說了
登入以後東翻番西翻翻看到 Host Services / Add New Hostname /
alias 我是沒勾啦,因為我是阿呆,不知道勾那個可以幹麻
然後有幾個 checkbox 這是重點,Service Type 要選 WebHop Redirect
IP 可以暫時先把它偵測到的弄上去
就 creat 啦
現在回頭來設定我們電腦的部份
又是 synaptic,找 dyndns,把 ddclient 裝起來 (description 這種東西真不是寫假的~)
裝到一半它跳出來要你填的四條東東
1.lesta.webhop.org (你當然是寫妳剛申請的那個)
2.妳的帳號
3.妳的密碼
4.我沒寫…
就好了
我是斷線重連一次,用 firefox 連上 http://lesta.webhop.org/
嗯,出現的東西和 http://localhost/ 一樣,就確定 ok 啦,

You might also like