Triplex Systemsの開発メモです。開発の手順・開発に関するTipsをまとめます。

ホスト名の設定

  • メールサーバを立てる時に必要?
  • /etc/sysconfig/network に以下の行を追加
HOSTNAME=<逆引きできるホスト名>
  • 一時的にホスト名を設定
# hostname <逆引きできるホスト名>

コンソールのベルを鳴らないようにする

  • /etc/inputrcの以下の行をコメントアウト
set bell-style none

viのベルを鳴らないようにする

  • /root/.vimrcを作成
  • 作成したファイルに以下の文面を追加する
set visualbell
  • /etc/skel/.vimrcを作成
  • 作成したファイルに以下の文面を追加する
set visualbell

suコマンドを実行可能なユーザグループをwheelに限定

  • /etc/login.defsの最下部に以下の行を追加
SU_WHEEL_ONLY yes
  • /etc/pam.d/suの以下の行のコメントを解除
auth required pam_wheel.so use_uid

SSHをセキュアに使う

  • /etc/ssh/sshd_configの以下の行のコメントを解除
Port 22
PermitEmptyPasswords no
  • /etc/ssh/sshd_configを編集
#PermitRootLogin yes
 ↓
PermitRootLogin no
# UseDNS yes

UseDNS no
#PasswordAuthentication yes
 ↓
PasswordAuthentication no

  • SSH用の鍵を入れるディレクトリを作成
# mkdir /etc/skel/.ssh

クライアントPCから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
atd
auditd
cpuspeed
crond
haldaemon
iptables
irqbalance
kudzu
lvm2-monitor
messagebus
network
portmap
smartd
sshd
syslog
yum-updatesd
  • Virtual Machine Additions for Linuxをインストールした場合、vmadd、vmadd-timesyncも

SELinuxの無効化

  • /etc/sysconfig/selinuxを編集
SELINUX=enforcing
 ↓
SELINUX=disabled

iptablesの設定

システムのアップデート

  • yumを使用してシステムのアップデートを行う
# yum -y update

NTPサーバのインストール

  • Virtual Machine Additions for Linuxをインストールした場合、不要かも
  • 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

Apacheのインストール

  • 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

リポジトリのインストール

# cd /usr/local/src/
# wget http://download.fedora.redhat.com/pub/epel/5/i386/...
# wget http://rpms.famillecollet.com/enterprise/remi-rele...
# rpm -Uvh remi-release-5*.rpm epel-release-5*.rpm

MySQLのインストール

# yum -y --enablerepo=epel,remi install mysql-5.1.53 mysql-server-5.1.53 mysql-devel-5.1.53
  • 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のインストール

# cd /usr/local/src/
# wget http://yum.pgsqlrpms.org/reporpms/8.4/pgdg-centos-...
# rpm -ivh pgdg-centos-8.4-2.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

PHPのインストール

  • yumを使用して必要なライブラリをインストール
# yum -y install libxml2-devel libjpeg-devel libpng-devel freetype-devel \
libmcrypt libmcrypt-devel
# cd /usr/local/src/
# wget http://jp2.php.net/get/php-5.3.3.tar.gz/from/this/...
  • PHPのインストール
# tar -zxvf ./php-5.3.3.tar.gz
# cd ./php-5.3.3/
# ./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.3/php.ini-production /usr/local/lib/php.ini
  • /usr/local/lib/php.ini を編集
expose_php = On → expose_php = Off

APCのインストール

  • APCのインストール
  • 今のところPHP5.3ではAPC3.1以上でないと動かないみたい
  • 以下から、最新のバージョンを確認
  • http://pecl.php.net/package/APC
# pecl install APC-3.1.4
(何か聞かれたら、Enter)
  • /usr/local/lib/php.iniを編集
(最後に追加)
extension=apc.so
  • APCが本当に入っているか確かめたい人は・・・
/usr/local/lib/php/apc.php
  • ↑をアクセスできる領域に置いて、ブラウザからアクセスしてみてください

このページへのコメント

vpDd5m Say, you got a nice blog article.Much thanks again. Will read on...

0
Posted by seo thing 2013年12月19日(木) 20:41:10 返信

コメントをかく


「http://」を含む投稿は禁止されています。

利用規約をご確認のうえご記入下さい

Wiki内検索

管理人/副管理人のみ編集できます