Home

nnpooh の :: ひとり言 ::

.htaccess で外部からの直リンク禁止

  • 2007-11-13 (火)
  • etc

禁止したいフォルダの.htaccess ファイルに以下の内容を記述すれば、([例]domain.tld)以外からのアクセスが拒否される。

SetEnvIf Referer “^http([s]?)://([a-z\.]*)domain\.tld” welcome
order deny,allow
deny from all
allow from env=welcome

最終行を改行して終了。

phpMyAdmin の設定

  • 2007-11-11 (日)
  • etc

# yum list | grep phpMyAdmin ← 確認
# yum -y install phpMyAdmin ← インストール
# vi /etc/phpMyAdmin/config.inc.php
$cfg[’blowfish_secret’] = ‘xxxxxx’; ← 適当に追加
$cfg[’Servers’][$i][’auth_type’] = ‘cookie’; ← cookie に変更
$cfg[’Servers’][$i][’user’] = ‘root’; ← ユーザー名を記述
$cfg[’Servers’][$i][’password’] = ‘xxxxxx’; ← パスワードを記述

# vi /etc/httpd/conf.d/phpMyAdmin.conf
<Directory /usr/share/phpMyAdmin/>

allow from 192.168.1 ← 追加
</Directory>

# /etc/rc.d/init.d/httpd restart

ブラウザで http://192.168.1.22/phpMyAdmin/ へアクセス。

完了。

MySQL の設定

# yum list | grep mysql ← 状況確認
# yum -y install mysql mysql-server mysql-devel ← 入ってなければインストール
# vi /etc/my.cnf
[client]
default-character-set=utf8
[mysqld]
default-character-set=utf8
[mysqldump]
default-character-set=utf8
[mysql]
default-character-set=utf8

# /etc/rc.d/init.d/mysqld start ← mysqld スタート
# mysqladmin -u root password xxxxxx ← root のパスワード設定
# /sbin/chkconfig mysqld on ← 自動起動オン
# /sbin/chkconfig –list mysqld ← 自動起動確認

PHP の設定

# yum list | grep php
# yum -y install php php-mbstring php-mysql php-pdo php-xml php-xmlrpc php-gd php-mcrypt ← 必要なものをインストール
# vi /etc/php.ini
safe_mode = Off
display_errors = Off
log_errors = On
magic_quotes_gpc = off
default_charset = “UTF-8″
date.timezone = “Asia/Tokyo”
iconv.internal_encoding = UTF-8
iconv.input_encoding = auto
iconv.output_encoding = UTF-8
session.auto_start = 0
mbstring.language = japanese
mbstring.internal_encoding = UTF-8
mbstring.http_input = auto
mbstring.http_output = UTF-8
mbstring.encoding_translation = On
mbstring.detect_order = auto
mbstring.substitute_character = none
mbstring.strict_encoding = Off
# /etc/rc.d/init.d/httpd restart ← 再起動
# exit
$ vi /var/www/html/info.php ← <?php phpinfo(); を記述してテスト
$ rm -f /var/www/html/info.php ← テストページを削除

ウェブサーバーの設定

  • 2007-11-10 (土)
  • etc

# vi /etc/httpd/conf/httpd.conf
ServerTokens Prod ← 変更
ServerAdmin webadmin@local.domain.tld ← 変更
ServerName domain.tld:80 ← 変更
UseCanonicalName On ← 変更 ( 末尾 “/” の自動補完 )
<Directory “/var/www/html”>
Options Includes ExecCGI FollowSymLinks ← CGI,SSI許可に変更
AllowOverride All ← .htaccessの許可に変更
</Directory>
ServerSignature Off ← 変更
LanguagePriority ja… ← ja を先頭にする。
#AddDefaultCharset UTF-8 ← コメントアウト
AddHandler cgi-script .cgi .pl ← 変更

# ln -s /usr/bin/perl /usr/local/bin/perl ← Perlのシンボリックリンク
# whereis perl ← 確認
# chown xxxxxx. /var/www/ ← 所有者を変更
# ll /var/ ← 所有者を確認
# /etc/rc.d/init.d/httpd start← httpd スタート
# /sbin/chkconfig httpd on ← 自動起動オン
# /sbin/chkconfig –list httpd ← 確認
# rm -f /etc/httpd/conf.d/welcome.conf ← welcomeページを削除
# rm -f /var/www/error/noindex.html ← noindexページを削除
# exit
$ vi /var/www/html/index.html ← テストページを作成してブラウザで確認
$ rm -f /var/www/html/index.html ← テストページを削除

Home

Links
Search
Feeds

Page Top