LoginSignup
2
0

More than 5 years have passed since last update.

Amazon EC2 (Amazon Linux)に PHP 5.6 + Laravel 5.3 + Apache 2.4をインストールする手順 (201709 メモ書き)

Last updated at Posted at 2017-09-19

参考記事:
Amazon EC2 (Amazon Linux)に PHP 5.6 + Laravel 5.3 + Apache 2.4をインストールする手順 (sedでphp.iniのdate.timezoneをAsia/Tokyoに変更するワンライナー)
https://qiita.com/na0AaooQ/items/e9b782be01ce6946d7e8

apache 2.4 install

# Apache 2.2 あれば削除
rpm -qa | grep http
yum remove httpd-*

# Apache 2.4 Install
sudo yum -y install httpd24

# Version
httpd -v


sudo /etc/init.d/httpd configtest
sudo /etc/init.d/httpd start
ps awux | grep -v grep | grep http

PHP 5.6

sudo yum -y install php56 php56-devel php56-mbstring php56-mcrypt php56-mysqlnd php56-pdo

Composer

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

gitなどのツール

sudo yum -y install git
sudo yum -y install php-pear
sudo yum -y install git
sudo yum -y install zlib-devel
sudo yum -y install gcc

httpdの設定

sudo chown ec2-user:ec2-user /var/www/laravel

mysql

自力でインストール:

* https://qiita.com/toshihirock/items/c5933d3628c7d4e81ffa
 EC2にMySQLインストールと設定確認
sudo yum install  mysql56 mysql56-server

RDS利用:

Source Deploy

git clone... の後、composer updateを実行したが、エラー。

[ec2-user@ip /var/www/test-git]$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 62 installs, 0 updates, 0 removals
  - Installing zendframework/zend-stdlib (3.1.0): Downloading (100%)
    proc_open(): fork failed - Cannot allocate memory
    The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems)
    Unzip with unzip command failed, falling back to ZipArchive class
The following exception is caused by a lack of memory or swap, or not having swap configured
Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details

PHP Warning:  proc_open(): fork failed - Cannot allocate memory in phar:///usr/local/bin/composer/vendor/symfony/console/Application.php on line 979

Warning: proc_open(): fork failed - Cannot allocate memory in phar:///usr/local/bin/composer/vendor/symfony/console/Application.php on line 979

  [ErrorException]
  proc_open(): fork failed - Cannot allocate memory


update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [--with-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [-i|--interactive] [--root-reqs] [--] [<packages>]...

Swapメモリが足りないので追加してみた

AWS Amazon Linux スワップファイル作成によりSwap領域のサイズを増やす
https://qiita.com/na0AaooQ/items/278a11ed905995bd16af

grep Mem /proc/meminfo
grep Swap /proc/meminfo
free
uname -a
# /swapfile1 に保存
sudo dd if=/dev/zero of=/swapfile1 bs=1M count=512
grep Swap /proc/meminfo

ll /swapfile1
sudo chmod 600 /swapfile1
mkswap /swapfile1
ll /swapfile1
sudo mkswap /swapfile1
swapon -s
free
sudo swapon /swapfile1
free
grep Swap /proc/meminfo

2
0
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
2
0