LoginSignup
9
5

More than 5 years have passed since last update.

【tutorial】AWS EC2にPHP, Apache, Laravelをインストール→テストページを表示

Last updated at Posted at 2018-04-16

2018/4/16に実施。

1.SSHでEC2に接続。

2.PHP, Apacheをインストール。

sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
sudo yum -y install --enablerepo=remi,remi-php70 php

3.PHPのバージョンを確認。「5.3.29」??
  7をいれたつもりなんだけど。。

php -v

4.jpg

4.リトライ。

sudo yum -y install --disablerepo=* --enablerepo=remi,remi-php70 php

5.PHPのバージョンを確認。7になった。

php -v

2.jpg

6.Composerをインストール。

curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

7.Laravelのインストール。エラーが発生。

composer global require "laravel/installer"

3.jpg

8.php-zipをインストール。

sudo yum -y install --disablerepo=* --enablerepo=remi,remi-php70 php-zip

9.「7.」をリトライ。成功。

composer global require "laravel/installer"

4.jpg

10.プロジェクトを作成。今回は「/var/www/laravel/sample」に作成。エラーが発生。

sudo mkdir /var/www/laravel
sudo chmod 777 /var/www/laravel
composer create-project laravel/laravel /var/www/laravel/sample

5.jpg

11.php-mbstring, php-xmlをインストール。

sudo yum -y install --disablerepo=* --enablerepo=remi,remi-php70 php-mbstring
sudo yum -y install --disablerepo=* --enablerepo=remi,remi-php70 php-xml

12.「10.」をリトライ。成功。

rm -rf /var/www/laravel/sample
composer create-project laravel/laravel /var/www/laravel/sample 

6.jpg

13.権限を変更。

sudo chown -R apache:apache /var/www/laravel/sample

14.httpd.confの設定を変更。

vim /etc/httpd/conf/httpd.conf 
DocumentRoot "/var/www/html"
↓
DocumentRoot "/var/www/laravel/sample/public"

15.Apacheを再起動。

sudo service httpd restart

16.「セキュリティグループ」→「インバウンドルール」にHTTPを追加。
https://qiita.com/d778980/items/fa5daeef8cc5e0af768c

17.ブラウザでテストページを表示。
http://(パブリックDNS)
7.jpg

終わり。

9
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
5