Help us understand the problem. What is going on with this article?

【Lavavel】5.1実行環境の構築をメモメモメモメモ

More than 3 years have passed since last update.

公式ドキュメント

http://readouble.com/laravel/5/1/ja/installation.html

Laravel5.1サーバ要件

要件

  • PHP >= 5.5.9
  • PDO PHP拡張
  • Tokenizer PHP拡張
  • OpenSSL PHP拡張
  • Mbstring PHP拡張
  • Composer

構築

  • 今回は「CentoOS6.5」に構築する

wget, vim

sudo yum -y install wget yum

httpd

httpdのインストール

# epelリポジトリインストール
sudo yum install epel-release
# IUSリポジトリインストール
sudo rpm -Uvh "https://dl.iuscommunity.org/pub/ius/stable/CentOS/6/x86_64/ius-release-1.0-14.ius.centos6.noarch.rpm"
# Apacheインストール
sudo yum install httpd24u

PHP

webtaticリポジトリの登録(PHPに特化したリポジトリ)

sudo rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm

peelリポジトリの登録(webtaticにないなら)

sudo rpm -ivh http://ftp.riken.jp/Linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm

remiリポジトリの登録(webtaticにないなら)

sudo rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

PHP5.6, PDO PHP拡張, Mbstring PHP拡張, Tokenizer PHP拡張, OpenSSL PHP拡張

sudo yum -y install php56w php56w-devel php56w-mcrypt php56w-mbstring php56w-mysqlnd php56w-pdo php56w-common php56w-xml php56w-opcache

PHP7.1

sudo yum -y install --enablerepo=webtatic-testing php71w php71w-devel php71w-mcrypt php71w-mbstring php71w-mysqlnd php71w-pdo php71w-common php71w-xml php71w-opcache php71w-gd

Composer

https://getcomposer.org/

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

mysql

remiレポジトリの登録

cd /usr/local/src
sudo wget http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
sudo yum -y localinstall mysql-community-release-el6-5.noarch.rpm

install

sudo yum -y install mysql-community-server
sudo cp /etc/my.cnf /etc/my.cnf.org

mysql文字コード設定

sudo vim /etc/my.cnf
#### utf-8設定の追加
[mysqld]
character-set-server=utf8

[client]
default-character-set=utf8

起動

sudo /etc/init.d/mysqld start

文字コードの確認(mysql 接続後にたたく)

mysql
show variables like 'char%';
  +--------------------------+----------------------------+
  | Variable_name            | Value                      |
  +--------------------------+----------------------------+
  | character_set_client     | utf8                       |
  | character_set_connection | utf8                       |
  | character_set_database   | utf8                       |
  | character_set_filesystem | binary                     |
  | character_set_results    | utf8                       |
  | character_set_server     | utf8                       |
  | character_set_system     | utf8                       |
  | character_sets_dir       | /usr/share/mysql/charsets/ |
  +--------------------------+----------------------------+

自動起動設定

chkconfig --list mysqld
sudo chkconfig mysqld on
chkconfig --list mysqld

rootパスワード設定

sudo /usr/bin/mysqladmin -u root password 'xxxxxxx'

セキュリティ設定

sudo /usr/bin/mysql_secure_installation
rootのパスワードはそのまま上記のパスワードを入力
設定参照 : http://weblabo.oscasierra.net/mysql-56-init-setup/

ユーザ登録

mysql -u root -p
CREATE USER 'reasuser'@'localhost' IDENTIFIED BY 'xxxxxx';
GRANT ALL PRIVILEGES ON *.* TO 'xxxxxx'@'localhost' IDENTIFIED BY 'xxxxxxx'
;
SELECT host,user FROM mysql.user;
show grants for 'xxxxxx'@'localhost';

Laravel

Laravelのインストール(comporser経由)

composer create-project laravel/laravel --prefer-dist [PROJECT_NAME]

書き込み権限付与

  • storage
  • bootstrap/cache

上記のディレクトリに対して「read,write」権限が必要なので適宜与える

確認

php artisan でサーバ起動して確認

php artisan serve
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away