・ Web系SE募集 (技術開発部開発系エンジニア・Java/Tomcat 420万円~750万円)
   ・ 社内SE募集 (業務系システムの開発・社内イントラ)

Apacheの最近のブログ記事

パスフレーズあり

$ /usr/bin/openssl genrsa -des3 1024 > ./ssl_server.key

パスフレーズなし

$ /usr/bin/openssl genrsa 1024 > ./ssl_server.key

 

$ /usr/bin/openssl req -new -key ./ssl_server.key -x509 -days 3650 -out ./ssl_server.crt

※ 有効期間は長めにね!

    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]:
    State or Province Name (full name) [Berkshire]:
    Locality Name (eg, city) [Newbury]:
    Organization Name (eg, company) [My Company Ltd]:
    Organizational Unit Name (eg, section) []:
    Common Name (eg, your name or your server's hostname) []:my.domain.name
    Email Address []:

Apacheの設定ファイル例

NameVirtualHost *:443

Listen 443

AddType application/x-x509-ca-cert .crt
AddType application/x-pkcs7-crl    .crl

SSLPassPhraseDialog  builtin

SSLSessionCache        "shmcb:/usr/local/apache2/logs/ssl_scache(512000)"
SSLSessionCacheTimeout  300

SSLMutex  "file:/usr/local/apache2/logs/ssl_mutex"

SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL

SSLCertificateFile    "/usr/local/apache2/conf/extra/httpd-vhosts/ssl_server.crt"
SSLCertificateKeyFile "/usr/local/apache2/conf/extra/httpd-vhosts/ssl_server.key"

<VirtualHost *:443>

        ServerName my.domain.name:443

SSLEngine on

<FilesMatch "\.(cgi|shtml|phtml|php)$">
    SSLOptions +StdEnvVars
</FilesMatch>

BrowserMatch ".*MSIE.*" \
         nokeepalive ssl-unclean-shutdown \
         downgrade-1.0 force-response-1.0

        CustomLog "|/usr/local/apache2/bin/rotatelogs /home/httpd/vhost/my.domain.name/log/ssl_request_log.%Y%m%d 86400"  "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

Apacheのソースファイルをダウンロードする。

The Apache HTTP Server Project にアクセスし、Download! from a mirror を開く。

「Other mirrors:」から適当な、mirror サイトを選び、「Change」ボタンを押す。

「Apache HTTP Server 2.2.9 is the best available version」という欄のダウンロード先が変わるので、そこからダウンロードする。

Unix Source: httpd-2.2.9.tar.gz [PGP] [MD5]
wget ftp://ftp.kddilabs.jp/infosystems/apache/httpd/httpd-2.2.9.tar.gz

Apacheをインストールする。

必要に応じて、configure のオプションを設定する。

./configure --enable-rewrite --enable-so --enable-deflate  --enable-vhost-alias  --enable-ssl

# prefix 指定
# --enable-proxy でプロキシ機能を有効
# --enable-proxy-balancer でロードバランスに対応
./configure --prefix=/usr/local/apache2.2.6 --enable-proxy --enable-proxy-balancer --enable-rewrite --enable-so --enable-deflate  --enable-vhost-alias  --enable-ssl

SSL関連でエラーが出る場合

checking whether to enable mod_ssl... checking dependencies
checking for SSL/TLS toolkit base... none
checking for OpenSSL version... checking openssl/opensslv.h usability... no
checking openssl/opensslv.h presence... no
checking for openssl/opensslv.h... no
checking openssl/ssl.h usability... no
checking openssl/ssl.h presence... no
checking for openssl/ssl.h... no
no OpenSSL headers found
checking for SSL-C version... checking sslc.h usability... no
checking sslc.h presence... no
checking for sslc.h... no
no SSL-C headers found
configure: error: ...No recognized SSL/TLS toolkit detected

上記のようなエラーが出る場合、yum で openssl-devel をインストールする。

 sudo yum  install openssl-devel

ダウンロードからインストールまで、まとめ

sudo yum  install openssl-devel
wget ftp://ftp.kddilabs.jp/infosystems/apache/httpd/httpd-2.2.9.tar.gz
tar xzvf httpd-2.2.9.tar.gz
cd httpd-2.2.9

# インストールオをプションを確認
./configure --help

./configure --enable-rewrite --enable-so --enable-deflate  --enable-vhost-alias  --enable-ssl

make
sudo make install

Apacheインストール後の忘れてはならない設定

ServerTokens によるサーバ情報表示をさせない。

sudo vim /usr/local/apache2/conf/extra/httpd-default.conf
ServerTokens Full
  になっているところを
ServerTokens Prod
に変更

ServerSignature On
  になっているところを
ServerSignature Off
に変更

httpd.conf の設定で、httpd-default.confを有効にする。

sudo vim /usr/local/apache2/conf/httpd.conf

コメントを外す。

# Various default settings
Include conf/extra/httpd-default.conf

Apache起動・リスタート・停止

# 起動
sudo /usr/local/apache2/bin/apachectl start
# リスタート
sudo /usr/local/apache2/bin/apachectl restart
#停止
sudo /usr/local/apache2/bin/apachectl stop

coLinux インストール後の環境設定」の続きで、 Apache をインストールしてみましょう。

yum install httpd でApacheをインストールする。

[suzu@localhost ~]$ sudo yum install httpd
[sudo] password for suzu:
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package httpd.i386 0:2.2.8-3 set to be updated
--> Processing Dependency: libapr-1.so.0 for package: httpd
--> Processing Dependency: libaprutil-1.so.0 for package: httpd
--> Processing Dependency: httpd-tools = 2.2.8-3 for package: httpd
--> Processing Dependency: /etc/mime.types for package: httpd
--> Running transaction check
---> Package apr.i386 0:1.2.12-2.fc9 set to be updated
---> Package httpd-tools.i386 0:2.2.8-3 set to be updated
---> Package apr-util.i386 0:1.2.12-5.fc9 set to be updated
---> Package mailcap.noarch 0:2.1.28-1.fc9 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================
 Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
 httpd                   i386       2.2.8-3          fedora            968 k
Installing for dependencies:
 apr                     i386       1.2.12-2.fc9     fedora            128 k
 apr-util                i386       1.2.12-5.fc9     fedora             74 k
 httpd-tools             i386       2.2.8-3          fedora             68 k
 mailcap                 noarch     2.1.28-1.fc9     fedora             15 k

Transaction Summary
=============================================================================
Install      5 Package(s)
Update       0 Package(s)
Remove       0 Package(s)

Total download size: 1.2 M
Is this ok [y/N]: y
Downloading Packages:
(1/5): mailcap-2.1.28-1.fc9.noarch.rpm                 |  15 kB     00:00
(2/5): httpd-tools-2.2.8-3.i386.rpm                    |  68 kB     00:00
(3/5): apr-util-1.2.12-5.fc9.i386.rpm                  |  74 kB     00:00
(4/5): apr-1.2.12-2.fc9.i386.rpm                       | 128 kB     00:00
(5/5): httpd-2.2.8-3.i386.rpm                          | 968 kB     00:00
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : mailcap                                           [1/5]
  Installing     : apr                                               [2/5]
  Installing     : apr-util                                          [3/5]
  Installing     : httpd-tools                                       [4/5]
  Installing     : httpd                                             [5/5]

Installed: httpd.i386 0:2.2.8-3
Dependency Installed: apr.i386 0:1.2.12-2.fc9 apr-util.i386 0:1.2.12-5.fc9 httpd-tools.i386 0:2.2.8-3 mailcap.noarch 0:2.1.28-1.fc9
Complete!
[suzu@localhost ~]$

Apacheを起動する。

[suzu@localhost ~]$ sudo /etc/init.d/httpd start
Starting httpd:                                            [  OK  ]
[suzu@localhost ~]$

起動したApacheプロセスを確認する。

[suzu@localhost ~]$ ps aux | grep httpd
root      2909  0.0  1.0  10284  2788 ?        Ss   07:32   0:00 /usr/sbin/httpd
apache    2910  0.0  0.7  10420  2028 ?        S    07:32   0:00 /usr/sbin/httpd
apache    2911  0.0  0.7  10420  2028 ?        S    07:32   0:00 /usr/sbin/httpd
apache    2913  0.0  0.7  10420  2028 ?        S    07:32   0:00 /usr/sbin/httpd
apache    2914  0.0  0.7  10420  2028 ?        S    07:32   0:00 /usr/sbin/httpd
apache    2915  0.0  0.7  10420  2028 ?        S    07:32   0:00 /usr/sbin/httpd
apache    2916  0.0  0.7  10420  2028 ?        S    07:32   0:00 /usr/sbin/httpd
apache    2917  0.0  0.7  10420  2028 ?        S    07:32   0:00 /usr/sbin/httpd
apache    2918  0.0  0.7  10420  2028 ?        S    07:32   0:00 /usr/sbin/httpd
suzu      2939  0.0  0.2   4120   704 pts/1    R+   07:47   0:00 grep httpd
[suzu@localhost ~]$

ブラウザからアクセスして確認してみる。

WindowsからcoLinuxのApacheへアクセスは、slirp 経由のまま変更していなければ、
URLに、http://localhost/ でアクセスします。

「Fedora Test Page」画面が表示される。


このアーカイブについて

このページには、過去に書かれたブログ記事のうちApacheカテゴリに属しているものが含まれています。

前のカテゴリは.netです。

次のカテゴリはConferenceです。

最近のコンテンツはインデックスページで見られます。過去に書かれたものはアーカイブのページで見られます。