最終更新: triplexsys 2010年05月07日(金) 20:14:08履歴
- /root/.vimrcを作成
- 作成したファイルに以下の文面を追加する
set visualbell
- /etc/skel/.vimrcを作成
- 作成したファイルに以下の文面を追加する
set visualbell
- /etc/login.defsの最下部に以下の行を追加
SU_WHEEL_ONLY yes
- /etc/pam.d/suの以下の行のコメントを解除
auth required pam_wheel.so use_uid
- /etc/ssh/sshd_configの以下の行のコメントを解除
Port 22
PermitEmptyPasswords no
- /etc/ssh/sshd_configを編集
#PermitRootLogin yes
↓
PermitRootLogin no
#PasswordAuthentication yes
↓
PasswordAuthentication no
# UseDNS yes
↓
UseDNS no
- SSH用の鍵を入れるディレクトリを作成
# mkdir /etc/skel/.ssh
- 一般管理ユーザの作成
# useradd -g users <新規ユーザ名>
# passwd <新規ユーザ名>
// 2回繰り返してパスワードを入力
# usermod -G wheel <新規ユーザ名>
- SSHの鍵ペアを作成(Windows上で作業)
- puttygen.exe等でパスフレーズを指定して公開鍵・秘密鍵ペアを作成
- 作成した公開鍵をSCPなどでサーバにアップロード(key.pubと仮定)
- 公開鍵を使用できるようにする
# ssh-keygen -i -f ./key.pub > ./open.pub
# cat ./open.pub >> /home/<新規ユーザ名>/.ssh/authorized_keys
# rm ./key.pub
# rm ./open.pub
- サービスに関する設定
# ntsysv
- 以下のサービス以外は不要(と思われる)
anacron
auditd
cpuspeed
crond
haldaemon
iptables
irqbalance
kudzu
lvm2-monitor
messagebus
network
smartd
sshd
syslog
yum-updatesd
iptablesの設定例を参照
- ntpのインストール
# yum -y install ntp
- /etc/ntp.confを編集
server 0.rhel.pool.ntp.org
server 1.rhel.pool.ntp.org
server 2.rhel.pool.ntp.org
↓
自分のプロバイダのNTPサーバに変更
- NTPサーバを自動起動するように設定
# ntpdate ntp.nict.jp
# /etc/rc.d/init.d/ntpd start
# chkconfig ntpd on
- VirtualPCでは、時刻の誤差が大きすぎて時計合わせに失敗することがある
- cronを使って定期的に時計合わせを行う
- /usr/local/src/ntpdate-cronを作成
#!/bin/sh
/usr/sbin/ntpdate 自分のプロバイダのNTPサーバ > null
- 実行属性を付与
# chmod +x /usr/local/src/ntpdate-cron
- cronに設定
# crontab -e
*/30 * * * * /usr/local/src/ntpdate-cron > /dev/null 2>&1
- ntpdの自動起動をオフにする
# chkconfig ntpd off
- Apache実行用ユーザの作成
# mkdir /etc/skel/public_html
# useradd -g users webmaster
# passwd webmaster
// 2回繰り返してパスワードを入力
- 「クライアントPCからSSHでログインするための設定」を参考にSSHの鍵ペアを設定
- Apacheのインストール
# yum -y install httpd httpd-devel
- /etc/httpd/conf/httpd.confを編集
ServerTokens OS → ServerTokens Prod
User apache → User webmaster
Group apache → Group users
ServerAdmin root@localhost → <自分のメールアドレス>
#ServerName www.example.com:80 → ServerName <サーバのホスト名>:80
DocumentRoot "/var/www/html"
→ DocumentRoot "/home/webmaster/public_html"
<Directory "/var/www/html">
→ <Directory "/home/webmaster/public_html">
(<Directory "/home/webmaster/public_html">ディレクティブに)
Options Indexes FollowSymLinks → Options ExecCGI FollowSymLinks
AllowOverride None → AllowOverride FileInfo AuthConfig Limit Options
DirectoryIndex index.html index.html.var
→ DirectoryIndex index.php index.html index.htm
ServerSignature On → ServerSignature Off
(<Directory "/var/www/icons">ディレクティブに)
Options Indexes MultiViews → Options MultiViews
AddDefaultCharset UTF-8 → #AddDefaultCharset UTF-8
(AddTypeを設定する行の行末に追加)
AddType application/x-httpd-php .php
- Apacheの自動起動の設定
# chkconfig httpd on
- apacheユーザの削除
# userdel apache
- MySQLのインストール
# yum -y install mysql mysql-server mysql-devel
- MySQLの自動起動の設定
# chkconfig mysqld on
- /etc/my.cnfを編集
([mysqld]の項目に以下を追加)
default-character-set=utf8
skip-character-set-client-handshake
- mysqldを起動
# service mysqld start
- rootのパスワードを設定
# mysqladmin -u root password 'パスワード'
- 匿名ユーザの削除
# mysql -u root -p
Enter password:(設定したパスワードを入力してEnter)
mysql> DELETE FROM `mysql`.`user` WHERE `user` = '' OR (`user` = 'root' AND `host` != 'localhost' );
- テストDBを削除
mysql> DROP DATABASE test;
- ローカルから接続できるようにする
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.%' IDENTIFIED BY 'パスワード' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
mysql> exit;
- PostgreSQLリポジトリの追加(http://yum.pgsqlrpms.org/reporpms/repoview/letter_... からRPMのアドレスを取得)
# cd /usr/local/src/
# wget http://yum.pgsqlrpms.org/reporpms/8.4/pgdg-centos-...
# rpm -ivh pgdg-centos-8.4-1.noarch.rpm
- /etc/yum.repos.d/CentOS-Base.repo を編集
([base]セクションの最後に追加)
exclude=postgresql*
([updates]セクションの最後に追加)
exclude=postgresql*
- PostgreSQLのインストール
yum -y install postgresql postgresql-server postgresql-devel
- PostgreSQLの自動起動の設定
# chkconfig postgresql on
- データベースの初期化
# su - postgres
$ initdb -E UTF-8 --no-locale
$ exit
- パスワードを設定
# service postgresql start
# psql -U postgres
postgres=# ALTER USER postgres with encrypted password 'パスワード';
postgres=# \q
- yumを使用して必要なライブラリをインストール
# yum -y install libxml2-devel libjpeg-devel libpng-devel freetype-devel \
libmcrypt libmcrypt-devel
- PHPのソースの取得(http://www.php.net/downloads.php からソースのアドレスを取得)
# cd /usr/local/src/
# wget http://jp2.php.net/get/php-5.3.0.tar.gz/from/this/...
- PHPのインストール
# tar -zxvf ./php-5.3.0.tar.gz
# cd ./php-5.3.0/
# ./configure \
--with-apxs2 \
--with-mysql --with-mysqli --with-pdo-mysql \
--with-pgsql --with-pdo-pgsql \
--enable-mbregex --enable-mbstring \
--with-mcrypt --with-zlib --enable-zip --with-openssl \
--with-gd --with-jpeg-dir --with-png-dir \
--enable-gd-native-ttf --enable-gd-jis-conv --with-freetype-dir \
--enable-soap --enable-sqlite-utf8
# make
# make install
# make clean
# cp /usr/local/src/php-5.3.0/php.ini-production /usr/local/lib/php.ini
- /usr/local/lib/php.ini を編集
expose_php = On → expose_php = Off
- APCのインストール
- 今のところPHP5.3ではAPC3.1以上でないと動かないみたい
- 以下から、最新のバージョンを確認
- http://pecl.php.net/package/APC
# pecl install APC-3.1.3p1
(何か聞かれたら、Enter)
- /usr/local/lib/php.iniを編集
(最後に追加)
extension=apc.so
- APCが本当に入っているか確かめたい人は・・・
/usr/local/lib/php/apc.php
- ↑をアクセスできる領域に置いて、ブラウザからアクセスしてみてください
- カテゴリ:
- インターネット
- Webプログラミング
このページへのコメント
h6QGaN Thanks a lot for the article.Thanks Again. Keep writing.
AviyJD Great, thanks for sharing this article post.Thanks Again. Will read on...