メッセージ
Perl関係のモジュールをyumインストール
- 詳細
- カテゴリ: 初期設定
- COM_CONTENT_PUBLISHED_DATE_ON
- 作者: Super User
- 参照数: 551
Perlの各モジュールをyumコマンドを使いインストールします。
rpmforgeリポジトリ のインストール
CentOS32ビット版はx86_64のところをi386にします。
[root@localhost ~]# yum list | grep rpmforge-releas
rpmforge-release.x86_64 0.3.6-1.el5.rf installed
//インストールされていないと表示されたらインストール
[root@localhost ~]# wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.x86_64.rpm //64ビット版の場合です。36ビット版はx86_64をi386に
[root@localhost ~]# wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm
[root@localhost ~]# rpm -Uvh rpmforge-release-0.5.1-1.el5.rf.x86_64.rpm
[root@localhost ~]# rpm -Uvh rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm
基本リポジトリとのパッケージ競合を避けるため、デフォルトは無効にしておく
[root@localhost ~]# sed -i 's/enabled = 1/enabled = 0/g' /etc/yum.repos.d/rpmforge.repo
[root@localhost ~]# vi /etc/yum.repos.d/rpmforge.repo
# URL: http://rpmforge.net/
[rpmforge]
priority=1
name = Red Hat Enterprise $releasever - RPMforge.net - dag
#baseurl = http://apt.sw.be/redhat/el5/en/$basearch/dag
mirrorlist = http://apt.sw.be/redhat/el5/en/mirrors-rpmforge
#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge
enabled = 0 //1となっていたら0に変更
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
gpgcheck = 1
//rpmforge-releaseをアップデートする場合(rpmforge-releaseが既にインストールされている場合)
[root@localhost ~]# yum update rpmforge-release
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost ~]# mv rpmforge.repo rpmforge.repo.bk ;mv rpmforge.repo.rpmnew rpmforge.repo
[root@localhost ~]# yum update --enablerepo=rpmforge-extras perl-IO-Compress
※rpmforge-releaseのアップデートの場合、/etc/yum.repos.d/rpmforge.repo.rpmnewというファイルができるので、それをrpmforge.repoにリネームする必要がある。
http://server-helper.doorblog.jp/archives/3686270.htmlを参照させていただきました。
CentOSにSSL証明書を2つインストールしてみました。
- 詳細
- カテゴリ: 初期設定
- COM_CONTENT_PUBLISHED_DATE_ON
- 作者: Super User
- 参照数: 686
CentOSにSSL証明書を2つインストールしてみました。(2つのドメインにSSL証明書を当てる。)
2つ以上SSL証明書をインストールする場合、グローバルIPアドレスを追加し、IPレベルでバーチャルドメインを立てる必要がありました。
以下はその手順。
Apacheにその設定をほどこすことと、ApacheのSSL用モジュールmod_sslと、OpenSSLをCentOS5にインストールします。
[root@localhost ~]# yum -y install mod_ssl
[root@localhost ~]# yum -y install openssl
秘密鍵や証明書を保管するディレクトリを作ります。
[root@localhost ~]# cd /etc/httpd/conf
[root@localhost conf]# mkdir ./ssl.key
[root@localhost conf]# mkdir ./ssl.csr
[root@localhost conf]# mkdir ./ssl.crt
[root@localhost conf]# mkdir ./certs
[root@localhost conf]# ls //ディレクトリを確認
httpd.conf httpd.conf.backup.2009-Oct12-15:04:00 magic ssl.crt ssl.csr ssl.key
[root@localhost conf]# cd ssl.key/
[root@localhost ssl.key]# pwd //現在のディレクトリの場所を表示
/etc/httpd/conf/ssl.key
[root@localhost ssl.key]# openssl genrsa -des3 -out server.key 2048 //Key生成
Generating RSA private key, 2048 bit long modulus
........++++++
....................++++++
e is 65537 (0x10001)
Enter pass phrase for server.key: //パスワードを入力
Verifying - Enter pass phrase for server.key: //パスワード確認
[root@admin ssl.key]# chmod 400 server.key //パーミッション変更
[root@admin ssl.key]# openssl req -new -key server.key -out server.csr
Enter pass phrase for server.key:
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) [GB]:JP //国コードを入力
State or Province Name (full name) [Berkshire]:Tokyo //都道府県名を入力
Locality Name (eg, city) [Newbury]:Hachiouji //市区町村名を入力
Organization Name (eg, company) [My Company Ltd]:server-memo Corp //企業名・組織名を入力
Organizational Unit Name (eg, section) []: //部署名を入力(省略の場合ハイフォンを入力)
Common Name (eg, your name or your server's hostname) []:www.exsample.com //サーバのホスト名をFQDNで入力
Email Address []: //担当者のE-mailアドレス(省略の場合ハイフォンを入力)
※上記の内容はメモ帳などにコピペ保存(後で必要になってくる場合がある)
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []: //パスワードを入力(省略可
An optional company name []: //省略
[root@localhost ssl.key]# vi server.csr
で開いた内容をコピペして認証局に送る。
[root@localhost ssl.key]# chmod 400 server.csr //パーミッション変更
[
このメールアドレスはスパムボットから保護されています。閲覧するにはJavaScriptを有効にする必要があります。
]# mv server.csr /etc/httpd/conf/ssl.csr //ssl.csrディレクトリにファイルを移動
[root@localhost ssl.key]# openssl rsa -in server.key -out server.key //サーバー用秘密鍵からパスワード削除
Enter pass phrase for server.key: //サーバー用秘密鍵・証明書作成時のパスワード応答※表示はされない
writing RSA key
Postdix、DovecotでSMTPサーバー、POP3/IMAP4サーバ構築
- 詳細
- カテゴリ: 初期設定
- COM_CONTENT_PUBLISHED_DATE_ON
- 作者: Super User
- 参照数: 2017
メールサーバ設定 SMTPサーバ
CentOSで標準のsendmailからpostfixに変更します。
[root@localhost ~]# groupadd postfix
[root@localhost ~]# groupadd postdrop
[root@localhost ~]# useradd postfix -g postfix
[root@localhost ~]# yum install postfix
メールサーバプログラムをPostfixに切り替えます。
[root@localhost ~]# /usr/sbin/alternatives --set mta /usr/sbin/sendmail.postfix
[root@localhost ~]# /sbin/service sendmail stop 2>/dev/null >/dev/null
[root@localhost ~]# /sbin/service exim stop 2>/dev/null >/dev/null
[root@localhost ~]# /sbin/service postfix start 2>/dev/null >/dev/null
[root@localhost ~]# alternatives --config mta
There are 2 programs which provide 'mta'.
Selection Command
-----------------------------------------------
*+ 1 /usr/sbin/sendmail.sendmail
2 /usr/sbin/sendmail.postfix
Enter to keep the current selection[+], or type selection number: 2
2を入力してenterします。
/etc/postfix/main.cf ファイルを作成。
[root@localhost ~]# vi /etc/postfix/main.cf
myhostname = mail.exsample.com //FDQNで入力
mydomain = exsample.com
$myorigin = $mydomain //先頭の#を削除
mydestination=$myhostname, localhost.$mydomain, localhost, $mydomain
inet_interfaces = all //追加
#inet_interfaces = localhost //先頭に#を追加して無効化
home_mailbox = Maildir/ //追加
allow_mail_to_commands = alias,forward,include //追加(デフォルトでは記述はないがalias,fowardのみの設定。includeを追加するのはセキュリティ上問題有り。MLドライバを利用する場合設定する。)
mynetworks_style = subnet //先頭の#を削除(subnetの場合#を外さなくてもデフォルトで有効)
mynetworks = 168.100.189.0/28, 127.0.0.0/8 //先頭の#を削除して有効化
mynetworksを有効にすると、mynetworks_styleの設定は無効化される。デフォルトではsubnetは168.100.189.0/28, 127.0.0.0/8のみを送信許可にする設定
relay_domains = $mydestination //#を外して有効化
#sendmail_path = /usr/sbin/sendmail.postfix
sendmail_path = /usr/sbin/sendmail //cgiなどでメールサーバーを動かす場合のパスをsendmail.postfixからsendmailに変更
mailbox_command = /usr/libexec/dovecot/deliver //mailboxへの配送をdovecotにする。
allow_min_user = yes 先頭にハイフォンの付いたメールアドレスを許可する。
sendmailのパスを通すため、シンボリックリンクをとおします。
[root@localhost ~]# mv /usr/sbin/sendmail /usr/sbin/sendmail.bak
[root@localhost ~]# ln -s /usr/sbin/sendmail.postfix /usr/sbin/sendmail
smtpクライアント認証を有効にします。
#以下を最終行辺りに追加
smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
smtp_sasl_security_options = noanonymous
smtpd_reclient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
外部SMTPサーバーにメール中継させるには次の設定を行います。
#以下を最終行辺りに追加
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/smtp-auth-passwd
smtp_sasl_mechanism_filter = cram-md5, plain, login
#SMTPサーバ名を [ ] 内に指定
relayhost = [mail.example.com]
[root@localhost ~]# vi /etc/postfix/smtp-auth-passwd
example.jp username:password
[root@localhost ~]# postmap /etc/postfix/isp_passwd
[root@localhost ~]# ls -la /etc/postfix/isp_passwd
次の設定はIPアドレスでのメール拒否。極力ドメイン名や差出人名で拒否設定をしないと、共用サーバーなども拒否リストに入ってしまう可能性があります。
[root@localhost ~]# vi /etc/postfix/reject_client
(拒否するIPアドレス) REJECT
[root@localhost ~]# postmap /etc/postfix/reject_client
[root@localhost ~]# ls -la /etc/postfix/reject_client.db
[root@localhost ~]# service postfix restart
上記設定で個別にIP制限をかけます。
更にセキュアにするには/etc/postfix/main.cfに、
# ホスト名を知らないメールシステムを拒否。
smtpd_helo_restrictions = reject_unknown_hostname
# ホワイトリスティング: ローカルクライアントはどの配送先でも指定でき、それ以外は行わない。
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
# 送信者のドメインによる拒否
smtpd_sender_restrictions = permit_sasl_authenticated, reject_unauth_destination, reject_unknown_sender_domain, reject_non_fqdn_sender hash:/etc/postfix/reject_sender
を追加します。
そして以下で設定を反映
[root@localhost ~]# vi /etc/postfix/reject_sender
このメールアドレスはスパムボットから保護されています。閲覧するにはJavaScriptを有効にする必要があります。
REJECT //拒否するドメインやメールアドレスを入力
[root@localhost ~]# postmap /etc/postfix/reject_sender
[root@localhost ~]# ls -la /etc/postfix/reject_sender.db
[root@localhost ~]# service postfix restart
PHPインストールメモ
- 詳細
- カテゴリ: 初期設定
- COM_CONTENT_PUBLISHED_DATE_ON
- 作者: Super User
- 参照数: 650
php最新版をインストールするためにリポジドリを取得
リポジドリの取得は以下のディレクトリで取得します。
[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# wget http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
[root@localhost src]# wget http://rpms.famillecollet.com/el5.x86_64/remi-release-5-8.el5.remi.noarch.rpm
[root@localhost src]# rpm -Uvh remi-release-5*.rpm epel-release-5*.rpm
http://memorandum.yamasnet.com/archives/Post-165.htmlを参照
Centos 32ビット版はx86_64をi382に。
CentOS-Base.repoの編集
[root@localhost ~]# vi /etc/yum.repos.d/CentOS-Base.repo
--------【CentOS-Base.repo】--------
[centosplus]
...
enabled=1
...
--------
remiの編集
[root@localhost ~]# vi /etc/yum.repos.d/remi.repo
[remi]
priority=1 //各repoの優先順位の設定。とりあえず1にしておく。
name=Les RPM de remi pour Enterprise Linux 5 - $basearch
baseurl=http://rpms.famillecollet.com/el5.$basearch/
http://iut-info.univ-reims.fr/remirpms/el5.$basearch/
enabled=0 //0にしておいたほうが無難
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
failovermethod=priority
[remi-test]
name=Les RPM de remi en test pour Enterprise Linux $releasever - $basearch
baseurl=http://rpms.famillecollet.com/test-el5.$basearch/
enabled=0 //0にしておいたほうが無難
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
epelの編集
[root@localhost ~]# vi /etc/yum.repos.d/epel.repo
[epel]
priority=1 //各repoの優先順位の設定。とりあえず1にしておく。
name=Extra Packages for Enterprise Linux 5 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/5/$basearch
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=$basearch
failovermethod=priority
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
[epel-debuginfo]
priority=1 //各repoの優先順位の設定。とりあえず1にしておく。
name=Extra Packages for Enterprise Linux 5 - $basearch - Debug
#baseurl=http://download.fedoraproject.org/pub/epel/5/$basearch/debug
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-debug-5&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
gpgcheck=1
[epel-source]
priority=1 //各repoの優先順位の設定。とりあえず1にしておく。
name=Extra Packages for Enterprise Linux 5 - $basearch - Source
#baseurl=http://download.fedoraproject.org/pub/epel/5/SRPMS
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-source-5&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
gpgcheck=1
Webサーバー Apacheの設定
- 詳細
- カテゴリ: 初期設定
- COM_CONTENT_PUBLISHED_DATE_ON
- 作者: Super User
- 参照数: 1986
Apacheをダウンロード。ソースからビルドします。
[root@localhost ~]# wget http://archive.apache.org/dist/httpd/httpd-2.2.17.tar.gz
ダウンロードしたファイルが正しいものかどうか検証するには次のコマンドを実行します。
[root@localhost ~]# md5sum httpd-2.2.17.tar.gz
これがダウンロードリンクにあるmd5チェックサムと一致するかを確認します。 またはチェックサムファイルを確認します。
[root@localhost ~]# cat httpd-2.2.17.tar.gz.md5
解凍後は解凍されたディレクトリに移動します。
[root@localhost ~]# tar zxvf httpd-2.2.17.tar.gz -C /usr/local/src
[root@localhost ~]# cd /usr/local/src/httpd-2.2.17/
[root@localhost httpd-2.2.17]# ./configure --enable-ssl --enable-so --enable-module=so --enable-module=rewrite //予め各モジュールはインストールしておきます。
[root@localhost httpd-2.2.17]# make
[root@localhost httpd-2.2.17]# make install
[root@localhost httpd-2.2.17]# cd
[root@localhost ~]# cp /usr/local/src/httpd-2.2.17/build/rpm/httpd.init /etc/rc.d/init.d/httpd
[root@localhost ~]# vi /etc/rc.d/init.d/httpd
起動スクリプトを以下に修正します。
#httpd=${HTTPD-/usr/sbin/httpd}
httpd=/usr/local/apache2/bin/httpd
#pidfile=${PIDFILE-/var/log/httpd/httpd.pid}
pidfile=/usr/local/apache2/logs/httpd.pid
# CONFFILE=/etc/httpd/conf/httpd.conf
CONFFILE=/usr/local/apache2/conf/httpd.conf
[root@localhost ~]# chmod 755 /etc/rc.d/init.d/httpd
[root@localhost ~]# chkconfig --add httpd
[root@localhost ~]# chkconfig httpd on

