ふつーに尊敬しました。
2009年12月13日
2008年12月10日
2008年10月30日
PHP5インストール
PHP5をソースからインストール。
PHPのインストールと実行に必要な、Flex と libxml2をインストール。
# yum -y install flex libxml2-devel
このとき zlib もインストールされている。
※flexとは
字句解析器を自動生成する機能を提供します。
※libxml2とは
GNOME2などで採用されているXMLを扱うための基本ライブラリ。
GDライブラリを有効にするために zlib と libpng をインストール。
# yum -y install libpng-devel
yumでlibxml2をインストールしたので、zlibはインスコ済み。
※zlibとは
zipやgzip、画像フォーマットPNGに使われている圧縮アルゴリズムをライブラリ化したもの。
※libpngとは
PNG形式の画像を処理するライブラリ。
GDでJPEGを扱う場合はJPEG画像ライブラリである libjpeg が必要。
libjpegはインスコ済。
※libjpegとは
JPEG形式の画像を処理するライブラリ。
PHPのソースをDL。
# wget -P /usr/local/src http://jp2.php.net/get/php-5.2.8.tar.gz/from/jp.php.net/mirror
インストール先のディレクトリを作成。
# mkdir /usr/local/php-5.2.8
# cd /usr/local/src
# tar xzf php-5.2.8.tar.gz
tarする。
# cd php-5.2.8
# ./configure --prefix=/usr/local/php-5.2.8 --enable-mbstring --with-apxs2=/usr/local/httpd/bin/apxs --with-pgsql=/usr/local/pgsql --with-mysql=/usr/local/mysql --with-gd --with-zlib --with-jpeg-dir
configureする。
# make > make_php.log 2>&1
makeログを残す。
# make install > make_install_php.log 2>&1
installログを残す。
# ln -sfn /usr/local/php-5.2.8 /usr/local/php
シボリックリンク作成。
PHP設定ファイルの雛形がソースファイルに含まれているので、
それを/php/lib/にコピー。
# cp /usr/local/src/php-5.2.8/php.ini-dist /usr/local/php/lib/php.ini
php.iniを編集。
# emacs /usr/local/php/lib/php.ini
-----------------------------------------------------------
allow_call_time_pass_reference = Off(L164)
引数の参照渡しを禁止
open_basedir = /virtual:/tmp(L205)
PHPスクリプトを動作させるディレクトリを制限
expose_php = Off(L248)
HTTPヘッダーのPHP に関する情報を隠蔽
error_reporting =E_ALL(L306)
全てのエラー情報を取得
display_errors = Off(L323)
エラーをブラウザに表示しない
log_errors = On(L333)
エラーログを出力
error_log = /var/log/php.log(L384)
エラーログを出力するファイルを指定
default_charset = “UTF-8"(L465)
デフォルトの文字コードを設定
-----------------------------------------------------------
Apacheの設定ファイルにPHPのファイルタイプ追加は設定済み。
※Webサーバ構築(Apache) 参照
#emacs /var/www/html/info.php
-----------------------------------------------------------
-----------------------------------------------------------
ブラウザを使ってアクセスし、内容が表示されていることを確認。
(!)
URLをたたくと、「次のファイルを開こうとしています。」が立ち上がって、
ファイルをプログラムで開くか、保存するの選択になってしまう。
前も同じような現象あったけど、どうやって解決したか忘れたので、
模索中・・・
httpd.confの「AddType application/x-httpd-php .php」は
追加してあるし、「LoadModule php5_module modules/libphp5.so」
も追記されてある。
PHPのインストールと実行に必要な、Flex と libxml2をインストール。
# yum -y install flex libxml2-devel
このとき zlib もインストールされている。
※flexとは
字句解析器を自動生成する機能を提供します。
※libxml2とは
GNOME2などで採用されているXMLを扱うための基本ライブラリ。
GDライブラリを有効にするために zlib と libpng をインストール。
# yum -y install libpng-devel
yumでlibxml2をインストールしたので、zlibはインスコ済み。
※zlibとは
zipやgzip、画像フォーマットPNGに使われている圧縮アルゴリズムをライブラリ化したもの。
※libpngとは
PNG形式の画像を処理するライブラリ。
GDでJPEGを扱う場合はJPEG画像ライブラリである libjpeg が必要。
libjpegはインスコ済。
※libjpegとは
JPEG形式の画像を処理するライブラリ。
PHPのソースをDL。
# wget -P /usr/local/src http://jp2.php.net/get/php-5.2.8.tar.gz/from/jp.php.net/mirror
インストール先のディレクトリを作成。
# mkdir /usr/local/php-5.2.8
# cd /usr/local/src
# tar xzf php-5.2.8.tar.gz
tarする。
# cd php-5.2.8
# ./configure --prefix=/usr/local/php-5.2.8 --enable-mbstring --with-apxs2=/usr/local/httpd/bin/apxs --with-pgsql=/usr/local/pgsql --with-mysql=/usr/local/mysql --with-gd --with-zlib --with-jpeg-dir
configureする。
# make > make_php.log 2>&1
makeログを残す。
# make install > make_install_php.log 2>&1
installログを残す。
# ln -sfn /usr/local/php-5.2.8 /usr/local/php
シボリックリンク作成。
PHP設定ファイルの雛形がソースファイルに含まれているので、
それを/php/lib/にコピー。
# cp /usr/local/src/php-5.2.8/php.ini-dist /usr/local/php/lib/php.ini
php.iniを編集。
# emacs /usr/local/php/lib/php.ini
-----------------------------------------------------------
allow_call_time_pass_reference = Off(L164)
引数の参照渡しを禁止
open_basedir = /virtual:/tmp(L205)
PHPスクリプトを動作させるディレクトリを制限
expose_php = Off(L248)
HTTPヘッダーのPHP に関する情報を隠蔽
error_reporting =E_ALL(L306)
全てのエラー情報を取得
display_errors = Off(L323)
エラーをブラウザに表示しない
log_errors = On(L333)
エラーログを出力
error_log = /var/log/php.log(L384)
エラーログを出力するファイルを指定
default_charset = “UTF-8"(L465)
デフォルトの文字コードを設定
-----------------------------------------------------------
Apacheの設定ファイルにPHPのファイルタイプ追加は設定済み。
※Webサーバ構築(Apache) 参照
#emacs /var/www/html/info.php
-----------------------------------------------------------
-----------------------------------------------------------
ブラウザを使ってアクセスし、内容が表示されていることを確認。
(!)
URLをたたくと、「次のファイルを開こうとしています。」が立ち上がって、
ファイルをプログラムで開くか、保存するの選択になってしまう。
前も同じような現象あったけど、どうやって解決したか忘れたので、
模索中・・・
httpd.confの「AddType application/x-httpd-php .php」は
追加してあるし、「LoadModule php5_module modules/libphp5.so」
も追記されてある。
2008年10月25日
PostgreSQLインストール
PostgreSQLをソースからインストール。
インストールと実行にroot以外のユーザが必要なのでユーザpostgresを作成。
# groupadd postgres
# useradd -g postgres postgres
# passwd postgres
PostgreSQL のインストールと実行に必要な、readlineをインストール。
# yum -y install readline-devel
※Readlineとは
CUIのアプリケーションにおいて快適な行編集や履歴機能を提供するライブラリ。
ncursesとzlibも必要だが、すでにインストール済み。
PostgreSQLのソースをDL。
# wget -P /usr/local/src http://wwwmaster.postgresql.org/redir?http%3A%2F%2Fftp2.jp.postgresql.org%2Fpub%2Fpostgresql%2Fsource%2Fv8.3.4%2Fpostgresql-8.3.4.tar.gz
インストール先のディレクトリを作成して、ディレクトリの所有者をpostgresにしておく。
# mkdir /usr/local/postgresql-8.3.4
# chown postgres:postgres /usr/local/postgresql-8.3.4
# cd /usr/local/src
# tar zxf postgresql-8.3.4.tar.gz
tarする。
# chown -R postgres:postgres postgresql-8.3.4.tar.gz
tarしたpostgresの所有者をpostgresに。
# su - postgres
ユーザpostgresになる。
$ cd /usr/local/src/postgresql-8.3.4
$ ./configure --prefix=/usr/local/postgresql-8.3.4
configureする。
$ make > make_pgsql.log 2>&1
makeログを残す。
$ make install > make_install_pgsql.log 2>&1
installログを残す。
$ exit
# ln -sfn /usr/local/postgresql-8.3.4 /usr/local/pgsql
シンボリックリンク作成。
作業しやすいようpostgresユーザの環境変数を設定しておく。
# emacs /home/postgres/.bash_profile
----------------------------------------------------
export PGDATA=/usr/local/pgsql/data ←追加
PATH=/usr/local/pgsql/bin:$PATH ←追加
----------------------------------------------------
共有ライブラリへ登録。
# emacs /etc/ld.so.conf
----------------------------------------------------
/usr/local/pgsql/lib ←追加
----------------------------------------------------
共有ライブラリの読込先である上記ファイルの変更内容を反映させる。
# /sbin/ldconfig
データーベースの初期化。
# su - postgres
$ initdb -E UNICODE --no-locale
$ exit
※-E UNICODE
デフォルトのデーターベースの文字コードを指定。
※--no-locale
データーベースで日本語を使用する場合は指定しておく。
設定ファイルの編集。
# emacs /usr/local/pgsql/data/postgresql.conf
----------------------------------------------------
# - Connection Settings -
listen_addresses = ’*’
----------------------------------------------------
TCP接続を許可する。
# emacs /usr/local/pgsql/data/pg_hba.conf
----------------------------------------------------
# md5 local connections:
host all all 192.168.0.0/24 md5 ←追加
----------------------------------------------------
LocalNetworkからのmd5認証接続を許可する。
# su - postgres
$ pg_ctl start
postgresqlの起動。
※emacsのci・co後にpostgresql.confとpg_hba.confの所有者に注意。
$ pg_ctl status
起動の確認。
$ pg_ctl stop
postgresqlの停止。
PostgreSQLの自動起動スクリプト設定。
# install -o root -g root -m 755 /usr/local/src/postgresql-8.3.4/contrib/start-scripts/linux /etc/rc.d/init.d/pgsql
# chkconfig --add pgsql
# /etc/rc.d/init.d/pgsql start
# su - postgres
$ psql -c "alter user postgres with password '***************'"
PostgreSQLの管理ユーザのパスワードを設定。
$ createuser -P ryuji
ユーザー ryuji の追加。
$ psql -c "select usename from pg_user"
ユーザを確認。
# emacs /etc/bashrc
----------------------------------------------------
PATH=/usr/local/pgsql/bin ←追加
----------------------------------------------------
postgresqlのPATHを追加。
インストールと実行にroot以外のユーザが必要なのでユーザpostgresを作成。
# groupadd postgres
# useradd -g postgres postgres
# passwd postgres
PostgreSQL のインストールと実行に必要な、readlineをインストール。
# yum -y install readline-devel
※Readlineとは
CUIのアプリケーションにおいて快適な行編集や履歴機能を提供するライブラリ。
ncursesとzlibも必要だが、すでにインストール済み。
PostgreSQLのソースをDL。
# wget -P /usr/local/src http://wwwmaster.postgresql.org/redir?http%3A%2F%2Fftp2.jp.postgresql.org%2Fpub%2Fpostgresql%2Fsource%2Fv8.3.4%2Fpostgresql-8.3.4.tar.gz
インストール先のディレクトリを作成して、ディレクトリの所有者をpostgresにしておく。
# mkdir /usr/local/postgresql-8.3.4
# chown postgres:postgres /usr/local/postgresql-8.3.4
# cd /usr/local/src
# tar zxf postgresql-8.3.4.tar.gz
tarする。
# chown -R postgres:postgres postgresql-8.3.4.tar.gz
tarしたpostgresの所有者をpostgresに。
# su - postgres
ユーザpostgresになる。
$ cd /usr/local/src/postgresql-8.3.4
$ ./configure --prefix=/usr/local/postgresql-8.3.4
configureする。
$ make > make_pgsql.log 2>&1
makeログを残す。
$ make install > make_install_pgsql.log 2>&1
installログを残す。
$ exit
# ln -sfn /usr/local/postgresql-8.3.4 /usr/local/pgsql
シンボリックリンク作成。
作業しやすいようpostgresユーザの環境変数を設定しておく。
# emacs /home/postgres/.bash_profile
----------------------------------------------------
export PGDATA=/usr/local/pgsql/data ←追加
PATH=/usr/local/pgsql/bin:$PATH ←追加
----------------------------------------------------
共有ライブラリへ登録。
# emacs /etc/ld.so.conf
----------------------------------------------------
/usr/local/pgsql/lib ←追加
----------------------------------------------------
共有ライブラリの読込先である上記ファイルの変更内容を反映させる。
# /sbin/ldconfig
データーベースの初期化。
# su - postgres
$ initdb -E UNICODE --no-locale
$ exit
※-E UNICODE
デフォルトのデーターベースの文字コードを指定。
※--no-locale
データーベースで日本語を使用する場合は指定しておく。
設定ファイルの編集。
# emacs /usr/local/pgsql/data/postgresql.conf
----------------------------------------------------
# - Connection Settings -
listen_addresses = ’*’
----------------------------------------------------
TCP接続を許可する。
# emacs /usr/local/pgsql/data/pg_hba.conf
----------------------------------------------------
# md5 local connections:
host all all 192.168.0.0/24 md5 ←追加
----------------------------------------------------
LocalNetworkからのmd5認証接続を許可する。
# su - postgres
$ pg_ctl start
postgresqlの起動。
※emacsのci・co後にpostgresql.confとpg_hba.confの所有者に注意。
$ pg_ctl status
起動の確認。
$ pg_ctl stop
postgresqlの停止。
PostgreSQLの自動起動スクリプト設定。
# install -o root -g root -m 755 /usr/local/src/postgresql-8.3.4/contrib/start-scripts/linux /etc/rc.d/init.d/pgsql
# chkconfig --add pgsql
# /etc/rc.d/init.d/pgsql start
# su - postgres
$ psql -c "alter user postgres with password '***************'"
PostgreSQLの管理ユーザのパスワードを設定。
$ createuser -P ryuji
ユーザー ryuji の追加。
$ psql -c "select usename from pg_user"
ユーザを確認。
# emacs /etc/bashrc
----------------------------------------------------
PATH=/usr/local/pgsql/bin ←追加
----------------------------------------------------
postgresqlのPATHを追加。
2008年10月22日
MySQLインストール
MySQLをソースからインストール。
MySQLをユーザー権限で実行するため、実行ユーザー「MySQL」を作成。
# groupadd mysql
# useradd -g mysql mysql
# passwd mysql
MySQLのインストールと実行に必要な、ncurses をインストール。
# yum -y install ncurses-devel
※ncursesとは
ファンクションキーの割り当てやスクリーン表示、オーバーラップしない複数のウィンドウの作成などを、テキストベースのターミナル上で行うためのライブラリ。
MySQLのソースを公式からDL。
# wget -P /usr/local/src http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-5.0.67.tar.gz/from/http://ftp.iij.ad.jp/pub/db/mysql/
インストール先のディレクトリを作成しておく。
# mkdir /usr/local/mysql-5.0.67
# cd /usr/local/src
# tar zxf mysql-5.0.67.tar.gz
tarする。
# cd mysql-5.0.67
# ./configure --prefix=/usr/local/mysql-5.0.67 --with-charset=utf8 --with-extra-charsets=all --with-mysqld-user=mysql
configureする。
# make > make_make_mysql.log 2>&1
makeログを残す。
# make install > make_install_mysql.log 2>&1
installログを残す。
# ln -sfn /usr/local/mysql-5.0.67 /usr/local/mysql
シンボリックリンク作成。
# /usr/local/mysql/bin/mysql_install_db --user=mysql
MySQLの権限テーブルを作成。
# cp /usr/local/mysql/share/mysql/my-medium.cnf /usr/local/mysql
MySQLの設定ファイルを作成。
# chown -R root /usr/local/mysql-5.0.67
# chown -R mysql /usr/local/mysql-5.0.67/var
# chgrp -R mysql /usr/local/mysql-5.0.67
ディレクトリの所有者&グループ変更。
# /usr/local/mysql/bin/mysqld_safe --user=mysql &
mysqld_safeで起動。
# /usr/local/mysql/bin/mysqladmin version
稼動確認。
-----------------------------------------------------------------------
/usr/local/mysql/bin/mysqladmin Ver 8.41 Distrib 5.0.67, for redhat-linux-gnu on i686Copyright (C) 2000-2006 MySQL AB
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license
Server version 5.0.67
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /tmp/mysql.sock
Uptime: 1 min 12 sec
-----------------------------------------------------------------------
# /usr/local/mysql/bin/mysqladmin -u root shutdown
MySQL停止。
MySQLの自動起動スクリプト設定。
# install -o root -g root -m 755 /usr/local/mysql/share/mysql/mysql.server /etc/rc.d/init.d/mysql
# chkconfig --add mysql
# /etc/rc.d/init.d/mysql start
# /usr/local/mysql/bin/mysqladmin -u root password '**********'
MySQLのrootユーザのパスワードを設定。
# /usr/local/mysql/bin/mysql -u root -p
Enter password: **********
ログインしてみる。
mysql> GRANT ALL PRIVILEGES ON *.* TO ryuji@localhost IDENTIFIED BY '**********' WITH GRANT OPTION;
mysql> SELECT host, user FROM mysql.user;
ユーザー ryuji の追加。
# emacs /etc/bashrc
---------------------------------------------------------
PATH=/usr/local/mysql/bin ←追加
---------------------------------------------------------
mysqlのPATHを追加。
MySQLをユーザー権限で実行するため、実行ユーザー「MySQL」を作成。
# groupadd mysql
# useradd -g mysql mysql
# passwd mysql
MySQLのインストールと実行に必要な、ncurses をインストール。
# yum -y install ncurses-devel
※ncursesとは
ファンクションキーの割り当てやスクリーン表示、オーバーラップしない複数のウィンドウの作成などを、テキストベースのターミナル上で行うためのライブラリ。
MySQLのソースを公式からDL。
# wget -P /usr/local/src http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-5.0.67.tar.gz/from/http://ftp.iij.ad.jp/pub/db/mysql/
インストール先のディレクトリを作成しておく。
# mkdir /usr/local/mysql-5.0.67
# cd /usr/local/src
# tar zxf mysql-5.0.67.tar.gz
tarする。
# cd mysql-5.0.67
# ./configure --prefix=/usr/local/mysql-5.0.67 --with-charset=utf8 --with-extra-charsets=all --with-mysqld-user=mysql
configureする。
# make > make_make_mysql.log 2>&1
makeログを残す。
# make install > make_install_mysql.log 2>&1
installログを残す。
# ln -sfn /usr/local/mysql-5.0.67 /usr/local/mysql
シンボリックリンク作成。
# /usr/local/mysql/bin/mysql_install_db --user=mysql
MySQLの権限テーブルを作成。
# cp /usr/local/mysql/share/mysql/my-medium.cnf /usr/local/mysql
MySQLの設定ファイルを作成。
# chown -R root /usr/local/mysql-5.0.67
# chown -R mysql /usr/local/mysql-5.0.67/var
# chgrp -R mysql /usr/local/mysql-5.0.67
ディレクトリの所有者&グループ変更。
# /usr/local/mysql/bin/mysqld_safe --user=mysql &
mysqld_safeで起動。
# /usr/local/mysql/bin/mysqladmin version
稼動確認。
-----------------------------------------------------------------------
/usr/local/mysql/bin/mysqladmin Ver 8.41 Distrib 5.0.67, for redhat-linux-gnu on i686Copyright (C) 2000-2006 MySQL AB
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license
Server version 5.0.67
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /tmp/mysql.sock
Uptime: 1 min 12 sec
-----------------------------------------------------------------------
# /usr/local/mysql/bin/mysqladmin -u root shutdown
MySQL停止。
MySQLの自動起動スクリプト設定。
# install -o root -g root -m 755 /usr/local/mysql/share/mysql/mysql.server /etc/rc.d/init.d/mysql
# chkconfig --add mysql
# /etc/rc.d/init.d/mysql start
# /usr/local/mysql/bin/mysqladmin -u root password '**********'
MySQLのrootユーザのパスワードを設定。
# /usr/local/mysql/bin/mysql -u root -p
Enter password: **********
ログインしてみる。
mysql> GRANT ALL PRIVILEGES ON *.* TO ryuji@localhost IDENTIFIED BY '**********' WITH GRANT OPTION;
mysql> SELECT host, user FROM mysql.user;
ユーザー ryuji の追加。
# emacs /etc/bashrc
---------------------------------------------------------
PATH=/usr/local/mysql/bin ←追加
---------------------------------------------------------
mysqlのPATHを追加。
2008年10月17日
HTTP暗号化
ApacheでSSL通信を行うため、
CSRファイル(サーバーの証明書発行の署名要求)や
秘密鍵、証明書やらなんやらを用意。
# mkdir /usr/local/httpd/conf/ssl.csr
# mkdir /usr/local/httpd/conf/ssl.key
# mkdir /usr/local/httpd/conf/ssl.crt
各ディレクトリを作成。
# openssl req -new -nodes -keyout /usr/local/httpd/conf/ssl.key/server.key -out /usr/local/httpd/conf/ssl.csr/server.csr
CSRと秘密鍵を作成。
入力を求められるので、上から順番に
[GB]:JP(国名)
[Berkshire]:Hiroshima(都道府県)
[Newbury]:Hiroshima(市町村)
[My Company Ltd]:hoge(会社名)
[]:hogehoge(部署)
[]:***.***.**(サーバー入れた)
[]:
[]:
[]:
最後の三つは .(ドット)を入れた。
# openssl x509 -in /usr/local/httpd/conf/ssl.csr/server.csr -out /usr/local/httpd/conf/ssl.crt/server.crt -req -signkey /usr/local/httpd/conf/ssl.key/server.key -days 3650
自己証明書を作成。
ここからApacheの設定。
# emacs /usr/local/httpd/conf/httpd.conf
-------------------------------------------------------
# Secure (SSL/TLS) connections
Include conf/extra/httpd-ssl.conf
コメントアウトを削除。
-------------------------------------------------------
続いて httpd/conf/extra/にある httpd-ssl.conf を編集。
# emacs /usr/local/httpd/conf/extra/httpd-ssl.conf
-------------------------------------------------------
DocumentRoot "/var/www/html"
ServerName ***.**.**.**:443
ServerAdmin ***@**.**.**
ErrorLog "/var/log/httpd/ssl_error_log"
TransferLog "/var/log/httpd/ssl_access_log"
#SLCertificateFile /usr/local/httpd-2.2.9/conf/server.crt
この行をコメントアウトして、
#SSLCertificateFile /usr/local/httpd-2.2.9/conf/server-dsa.crt
SSLCertificateFile /usr/local/httpd/conf/ssl.crt/server.crt
この行を追加。
#SSLCertificateKeyFile /usr/local/httpd-2.2.9/conf/server.key
この行をコメントアウトして、
#SSLCertificateKeyFile /usr/local/httpd-2.2.9/conf/server-dsa.key
SSLCertificateKeyFile /usr/local/httpd/conf/ssl.key/server.key
この行を追加。
--------------------------------------------------------
Apacheの設定ファイルをいじくったわけで、再起動。
/usr/local/httpd/bin/apachectl graceful
URLの"http"を"https"にして接続してみる。
無事表示されることを確認。
CSRファイル(サーバーの証明書発行の署名要求)や
秘密鍵、証明書やらなんやらを用意。
# mkdir /usr/local/httpd/conf/ssl.csr
# mkdir /usr/local/httpd/conf/ssl.key
# mkdir /usr/local/httpd/conf/ssl.crt
各ディレクトリを作成。
# openssl req -new -nodes -keyout /usr/local/httpd/conf/ssl.key/server.key -out /usr/local/httpd/conf/ssl.csr/server.csr
CSRと秘密鍵を作成。
入力を求められるので、上から順番に
[GB]:JP(国名)
[Berkshire]:Hiroshima(都道府県)
[Newbury]:Hiroshima(市町村)
[My Company Ltd]:hoge(会社名)
[]:hogehoge(部署)
[]:***.***.**(サーバー入れた)
[]:
[]:
[]:
最後の三つは .(ドット)を入れた。
# openssl x509 -in /usr/local/httpd/conf/ssl.csr/server.csr -out /usr/local/httpd/conf/ssl.crt/server.crt -req -signkey /usr/local/httpd/conf/ssl.key/server.key -days 3650
自己証明書を作成。
ここからApacheの設定。
# emacs /usr/local/httpd/conf/httpd.conf
-------------------------------------------------------
# Secure (SSL/TLS) connections
Include conf/extra/httpd-ssl.conf
コメントアウトを削除。
-------------------------------------------------------
続いて httpd/conf/extra/にある httpd-ssl.conf を編集。
# emacs /usr/local/httpd/conf/extra/httpd-ssl.conf
-------------------------------------------------------
DocumentRoot "/var/www/html"
ServerName ***.**.**.**:443
ServerAdmin ***@**.**.**
ErrorLog "/var/log/httpd/ssl_error_log"
TransferLog "/var/log/httpd/ssl_access_log"
#SLCertificateFile /usr/local/httpd-2.2.9/conf/server.crt
この行をコメントアウトして、
#SSLCertificateFile /usr/local/httpd-2.2.9/conf/server-dsa.crt
SSLCertificateFile /usr/local/httpd/conf/ssl.crt/server.crt
この行を追加。
#SSLCertificateKeyFile /usr/local/httpd-2.2.9/conf/server.key
この行をコメントアウトして、
#SSLCertificateKeyFile /usr/local/httpd-2.2.9/conf/server-dsa.key
SSLCertificateKeyFile /usr/local/httpd/conf/ssl.key/server.key
この行を追加。
--------------------------------------------------------
Apacheの設定ファイルをいじくったわけで、再起動。
/usr/local/httpd/bin/apachectl graceful
URLの"http"を"https"にして接続してみる。
無事表示されることを確認。
2008年10月16日
24 season6
2008年10月15日
Webサーバ構築(Apache)
Apacheをソースからインストールする。
mod_sslを有効にするため、openssl-develをインストール。
# yum -y install openssl-devel
まずはApacheをダウンロード。
# wget -P /usr/local/src http://www.meisei-u.ac.jp/mirror/apache/dist/httpd/httpd-2.2.9.tar.gz
バージョンは2.2.9。
インストール先のディレクトリを作成しておく。
# mkdir /usr/local/httpd-2.2.9
# cd /usr/local/src
# tar zxf httpd-2.2.9.tar.gz
tarする。
# cd httpd-2.2.9
# ./configure --prefix=/usr/local/httpd-2.2.9 --enable-mods-shared=all --enable-ssl=shared
configure
allでconfigureしたけど、sslはallに含まれないとかってのを見たことがあるので
指定してみた。違っていたら教えてください。
# make > make_httpd.log 2>&1
makeログを残す。
# make install > make_install_httpd.log 2>&1
installログを残す。
# ln -sfn /usr/local/httpd-2.2.9 /usr/local/httpd
シンボリックリンク作成。
# groupadd apache
# useradd -g apache apache
# mkdir /var/www/ /var/www/html
# mkdir /var/log/httpd ←ログ用
# chown apache:apache /var/www/html
apache君を作成。
# emacs /usr/local/httpd/conf/httpd.conf
-----------------------------------------------------------
User apache(L116)
Group apache
ServerAdmin xxxxxx@xx.xx.xx(L139)
ServerName xx.xx.xx:80(L148)
DocumentRoot "/var/www/html"(L155)
(L182)
AllowOverride All(L202)
DirectoryIndex index.html index.php(L217)
ErrorLog "/var/log/httpd/error_log"(L237)
CustomLog "/var/log/httpd/access_log" common(L266)
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"(L302)
(L318)
AddType application/x-httpd-php .php(L360)追加
※後にPHPをインストールするので。
AddHandler cgi-script .cgi .pl(L370)
# User home directories
Include conf/extra/httpd-userdir.conf(L434)
-----------------------------------------------------------
変更点のみ抜粋。(Lは行数)
# /usr/local/httpd/bin/apachectl configtest
Syntax OK
# /usr/local/httpd/bin/apachectl start
apache起動。
#emacs /var/www/html/index.html
ブラウザを使ってアクセスし、内容が表示されていることを確認。
# /usr/local/httpd/bin/apachectl stop
apache停止。
# sed -e 's/^# chkconfig:.*/# chkconfig: 2345 85 15/' -e 's/\/etc\/httpd/\/usr\/local\/httpd/' -e 's/\/usr\/sbin/\/usr\/local\/httpd\/bin/' /usr/local/src/httpd-2.2.9/build/rpm/httpd.init > /etc/rc.d/init.d/httpd
自動起動スクリプト。
# chmod 755 /etc/rc.d/init.d/httpd
# chkconfig --add httpd
# /etc/rc.d/init.d/httpd start
実行権限を与えて自動起動設定し起動。
mod_sslを有効にするため、openssl-develをインストール。
# yum -y install openssl-devel
まずはApacheをダウンロード。
# wget -P /usr/local/src http://www.meisei-u.ac.jp/mirror/apache/dist/httpd/httpd-2.2.9.tar.gz
バージョンは2.2.9。
インストール先のディレクトリを作成しておく。
# mkdir /usr/local/httpd-2.2.9
# cd /usr/local/src
# tar zxf httpd-2.2.9.tar.gz
tarする。
# cd httpd-2.2.9
# ./configure --prefix=/usr/local/httpd-2.2.9 --enable-mods-shared=all --enable-ssl=shared
configure
allでconfigureしたけど、sslはallに含まれないとかってのを見たことがあるので
指定してみた。違っていたら教えてください。
# make > make_httpd.log 2>&1
makeログを残す。
# make install > make_install_httpd.log 2>&1
installログを残す。
# ln -sfn /usr/local/httpd-2.2.9 /usr/local/httpd
シンボリックリンク作成。
# groupadd apache
# useradd -g apache apache
# mkdir /var/www/ /var/www/html
# mkdir /var/log/httpd ←ログ用
# chown apache:apache /var/www/html
apache君を作成。
# emacs /usr/local/httpd/conf/httpd.conf
-----------------------------------------------------------
User apache(L116)
Group apache
ServerAdmin xxxxxx@xx.xx.xx(L139)
ServerName xx.xx.xx:80(L148)
DocumentRoot "/var/www/html"(L155)
AllowOverride All(L202)
DirectoryIndex index.html index.php(L217)
ErrorLog "/var/log/httpd/error_log"(L237)
CustomLog "/var/log/httpd/access_log" common(L266)
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"(L302)
AddType application/x-httpd-php .php(L360)追加
※後にPHPをインストールするので。
AddHandler cgi-script .cgi .pl(L370)
# User home directories
Include conf/extra/httpd-userdir.conf(L434)
-----------------------------------------------------------
変更点のみ抜粋。(Lは行数)
# /usr/local/httpd/bin/apachectl configtest
Syntax OK
# /usr/local/httpd/bin/apachectl start
apache起動。
#emacs /var/www/html/index.html
ブラウザを使ってアクセスし、内容が表示されていることを確認。
# /usr/local/httpd/bin/apachectl stop
apache停止。
# sed -e 's/^# chkconfig:.*/# chkconfig: 2345 85 15/' -e 's/\/etc\/httpd/\/usr\/local\/httpd/' -e 's/\/usr\/sbin/\/usr\/local\/httpd\/bin/' /usr/local/src/httpd-2.2.9/build/rpm/httpd.init > /etc/rc.d/init.d/httpd
自動起動スクリプト。
# chmod 755 /etc/rc.d/init.d/httpd
# chkconfig --add httpd
# /etc/rc.d/init.d/httpd start
実行権限を与えて自動起動設定し起動。
2008年10月09日
NTPサーバ構築
# yum -y install ntp
# emacs /etc/ntp.conf
--------------------------------------------------------
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.centos.pool.ntp.org
#server 1.centos.pool.ntp.org
#server 2.centos.pool.ntp.org
server ntp.nict.jp
--------------------------------------------------------
時刻同期先のサーバを指定。
# ntpdate ntp.nict.jp
一度手動で時刻を合わせる。
# /etc/rc.d/init.d/ntpd start
# chkconfig ntpd on
NTPサーバー起動と自動起動設定。
# ntpq -p
NTPサーバーへの時刻同期状態確認
# emacs /etc/ntp.conf
--------------------------------------------------------
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.centos.pool.ntp.org
#server 1.centos.pool.ntp.org
#server 2.centos.pool.ntp.org
server ntp.nict.jp
--------------------------------------------------------
時刻同期先のサーバを指定。
# ntpdate ntp.nict.jp
一度手動で時刻を合わせる。
# /etc/rc.d/init.d/ntpd start
# chkconfig ntpd on
NTPサーバー起動と自動起動設定。
# ntpq -p
NTPサーバーへの時刻同期状態確認


