Diary-nagataka-シリコンバレーで働きたい!という夢への日々

外資ITで働くエンジニアが趣味や日々の事など書いてます(技術の話は別ブログ http://wanna-be-geek.seesaa.net/ )

スポンサーサイト

上記の広告は1ヶ月以上更新のないブログに表示されています。
新しい記事を書く事で広告が消せます。
  1. --/--/--(--) --:--:--|
  2. スポンサー広告
  3. このエントリーを含むはてなブックマーク

[AWS][Apache]AWSにApache2.4を立てる

ググればいくらでも情報はあるので今更感はある内容ですが、誰かの役に立つかもしれないので

0.まずはAWSの環境を作成し、ログイン(AWSのインスタンスを用意するのは別途事前に行ってくださいね)

$ ssh -i /Users/Nagataka/.ssh/myawikey.pem ec2-user@ec2-XX-XXX-XX-XX.ap-northeast-1.compute.amazonaws.com
(※青字の箇所は、インスタンスを作成した際に使う鍵です。ローカルの保存している場所を指定してあげます。

The authenticity of host 'ec2-XX-XXX-XX-XX.ap-northeast-1.compute.amazonaws.com (54.248.33.31)' can't be established.
RSA key fingerprint is 5b:ee:83:5a:5d:f5:8b:00:8a:70:8c:5c:9c:8d:27:c0.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'ec2-XX-XXX-XX-XX.ap-northeast-1.compute.amazonaws.com,54.248.33.31' (RSA) to the list of known hosts.

__| __|_ )
_| ( / Amazon Linux AMI
___|\___|___|

https://aws.amazon.com/amazon-linux-ami/2012.09-release-notes/
There are 4 security update(s) out of 35 total update(s) available
Run "sudo yum update" to apply all updates.
[ec2-user@ip-xx-xxx-x-xxx ~]$



これでログイン完了。
rootになるには、最初は sudo su - としてやればOK。

[ec2-user@ip-xx-xxx-x-xxx ~]$ sudo su
[root@ip-xx-xxx-x-xxx ec2-user]#



次に、rootのパスワードを設定しておこう。


[root@ip-xx-xxx-x-xxx ~]# passwd root
Changing password for user root.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[root@ip-xx-xxx-x-xxx ~]#



リポジトリを確認してみよう。

[root@ip-xx-xxx-x-xxx ~]# ll /etc/yum.repos.d/
amzn-main.repo amzn-preview.repo epel.repo
amzn-nosrc.repo amzn-updates.repo epel-testing.repo
[root@ip-xx-xxx-x-xxx ~]#



それでは、リポジトリ上のhttpdの確認です。

[root@ip-xx-xxx-x-xxx ~]# yum list httpd
Loaded plugins: priorities, security, update-motd, upgrade-helper
amzn-main | 2.1 kB 00:00
amzn-updates | 2.3 kB 00:00
Available Packages
httpd.x86_64 2.2.23-1.25.amzn1 amzn-updates
[root@ip-xx-xxx-x-xxx ~]#




デフォルトのリポジトリだと、Apacheのバージョンは2.2.23のようですね。
これで良い人はyum install httpd としてあげればOK。
折角なので最新の2.4を入れたい人は、以下に従ってみてください。

[root@ip-xx-xxx-x-xxx ~]# cd /usr/local/src/
[root@ip-xx-xxx-x-xxx src]# wget http://ftp.riken.jp/net/apache//httpd/httpd-2.4.3.tar.gz
--2012-12-08 06:10:54-- http://ftp.riken.jp/net/apache//httpd/httpd-2.4.3.tar.gz
Resolving ftp.riken.jp... 134.160.38.1
Connecting to ftp.riken.jp|134.160.38.1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 6137268 (5.9M) [application/x-gzip]
Saving to: “httpd-2.4.3.tar.gz”


100%[====================================================================>] 6,137,268 2.08M/s in 2.8s


2012-12-08 06:10:56 (2.08 MB/s) - “httpd-2.4.3.tar.gz” saved [6137268/6137268]


[root@ip-xx-xxx-x-xxx src]#
[root@ip-xx-xxx-x-xxx src]# ll
total 5996
-rw-r--r-- 1 root root 6137268 Aug 20 13:22 httpd-2.4.3.tar.gz
[root@ip-xx-xxx-x-xxx src]#
[root@ip-xx-xxx-x-xxx src]# gzip -d ./httpd-2.4.3.tar.gz
[root@ip-xx-xxx-x-xxx src]# tar xf ./httpd-2.4.3.tar
[root@ip-xx-xxx-x-xxx src]# cd httpd-2.4.3
[root@ip-xx-xxx-x-xxx httpd-2.4.3]# ls

ABOUT_APACHE build configure include Makefile.in README test
acinclude.m4 BuildAll.dsp configure.in INSTALL Makefile.win README.platforms VERSIONING
Apache-apr2.dsw BuildBin.dsp docs InstallBin.dsp modules ROADMAP
Apache.dsw buildconf emacs-style LAYOUT NOTICE server
apache_probes.d CHANGES httpd.dsp libhttpd.dsp NWGNUmakefile srclib
ap.d config.layout httpd.spec LICENSE os support
[root@ip-xx-xxx-x-xxx httpd-2.4.3]#




で、ここからがひと手間。
試しにconfigureをしてみると、以下のように止まります。

[root@ip-xx-xxx-x-xxx httpd-2.4.3]# ./configure
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... no
configure: error: APR not found. Please read the documentation.
[root@ip-xx-xxx-x-xxx httpd-2.4.3]#




APRが無いよと言われているので、APRをインストールしましょう。
そのまえに、Cコンパイラが必要ですね。

[root@ip-xx-xxx-x-xxx apr-1.4.6]# yum install cc
Loaded plugins: priorities, security, update-motd, upgrade-helper
amzn-main | 2.1 kB 00:00
amzn-updates | 2.3 kB 00:00
Setting up Install Process
No package cc available.
Error: Nothing to do
[root@ip-xx-xxx-x-xxx apr-1.4.6]# yum install gcc
Loaded plugins: priorities, security, update-motd, upgrade-helper
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package gcc.noarch 0:4.6.2-1.8.amzn1 will be installed
--> Processing Dependency: gcc46 = 4.6.2 for package: gcc-4.6.2-1.8.amzn1.noarch
--> Running transaction check
---> Package gcc46.x86_64 0:4.6.2-2.65.amzn1 will be installed
--> Processing Dependency: cpp46 = 4.6.2-2.65.amzn1 for package: gcc46-4.6.2-2.65.amzn1.x86_64
--> Processing Dependency: libgcc46 = 4.6.2 for package: gcc46-4.6.2-2.65.amzn1.x86_64
--> Processing Dependency: binutils >= 2.20.51.0.2-12 for package: gcc46-4.6.2-2.65.amzn1.x86_64
--> Processing Dependency: libgomp >= 4.6.2-2.65.amzn1 for package: gcc46-4.6.2-2.65.amzn1.x86_64
--> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc46-4.6.2-2.65.amzn1.x86_64
--> Processing Dependency: libmpfr.so.1()(64bit) for package: gcc46-4.6.2-2.65.amzn1.x86_64
--> Processing Dependency: libmpc.so.2()(64bit) for package: gcc46-4.6.2-2.65.amzn1.x86_64
--> Processing Dependency: libgomp.so.1()(64bit) for package: gcc46-4.6.2-2.65.amzn1.x86_64
--> Running transaction check
---> Package binutils.x86_64 0:2.20.51.0.7-8.29.amzn1 will be installed
---> Package cpp46.x86_64 0:4.6.2-2.65.amzn1 will be installed
---> Package glibc-devel.x86_64 0:2.12-1.80.42.amzn1 will be installed
--> Processing Dependency: glibc-headers = 2.12-1.80.42.amzn1 for package: glibc-devel-2.12-1.80.42.amzn1.x86_64
--> Processing Dependency: glibc-headers for package: glibc-devel-2.12-1.80.42.amzn1.x86_64
---> Package libgcc46.x86_64 0:4.6.2-2.65.amzn1 will be installed
---> Package libgomp.x86_64 0:4.7.2-2.69.amzn1 will be installed
---> Package libmpc.x86_64 0:0.8.2-1.4.amzn1 will be installed
---> Package mpfr.x86_64 0:2.4.2-1.7.amzn1 will be installed
--> Running transaction check
---> Package glibc-headers.x86_64 0:2.12-1.80.42.amzn1 will be installed
--> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers-2.12-1.80.42.amzn1.x86_64
--> Processing Dependency: kernel-headers for package: glibc-headers-2.12-1.80.42.amzn1.x86_64
--> Running transaction check
---> Package kernel-headers.x86_64 0:3.2.34-55.46.amzn1 will be installed
--> Finished Dependency Resolution


Dependencies Resolved


==============================================================================================================
Package Arch Version Repository Size
==============================================================================================================
Installing:
gcc noarch 4.6.2-1.8.amzn1 amzn-main 2.7 k
Installing for dependencies:
binutils x86_64 2.20.51.0.7-8.29.amzn1 amzn-main 3.6 M
cpp46 x86_64 4.6.2-2.65.amzn1 amzn-main 4.8 M
gcc46 x86_64 4.6.2-2.65.amzn1 amzn-main 14 M
glibc-devel x86_64 2.12-1.80.42.amzn1 amzn-main 1.0 M
glibc-headers x86_64 2.12-1.80.42.amzn1 amzn-main 648 k
kernel-headers x86_64 3.2.34-55.46.amzn1 amzn-updates 843 k
libgcc46 x86_64 4.6.2-2.65.amzn1 amzn-main 98 k
libgomp x86_64 4.7.2-2.69.amzn1 amzn-updates 113 k
libmpc x86_64 0.8.2-1.4.amzn1 amzn-main 49 k
mpfr x86_64 2.4.2-1.7.amzn1 amzn-main 182 k


Transaction Summary
==============================================================================================================
Install 11 Package(s)

Total download size: 25 M
Installed size: 48 M
Is this ok [y/N]: y
Downloading Packages:
(1/11): binutils-2.20.51.0.7-8.29.amzn1.x86_64.rpm | 3.6 MB 00:00
(2/11): cpp46-4.6.2-2.65.amzn1.x86_64.rpm | 4.8 MB 00:00
(3/11): gcc-4.6.2-1.8.amzn1.noarch.rpm | 2.7 kB 00:00
(4/11): gcc46-4.6.2-2.65.amzn1.x86_64.rpm | 14 MB 00:00
(5/11): glibc-devel-2.12-1.80.42.amzn1.x86_64.rpm | 1.0 MB 00:00
(6/11): glibc-headers-2.12-1.80.42.amzn1.x86_64.rpm | 648 kB 00:00
(7/11): kernel-headers-3.2.34-55.46.amzn1.x86_64.rpm | 843 kB 00:00
(8/11): libgcc46-4.6.2-2.65.amzn1.x86_64.rpm | 98 kB 00:00
(9/11): libgomp-4.7.2-2.69.amzn1.x86_64.rpm | 113 kB 00:00
(10/11): libmpc-0.8.2-1.4.amzn1.x86_64.rpm | 49 kB 00:00
(11/11): mpfr-2.4.2-1.7.amzn1.x86_64.rpm | 182 kB 00:00
--------------------------------------------------------------------------------------------------------------
Total 13 MB/s | 25 MB 00:01
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : mpfr-2.4.2-1.7.amzn1.x86_64 1/11
Installing : libmpc-0.8.2-1.4.amzn1.x86_64 2/11
Installing : cpp46-4.6.2-2.65.amzn1.x86_64 3/11
Installing : libgcc46-4.6.2-2.65.amzn1.x86_64 4/11
Installing : libgomp-4.7.2-2.69.amzn1.x86_64 5/11
Installing : kernel-headers-3.2.34-55.46.amzn1.x86_64 6/11
Installing : glibc-headers-2.12-1.80.42.amzn1.x86_64 7/11
Installing : glibc-devel-2.12-1.80.42.amzn1.x86_64 8/11
Installing : binutils-2.20.51.0.7-8.29.amzn1.x86_64 9/11
Installing : gcc46-4.6.2-2.65.amzn1.x86_64 10/11
Installing : gcc-4.6.2-1.8.amzn1.noarch 11/11
Verifying : binutils-2.20.51.0.7-8.29.amzn1.x86_64 1/11
Verifying : glibc-headers-2.12-1.80.42.amzn1.x86_64 2/11
Verifying : libmpc-0.8.2-1.4.amzn1.x86_64 3/11
Verifying : gcc46-4.6.2-2.65.amzn1.x86_64 4/11
Verifying : gcc-4.6.2-1.8.amzn1.noarch 5/11
Verifying : kernel-headers-3.2.34-55.46.amzn1.x86_64 6/11
Verifying : libgomp-4.7.2-2.69.amzn1.x86_64 7/11
Verifying : libgcc46-4.6.2-2.65.amzn1.x86_64 8/11
Verifying : mpfr-2.4.2-1.7.amzn1.x86_64 9/11
Verifying : cpp46-4.6.2-2.65.amzn1.x86_64 10/11
Verifying : glibc-devel-2.12-1.80.42.amzn1.x86_64 11/11


Installed:
gcc.noarch 0:4.6.2-1.8.amzn1


Dependency Installed:
binutils.x86_64 0:2.20.51.0.7-8.29.amzn1 cpp46.x86_64 0:4.6.2-2.65.amzn1
gcc46.x86_64 0:4.6.2-2.65.amzn1 glibc-devel.x86_64 0:2.12-1.80.42.amzn1
glibc-headers.x86_64 0:2.12-1.80.42.amzn1 kernel-headers.x86_64 0:3.2.34-55.46.amzn1
libgcc46.x86_64 0:4.6.2-2.65.amzn1 libgomp.x86_64 0:4.7.2-2.69.amzn1
libmpc.x86_64 0:0.8.2-1.4.amzn1 mpfr.x86_64 0:2.4.2-1.7.amzn1


Complete!
[root@ip-xx-xxx-x-xxx apr-1.4.6]#




あと、最初はmakeもインストールされていないですね。
必要なので入れましょう。

[root@ip-xx-xxx-x-xxx apr-1.4.6]# yum install make
Loaded plugins: priorities, security, update-motd, upgrade-helper
amzn-main | 2.1 kB 00:00
amzn-updates | 2.3 kB 00:00
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package make.x86_64 1:3.81-20.7.amzn1 will be installed
--> Finished Dependency Resolution


Dependencies Resolved


==============================================================================================================
Package Arch Version Repository Size
==============================================================================================================
Installing:
make x86_64 1:3.81-20.7.amzn1 amzn-main 487 k


Transaction Summary
==============================================================================================================
Install 1 Package(s)


Total download size: 487 k
Installed size: 1.0 M
Is this ok [y/N]: y
Downloading Packages:
make-3.81-20.7.amzn1.x86_64.rpm | 487 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : 1:make-3.81-20.7.amzn1.x86_64 1/1
Verifying : 1:make-3.81-20.7.amzn1.x86_64 1/1


Installed:
make.x86_64 1:3.81-20.7.amzn1


Complete!
[root@ip-xx-xxx-x-xxx apr-1.4.6]#






それでは、APRの準備に取りかかります。

[root@ip-xx-xxx-x-xxx src]# cd /usr/local/src/
[root@ip-xx-xxx-x-xxx src]# wget http://ftp.jaist.ac.jp/pub/apache//apr/apr-1.4.6.tar.gz
[root@ip-xx-xxx-x-xxx src]# gzip -d ./apr-1.4.6.tar.gz
[root@ip-xx-xxx-x-xxx src]# tar xf ./apr-1.4.6.tar
[root@ip-xx-xxx-x-xxx apr-1.4.6]# ./configure
[root@ip-xx-xxx-x-xxx apr-1.4.6]# make
[root@ip-xx-xxx-x-xxx apr-1.4.6]# make install





/usr/local/apr というディレクトリができている事を確認しましょう。

[root@ip-xx-xxx-x-xxx apr-1.4.6]# ll /usr/local/apr/
total 16
drwxr-xr-x 2 root root 4096 Dec 8 06:59 bin
drwxr-xr-x 2 root root 4096 Dec 8 06:59 build-1
drwxr-xr-x 3 root root 4096 Dec 8 06:59 include
drwxr-xr-x 3 root root 4096 Dec 8 06:59 lib
[root@ip-xx-xxx-x-xxx apr-1.4.6]#






さてさて、次はapr-utilが必要なので、こちらも同様にインストールしましょう。

[root@ip-xx-xxx-x-xxx src]# wget http://ftp.jaist.ac.jp/pub/apache//apr/apr-util-1.4.1.tar.gz
--2012-12-08 07:03:01-- http://ftp.jaist.ac.jp/pub/apache//apr/apr-util-1.4.1.tar.gz
Resolving ftp.jaist.ac.jp... 150.65.7.130, 2001:200:141:feed::feed
Connecting to ftp.jaist.ac.jp|150.65.7.130|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 774770 (757K) [application/x-gzip]
Saving to: “apr-util-1.4.1.tar.gz”


100%[====================================================================>] 774,770 3.30M/s in 0.2s


2012-12-08 07:03:01 (3.30 MB/s) - “apr-util-1.4.1.tar.gz” saved [774770/774770]


[root@ip-xx-xxx-x-xxx src]# ll
total 35244
drwxr-sr-x 26 5000 10001 4096 Dec 8 06:58 apr-1.4.6
-rw-r--r-- 1 root root 5345280 Feb 14 2012 apr-1.4.6.tar
-rw-r--r-- 1 root root 774770 Dec 13 2011 apr-util-1.4.1.tar.gz
drwxr-xr-x 11 501 games 4096 Dec 8 06:50 httpd-2.4.3
-rw-r--r-- 1 root root 29958144 Aug 20 13:22 httpd-2.4.3.tar
[root@ip-xx-xxx-x-xxx src]# gzip -d ./apr-util-1.4.1.tar.gz
[root@ip-xx-xxx-x-xxx src]# tar xf ./apr-util-1.4.1.tar
[root@ip-xx-xxx-x-xxx src]# cd apr-util-1.4.1
[root@ip-xx-xxx-x-xxx apr-util-1.4.1]# ./configure --with-apr=/usr/local/apr/

[root@ip-xx-xxx-x-xxx apr-util-1.4.1]# make
[root@ip-xx-xxx-x-xxx apr-util-1.4.1]# make install




さらに、pcre-develとやらも必要なので、以下も行ってください。

[root@ip-xx-xxx-x-xxx httpd-2.4.3]# yum -y install pcre-devel
Loaded plugins: priorities, security, update-motd, upgrade-helper
amzn-main | 2.1 kB 00:00
amzn-updates | 2.3 kB 00:00
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package pcre-devel.x86_64 0:8.21-5.3.amzn1 will be installed
--> Finished Dependency Resolution


Dependencies Resolved


==============================================================================================================
Package Arch Version Repository Size
==============================================================================================================
Installing:
pcre-devel x86_64 8.21-5.3.amzn1 amzn-main 479 k


Transaction Summary
==============================================================================================================
Install 1 Package(s)


Total download size: 479 k
Installed size: 1.2 M
Downloading Packages:
pcre-devel-8.21-5.3.amzn1.x86_64.rpm | 479 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : pcre-devel-8.21-5.3.amzn1.x86_64 1/1
Verifying : pcre-devel-8.21-5.3.amzn1.x86_64 1/1


Installed:
pcre-devel.x86_64 0:8.21-5.3.amzn1


Complete!
[root@ip-xx-xxx-x-xxx httpd-2.4.3]#




それでは、やっとhttpdのインストールに移ります!

[root@ip-xx-xxx-x-xxx httpd-2.4.3]# pwd
/usr/local/src/httpd-2.4.3
[root@ip-xx-xxx-x-xxx httpd-2.4.3]# ./configure --prefix=/usr/local/apache2.4 --enable-mpms-shared=all --enable-mods-shared=all --with-apr=/usr/local/apr
[root@ip-xx-xxx-x-xxx apr-util-1.4.1]# make
[root@ip-xx-xxx-x-xxx apr-util-1.4.1]# make install


(※赤字の部分は、2.4の新しい特徴であるLoadableなMPMを使用するために入れています。)

インストール完了!
さてさて、見てみましょう

apacheを起動します。

[root@ip-xx-xxx-x-xxx httpd-2.4.3]# /usr/local/apache2.4/bin/apachectl start




そして、ブラウザから以下のURLにアクセス!
http://ec2-xx-xxx-xx-xx.ap-northeast-1.compute.amazonaws.com/

It works!と表示されればOK!


apache2.4 on AWS

Apacheは問題無く起動しているけれどブラウザからアクセスができないよ!という人は、AWSのSecurity Groupのルールを確認してみてくださいね。
HTTPを許可していますか?



一先ず、これで無事AWS上にウェブサーバを立てる事ができましたね。

是非色々と遊んでみてください :-)
スポンサーサイト
  1. 2012/12/08(土) 16:45:07|
  2. AWS
  3. | トラックバック:0
  4. | コメント:0
  5. このエントリーを含むはてなブックマーク
<<カヌー@河口湖 | ホーム | [仕事]ギャップ>>

コメント

コメントの投稿

管理者にだけ表示を許可する

トラックバック

トラックバックURLはこちら
http://nagataka.blog50.fc2.com/tb.php/445-41e99df2
この記事にトラックバックする(FC2ブログユーザー)
上記広告は1ヶ月以上更新のないブログに表示されています。新しい記事を書くことで広告を消せます。