[Apache] .htaccess 失效

今天發現自己的apache根目錄會顯示出來
基於安全的問題所以在根目錄丟一個.htaccess去檔顯示目錄

Options -Indexes

丟進去後
卻發現目錄依然會顯示
檢查一下http.conf
原來是AllowOverride的設定是None
改成 AllowOverride All 重新啟動Apache即可

<Directory "/usr/local/www">
    Options Indexes FollowSymLinks
    # 這裡改成All
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
Leave a comment

[FreeBSD] Twiki Install note

version:4.2.4

必要套件:Apache22、Perl5.10

安裝
cd /usr/ports/www/twiki
make install clean

 

設定各目錄訪問權限(bin與pub的設定在twiki.conf內而不使用.htaccess)
cd /usr/local/www/twiki
cp root-htaccess.txt .htaccess
cp subdir-htaccess.txt data/.htaccess
cp subdir-htaccess.txt locale/.htaccess
cp subdir-htaccess.txt templates/.htaccess
cp subdir-htaccess.txt tools/.htaccess
cp subdir-htaccess.txt working/.htaccess

 

設定twikiLibPath
cd /usr/local/www/twiki/bin
cp LocalLib.cfg.txt LocalLib.cfg //先copy example config
vi LocalLib.cfg
找到$twikiLibPath,並修改成實際路徑
$twikiLibPath = “/usr/local/www/twiki/lib”

 

 

加入/usr/local/etc/apache22/twiki.conf
ScriptAlias /twiki/bin “/usr/local/www/twiki/bin”
Alias /twiki/pub “/usr/local/www/twiki/pub”

BrowserMatchNoCase ^$ blockAccess

<Directory “/usr/local/www/twiki/bin”>
AllowOverride None
Order Allow,Deny
Allow from all
Deny from env=blockAccess

Options ExecCGI FollowSymLinks
SetHandler cgi-script

Password file for TWiki users

AuthUserFile /usr/local/www/twiki/data/.htpasswd
AuthName ‘Enter your WikiName: (First name and last name, no space, no dots, capitalized, e.g. JohnSmith)’
AuthType Basic

<FilesMatch “^configure.*”>
SetHandler cgi-script
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 192.168.1.10 <–在這裡加入自己的IP(不然進不去configure)
Require user JohnDoe
Satisfy Any
</FilesMatch>
</Directory>

<Directory “/usr/local/www/twiki/pub”>
Options None
AllowOverride Limit
Allow from all

AddType text/plain .shtml .php .php3 .phtml .phtm .pl .py .cgi
</Directory>

 

 

 

編輯http.conf,在最底下加入一行
include “etc/apache22/twiki.conf”

 

打開瀏覽器進入Configure
http://(hostname)/twiki/bin/configure

 

若噴出Error.pm,將p5-Error砍掉重裝
cd /usr/ports/lang/p5-Error
make deinstall clean
make install clean
※不知道為什麼reinstall系統會噴錯誤,所以才下兩行指令

 

這時候應該就沒有error了,可以點選next
然後設定密碼後保存
twiki/lib底下就會出現LocalSite.cfg(用來保存網站設定)

 

若{RCS}{EgrepCmd}與{RCS}{fgrepCmd}出現
Error:”/BIN/grep” does not meet the current Path.
因為FreeBSD的grep在/usr/bin底下
所以只要把/bin/grep改成/usr/bin/grep(後面的參數不動)即可

 

 

User Mapping的部分:
預射是Twiki::Users::TwikiUserMapping
如果想先試跑首頁就先改成Twiki::Users::BaseUserMapping
保存後就可進入WebHome了
網址 http://(hostname)/twiki/bin/view/Main/WebHome

 

 

 

認證:

CGI::Session Install
shell> perl -MCPAN -e shell
cpan> install CGI::Session
Reference:http://cpan.uwinnipeg.ca/htdocs/CGI-Session/INSTALL.html

 

Leave a comment

[FreeBSD] 開啟SSH遠端連線

修改 /etc/ssh/sshd_config

PermitRootLogin yes
PermitEmptyPasswords no
PasswordAuthentication yes

 

修改 /etc/inetd.conf,將以下的註解拿掉(開啟遠端登入root)

ssh stream tcp nowait root /usr/sbin/sshd sshd -i -4
ssh stream tcp6 nowait root /usr/sbin/sshd sshd -i -6

 

/etc/rc.conf 加入

sshd_enable="yes"

 

重新啟動服務

/etc/rc.d/sshd restart
Leave a comment