Friday, March 19, 2010

Linux初始開發環境設定

想查指令請下man blah 或用
blah --help / blah help 軟體通常有內建的說明

login as root or
login and su - as root

===非必要===for security reason only

開新帳號,不要一直用root做事 (必要時 sudo blah)
adduser blah

改sudo設定,以後用sudo取代root
visudo
加一行
blah ALL=NOPASSWD: ALL
save file


logout and login as normal user
============

edit ~/.bashrc

在 #force_color_prompt=yes  這行下面加
color_prompt=yes
以後就有顏色了
或是在putty把term從 xterm改成xterm-color
加一行
export LC_CTYPE="zh_TW.UTF-8"
解決svn co時遇到中文卡住 (by Thomas)

save file

改putty設定
Windows->Translation->UTF-8


更新apt資料庫 (建議用aptitude取代apt-get)
aptitude update

更新已安裝package
aptitude safe-upgrade
aptitude dist-upgrade

清理暫存空間
aptitude clean


===非必要===

先裝個screen來用用 (screen是好物,不會用很可惜,對screen不熟的,可以google一下)
aptitude install screen

edit ~/.screenrc
encoding utf8 utf8
save file

===APT package管理系統=====

建議使用aptitude取代apt-get (功能較強大,也支援apt-get的所有參數)

找package
aptitude search blah

裝package
aptitude install apache2 mysql-server php5 cakephp subversion


清理下載檔案
aptitude clean

查詢已安裝package狀態
       dpkg-query actions
              See  dpkg-query(1) for more information about the follow-
              ing actions.

              -l, --list package-name-pattern...
                  List packages matching given pattern.
              -s, --status package-name...
                  Report status of specified package.
              -L, --listfiles package-name...
                  List files installed to your system from package-name.
              -S, --search filename-search-pattern...
                  Search for a filename from installed packages.
              -p, --print-avail package-name...
                  Display details about package-name, as found in
                  /var/lib/dpkg/available.


===MySQL===
開帳號 權限
mysql -u root -ppassword mysql (新系統root預設是無密碼,所以要用mysql -u root mysql)
CREATE USER 'blah'@'%' IDENTIFIED BY 'foo';
GRANT ALL PRIVILEGES ON *.* TO 'blah'@'%' WITH GRANT OPTION;

改mysqld 的 listen ip
edit /etc/mysql/my.cnf
comment out
#bind-address           = 127.0.0.1
save file

重開MySQL
/etc/init.d/mysql restart
把svn checkout
svn co https://svn的網址

使用到的db看
\app\config\database.php  (cakephp db config file)
帳號請爬 code

===php===
edit php.ini (/etc/php5/apache2/php.ini)


date.timezone = Asia/Taipei




===Zend Framework===

把Zend library搬到/usr/share/php
sudo mv ~/ZendFramework-1.9.5/library/Zend/ /usr/share/php/

改php.ini (/etc/php5/apache2)
加入Zend library的path
include_path = ".:/usr/share/php"


===CakePHP===
chmod -R 777 user2/app/tmp (因為svn的關係,否則正常程序為 chown -R www-data app/tmp)

在 /app/config/core.php  中  comment掉
#Configure::write('App.baseUrl', env('SCRIPT_NAME'));

mod_rewrite用到的檔案 (不用可以砍,或是不開目錄的AllowOverride就沒事)
# /.htaccess
# /app/.htaccess
# /app/webroot/.htaccess

有沒有開的差別

Cake's built in pretty URLs

www.example.com/index.php/controllername/actionname/param

URL when mod_rewrite is on

www.example.com/controllername/actionname/param.

===Vim .ctp設定===
vim .ctp syntax highlight
 
root@h7dev06:~$ cat ~/.vim/ftdetect/ctp.vim
au BufRead,BufNewFile *.ctp             set filetype=php


=============

web server路徑相關設定請參考kevin寫的windows環境設定

apache設定mod_rewrite
edit httpd.conf (Make sure you are editing the system httpd.conf rather than a user- or site-specific httpd.conf)

DocumentRoot要開AllowOverride


    Options FollowSymLinks
    AllowOverride All


參考cakephp文件 3.3.4 Apache and mod_rewrite (and .htaccess)



=====svn sever 以下可省略====(有興趣的請自行研究)


aptitude install subversion-tools libapache2-svn


edit /etc/apache2/mods-enabled/dav_svn.conf
把該uncomment的 uncomment


設你自己想要的路徑後再生目錄
SVNPath /var/lib/svn
mkdir /var/lib/svn
svnadmin create /var/lib/svn
chown -R www-data:www-data /var/lib/svn

認證檔位置
AuthUserFile /etc/apache2/dav_svn.passwd

生檔案設密碼
htpasswd /etc/apache2/dav_svn.passwd blah

https support
foo@bar:/etc/apache2/mods-enabled$  ln -s ../mods-available/ssl.* .
/etc/apache2/sites-enabled也要做link


sample
/etc/apache2/mods-enabled/dav_svn.conf


  DAV svn
  SVNPath /var/lib/svn
  AuthType Basic
  AuthName "Subversion Repository"
  AuthUserFile /etc/apache2/dav_svn.passwd
  Require valid-user

No comments: