安裝家裡 Home Debian
# 安裝光碟版本 : Debian 6.0.1a-i386
# 安裝磁區把 /usr /var /home /root ...etc 獨立分開
# 內部固定 IP 192.168.0.156
# DDNS xxx.myftp.org
1. 清掉 sources 的 從 CD ROM 讀取套件 List
$ vim /etc/apt/sources.list
# 把檔案裡面的 # deb cdrom:[Debian xxxxxxxxx … 開頭的刪掉
# 選擇後按下 dd 刪除 , 刪除後 ,
# 按下 ESC , 輸入 :wq , 按下 Enter
2. 安裝 ssh
$ apt-get update
$ apt-get -y install ssh
3, 安裝 pppoe
# 現在,您可以使用 "pon dsl-provider" 來建立 DSL │
# 連線並使用 "poff" 來中斷連線。
$ apt-cache search pppoe
$ apt-get install pppoe pppoeconf
# 啟動 pppoe
$ pppoeconf
# 安裝 vim 跟 移除預設的編輯器 nano
$ apt-get install ssh
$ apt-get autoremove nano
4. 安裝套件
$ apt-get -y install ssh w3m libncurses5 sudo gcc portmap
libncurses5-dev make unzip patch lynx
wget vim rcconf phpmyadmin libdate-calc-perl
rsync php5 apache2 php5-cgi php5-cli php5-curl php5-dev php5-gd
php5-mysql libapache2-mod-php5 mysql-client mysql-server chkrootkit ntpdate
mplayer ffmpeg curl ntp
5. 關掉 跟 移除 Mail Client ( MTA )
$ /etc/init.d/exim4 stop
$ apt-get autoremove exim4
6. 安裝 noip , 先申請 xxx.myftp.org
# 啟動 DDNS ( 動態 IP 網域對應 )
$ cd /root/
$ wget 'https://www.no-ip.com/client/linux/noip-duc-linux.tar.gz' .
$ tar zxvf noip-duc-linux.tar.gz
$ cd noip-2.1.9-1
$ make
$ make install
7. 設定開機的時候會啟動哪些服務
$ rcconf
8. 觀看每各磁區大小跟位置
$ df -h
檔案系統 Size Used Avail Use% 掛載點
/dev/sda1 323M 119M 188M 39% /
tmpfs 501M 0 501M 0% /lib/init/rw
udev 497M 192K 497M 1% /dev
tmpfs 501M 0 501M 0% /dev/shm
/dev/sda9 24G 173M 22G 1% /home
/dev/sda8 368M 11M 339M 3% /tmp
/dev/sda5 8.3G 732M 7.2G 10% /usr
/dev/sda6 2.8G 327M 2.3G 13% /var
9. 觀看服務的 port , 確定都是自己要使用的 port 服務
$ netstat -tlnap
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 1284/mysqld
tcp 0 0 0.0.0.0:51309 0.0.0.0:* LISTEN 778/rpc.statd
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 763/portmap
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1288/sshd
tcp 0 52 192.168.0.156:22 192.168.0.112:1506 ESTABLISHED 1683/0
tcp6 0 0 :::80 :::* LISTEN 984/apache2
tcp6 0 0 :::22 :::* LISTEN 1288/sshd
10. 調整時區 , 調整所在位置的時區地點
$ dpkg-reconfigure tzdata
11. PHP Web 介面檔案上傳容量限制修改 ; 重新啟動 apache2
$ vim /etc/php5/apache2/php.ini
#upload_max_filesize = 50M ; 可以上傳50MB的檔案
#post_max_size = 50M ; PHP 將接受的POST資料最大大小。
#file_uploads = On ; 是否允許HTTP方式文件上載
12. 如果需要重新設定 Mysql 的 root 密碼 ; 或可透過 phpmyadmin 來設定
$ /usr/bin/mysqladmin -u root -p password '123456' ;
13. 檢查 PHP 是否有 run 起來
$ touch /var/www/phpinfo.php ; echo '<?PHP phpinfo(); ?>' > /var/www/phpinfo.php
$ 打開 Brwoser , 輸入 http://homedebian.myftp.org/phpinfo.php
14. 安裝 phpmyadmin
# 列出所有 Phpmyadmin 安裝目錄 跟檔案
# dpkg -L phpmyadmin
/var/lib/phpmyadmin
/etc
/etc/phpmyadmin
/etc/phpmyadmin/lighttpd.conf
..
# 移除系統安裝的 phpmyadmin
$ apt-get autoremove phpmyadmin
# 安裝 mcrypt libmcrypt4
$ apt-get install php5-mcrypt libmcrypt4
# 抓取 phpmyadmin 官方網站的, 重新取目錄名稱
$ cd /var/www/
$ wget 'http://downloads.sourceforge.net/project/phpmyadmin/phpMyAdmin/3.4.9/phpMyAdmin-3.4.9-all-languages.tar.gz?r=http%3A%2F%2Fwww.phpmyadmin.net%2Fhome_page%2Fdownloads.php&ts=1325990408&use_mirror=ncu' .
$ mv phpMyAdmin-3.4.9-all-languages.tar.gz\?r\=http\:%2F%2Fwww.phpmyadmin.net%2Fhome_page%2Fdownloads.php\&ts\=1325990408\&use_mirror\=ncu phpmyadmin3.4.9.tar.gz
$ tar zxvf phpmyadmin3.4.9.tar.gz
$ mv phpMyAdmin-3.4.9-all-languages phpmyadmin_homedebain
15. 打開 Brwoser , 輸入 http://xxx.myftp.org/phpmyadmin_homedebain
2012年1月8日 星期日
[ How-To] Debian Linux Apache2 + SVN Server +SSL
環境規格 :
OS : ( Debian6.0.1- 6.0.3) + apache2(2.2.16)+ HTTPS/SSL + Subversion(1.6.12)
需求 : 建立程式碼版本控制服務,使用 subversion
1. 安裝 svn
svn-server 套件
$ apt-get install subversion libapache2-svn apache2
svn-client 套件
$ apt-get install subversion-tools
2. 建立 svn 目錄(/home/svn/repository),配置目錄所有者(www-data)跟 權限
$ mkdir /home/svn
$ chown www-data:www-data -R /home/svn
$ chmod 770 -R /home/svn
3. 建立 svn 用戶 admin 密碼 /etc/apache2/dav_svn.passwd
$ /usr/bin/htpasswd -c /etc/apache2/dav_svn.passwd admin
New password:
Re-type new password:
Adding password for user admin
# 建立一般用戶的帳號 密碼
$ /usr/bin/htpasswd /etc/apache2/dav_svn.passwd fifi.chen
$ cat /etc/apache2/dav_svn.passwd
admin:OlOpE5W7gXLis
user1:W7zVH8zz13KgA
user2:qQ7eb81zSZ2.g
4. 建立 svn 目錄權限配置文件:/etc/apache2/dav_svn.authz
$ vim /etc/apache2/dav_svn.authz
[groups]
admin=admin
guest=user1,user2
#新建每一個版本庫都需要再設一各權限配置
[test1:/] # 版本庫 test1 權限配置
# *= # 默認禁止所有用戶訪問
@admin=rw # admin 組有 rw 權限
user1=r # 用戶 user1 有 r 權限
[test2:/] # 版本庫 test2 權限配置
@admin=rw # admin 組有 rw 權限
user2=r # 用戶 user2 有 r 權限
5. 修訂 /etc/apache2/mods-available/dav_svn.conf
建立 svn location,指定 svn 目錄,認證方式,認證信息;
指定 dav_svn.passwd 用戶密碼配置文件路徑;
指定 dav_svn.authz 目錄權限配置文件路徑。
$ cp /etc/apache2/mods-available/dav_svn.conf /etc/apache2/mods-available/dav_svn.conf.bak
$ vim /etc/apache2/mods-available/dav_svn.conf
<Location /svn>
DAV svn
SVNParentPath /home/svn
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/dav_svn.passwd
AuthzSVNAccessFile /etc/apache2/dav_svn.authz
Require valid-user
</Location>
6. 建立 svn 版本庫(test1、test2)
$ su www-data
$ svnadmin create /home/svn/test1
$ svnadmin create /home/svn/test2
7. 重新啟動 apache2
$ su root
$ /etc/init.d/apache2 restart
8. 打開瀏覽器,輸入 http://domain/svn/test1
9. SVN Clinet 端操作
Windows下, 使用 Tortoise 來存取 版本庫
[Tortoise]
Linux 下 , 使用 svn 存取 , checkout(co)/commit(ci)/update(up).
例如 svn co http://domain/svn/test1
匯入程式檔案
$ svn import /testtmp http://IP&Domain/svn/test1/tmp
打開 brwoser , 輸入 http://IP&Domain/svn/test1/
就可以看到剛剛匯入的 tmp
測試取出匯入檔案
$ cd /tmp/
$ mkdir checkout
$ cd checkout
$ svn co http://domain/svn/test1/tmp ( 在遠端server指令 )
or
$ svn co /home/svn/test1/tmp ( 在localhost指令 )
10. 建立用戶改為 sha 加密(htpasswd SHA 加密方法,參數:-s)
密碼文件默認加密方法:CRYPT encryption,密碼文件格式:用戶名:密碼
基於安全考慮,建議加密方法使用 SHA encryption:htpasswd -s 用戶名
刪除用戶指定行:dd
保存退出::wq
13. 創建 ssl 目錄,用于存放 ssl pem 証書文件
$ mkdir -p /etc/apache2/ssl
14. 創建 ssl 証書(svn.pem),保存到 ssl 目錄(/etc/apache2/ssl)
-days 365 証書有效時間一年,可依需求自行定義。
$ RANDFILE=/dev/random openssl req $@ -new -x509 -days 365 -nodes \
-out /etc/apache2/ssl/svn.pem \
-keyout /etc/apache2/ssl/svn.pem
15. 配置 ssl証書(svn.pem),包括國家,州(省),市,組織,姓名,E-mail地址
Generating a 1024 bit RSA private key
.......++++++
........++++++
writing new private key to '/etc/apache2/ssl/svn.pem'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:CN
State or Province Name (full name) [Some-State]:GD
Locality Name (eg, city) []:GZ
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Reistlin.com
Organizational Unit Name (eg, section) []:Reistlin.com
Common Name (eg, YOUR name) []:reistlin
Email Address []:admin@reistlin.com
17. 創建 apache2 svn ssl 設定
$ cp /etc/apache2/sites-available/default-ssl /etc/apache2/sites-available/svn
啟用 SSL Engine,並指定 /etc/apache2/ssl/svn.pem ssl-key存放的位置
並設定 apache2 日誌 svn_error.log 和 svn_access.log
$ vim /etc/apache2/sites-available/svn
<VirtualHost *:443>
SSLEngine On
SSLCertificateFile /etc/apache2/ssl/svn.pem
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/svn_error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/svn_access.log combined
</VirtualHost>
18. apache2 svn ssl 配置(a2ensite),啟動 apache2 ssl mod(a2enmod)
$ cd /etc/apache2/sites-available
$ a2ensite svn
Enabling site svn.
Run '/etc/init.d/apache2 reload' to activate new configuration!
$ a2enmod ssl
Module ssl enabled
19. 配置完成,重新 apache2
$ /etc/init.d/apache2 restart
20. 完成
參考來源:
Debian Linux Apache2 + SVN 配置
Debian Linux 架設 Subversion(SVN)
OS : ( Debian6.0.1- 6.0.3) + apache2(2.2.16)+ HTTPS/SSL + Subversion(1.6.12)
需求 : 建立程式碼版本控制服務,使用 subversion
1. 安裝 svn
svn-server 套件
$ apt-get install subversion libapache2-svn apache2
svn-client 套件
$ apt-get install subversion-tools
2. 建立 svn 目錄(/home/svn/repository),配置目錄所有者(www-data)跟 權限
$ mkdir /home/svn
$ chown www-data:www-data -R /home/svn
$ chmod 770 -R /home/svn
3. 建立 svn 用戶 admin 密碼 /etc/apache2/dav_svn.passwd
$ /usr/bin/htpasswd -c /etc/apache2/dav_svn.passwd admin
New password:
Re-type new password:
Adding password for user admin
# 建立一般用戶的帳號 密碼
$ /usr/bin/htpasswd /etc/apache2/dav_svn.passwd fifi.chen
$ cat /etc/apache2/dav_svn.passwd
admin:OlOpE5W7gXLis
user1:W7zVH8zz13KgA
user2:qQ7eb81zSZ2.g
4. 建立 svn 目錄權限配置文件:/etc/apache2/dav_svn.authz
$ vim /etc/apache2/dav_svn.authz
[groups]
admin=admin
guest=user1,user2
#新建每一個版本庫都需要再設一各權限配置
[test1:/] # 版本庫 test1 權限配置
# *= # 默認禁止所有用戶訪問
@admin=rw # admin 組有 rw 權限
user1=r # 用戶 user1 有 r 權限
[test2:/] # 版本庫 test2 權限配置
@admin=rw # admin 組有 rw 權限
user2=r # 用戶 user2 有 r 權限
5. 修訂 /etc/apache2/mods-available/dav_svn.conf
建立 svn location,指定 svn 目錄,認證方式,認證信息;
指定 dav_svn.passwd 用戶密碼配置文件路徑;
指定 dav_svn.authz 目錄權限配置文件路徑。
$ cp /etc/apache2/mods-available/dav_svn.conf /etc/apache2/mods-available/dav_svn.conf.bak
$ vim /etc/apache2/mods-available/dav_svn.conf
<Location /svn>
DAV svn
SVNParentPath /home/svn
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/dav_svn.passwd
AuthzSVNAccessFile /etc/apache2/dav_svn.authz
Require valid-user
</Location>
6. 建立 svn 版本庫(test1、test2)
$ su www-data
$ svnadmin create /home/svn/test1
$ svnadmin create /home/svn/test2
7. 重新啟動 apache2
$ su root
$ /etc/init.d/apache2 restart
8. 打開瀏覽器,輸入 http://domain/svn/test1
9. SVN Clinet 端操作
Windows下, 使用 Tortoise 來存取 版本庫
[Tortoise]
Linux 下 , 使用 svn 存取 , checkout(co)/commit(ci)/update(up).
例如 svn co http://domain/svn/test1
匯入程式檔案
$ svn import /testtmp http://IP&Domain/svn/test1/tmp
打開 brwoser , 輸入 http://IP&Domain/svn/test1/
就可以看到剛剛匯入的 tmp
測試取出匯入檔案
$ cd /tmp/
$ mkdir checkout
$ cd checkout
$ svn co http://domain/svn/test1/tmp ( 在遠端server指令 )
or
$ svn co /home/svn/test1/tmp ( 在localhost指令 )
10. 建立用戶改為 sha 加密(htpasswd SHA 加密方法,參數:-s)
密碼文件默認加密方法:CRYPT encryption,密碼文件格式:用戶名:密碼
基於安全考慮,建議加密方法使用 SHA encryption:htpasswd -s 用戶名
$ sudo /usr/bin/htpasswd -s /etc/apache2/dav_svn.passwd 用戶名
11. 刪除 svn 用戶
$ sudo vim /etc/apache2/dav_svn.passwd查找指定用戶名:/用戶名
刪除用戶指定行:dd
保存退出::wq
12. 安装 SSL 設定
$ apt-get install openssl13. 創建 ssl 目錄,用于存放 ssl pem 証書文件
$ mkdir -p /etc/apache2/ssl
14. 創建 ssl 証書(svn.pem),保存到 ssl 目錄(/etc/apache2/ssl)
-days 365 証書有效時間一年,可依需求自行定義。
$ RANDFILE=/dev/random openssl req $@ -new -x509 -days 365 -nodes \
-out /etc/apache2/ssl/svn.pem \
-keyout /etc/apache2/ssl/svn.pem
15. 配置 ssl証書(svn.pem),包括國家,州(省),市,組織,姓名,E-mail地址
Generating a 1024 bit RSA private key
.......++++++
........++++++
writing new private key to '/etc/apache2/ssl/svn.pem'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:CN
State or Province Name (full name) [Some-State]:GD
Locality Name (eg, city) []:GZ
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Reistlin.com
Organizational Unit Name (eg, section) []:Reistlin.com
Common Name (eg, YOUR name) []:reistlin
Email Address []:admin@reistlin.com
16. 証書創建完成後,請配置証書的 root 權限設定(重要!)
$ chmod 600 /etc/apache2/ssl/svn.pem
17. 創建 apache2 svn ssl 設定
$ cp /etc/apache2/sites-available/default-ssl /etc/apache2/sites-available/svn
啟用 SSL Engine,並指定 /etc/apache2/ssl/svn.pem ssl-key存放的位置
並設定 apache2 日誌 svn_error.log 和 svn_access.log
$ vim /etc/apache2/sites-available/svn
<VirtualHost *:443>
SSLEngine On
SSLCertificateFile /etc/apache2/ssl/svn.pem
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/svn_error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/svn_access.log combined
</VirtualHost>
18. apache2 svn ssl 配置(a2ensite),啟動 apache2 ssl mod(a2enmod)
$ cd /etc/apache2/sites-available
$ a2ensite svn
Enabling site svn.
Run '/etc/init.d/apache2 reload' to activate new configuration!
$ a2enmod ssl
Module ssl enabled
19. 配置完成,重新 apache2
$ /etc/init.d/apache2 restart
20. 完成
打開 brwoser , 輸入 https://IP&Domain/svn/test1/
參考來源:
Debian Linux Apache2 + SVN 配置
Debian Linux 架設 Subversion(SVN)
訂閱:
文章 (Atom)