1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

EC2 RHEL環境にLaravel環境を構築

Posted at

EC2 RHEL環境にLaravel環境を構築

EC2を構築済みであり、SSHで接続できることが前提

EC2へSSH接続

1. EC2へSSH接続
2. roo権限にする

$ sudo su -

PHPをインストール

$ yum install wget
$ wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
$ wget https://rpms.remirepo.net/enterprise/remi-release-7.rpm
$ rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm
$ subscription-manager repos --enable=rhel-7-server-optional-rpms
$ yum install yum-utils
$ yum module install php:7.2
$ yum install php php-gd php-pdo php-xml php-sqlsrv php-mysql php-mbstring php-pear php-devel php-mcrypt re2c gcc-c++ gcc
$ yum install php-zip

bcp、sqlcmdをインストール

$ yum install mssql-tools
$ echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
$ echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
$ source ~/.bashrc

composerをインストール

$ curl -sS https://getcomposer.org/installer | php
$ mv composer.phar /usr/local/bin/composer
$ chmod +x /usr/local/bin/composer

Laravel5.7インストール(プロジェクト作成)

$ cd /var/www/html ←DocumentRootディレクトリ
$ composer create-project "laravel/laravel=5.7.*" xxxxx ←プロジェクト名

権限設定

$ cd /var/www/html
$ chmod -R 777 xxxx ←プロジェクト名
$ cd xxxx/
$ chmod -R 777 storage
$ chmod -R 777 bootstrap/cache
$ composer require intervention/image

httpd開始・自動起動設定

$ service httpd start
$ systemctl enable httpd.service

firewallにhttp許可 ※再起動

$ sudo su -
$ yum install firewalld
$ systemctl start firewalld
$ systemctl enable firewalld
$ systemctl status firewalld
$ firewall-cmd --add-service=http --zone=public --permanent
$ firewall-cmd --add-service=https --zone=public --permanent

Apacheの設定変更

$ vim /etc/httpd/conf/httpd.conf
以下を記載
DocumentRoot "/var/www/html/xxxx/public"

$ service httpd restart

タイムゾーンの設定変更

$ timedatectl set-timezone Asia/Tokyo
$ timedatectl set-ntp yes
$ vim /etc/php.ini
以下を変更
;date.timezone =
↓
date.timezone = Asia/Tokyo

クーロンインストール

$ yum install cronie
$ systemctl enable crond.service
$ systemctl start crond.service
$ timedatectl set-timezone Asia/Tokyo
$ ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
$ systemctl restart crond

ログの書き込み権限エラー解消

$ setenforce 0
$ vim /etc/selinux/config
SELINUX=disabled

cssがhttp通信になる問題

・参照ページ:https対応したLaravelプロジェクトでassetを使う時の注意点

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?