忘れがちなことを、つらつらと...

俺的備忘録を公開してみるテスト

CentOS 6.5 にLaravelをインストールしたときのメモ

近頃、PHPフレームワークってどうなのかと思って、ggってみたら知らないのがあった... とりあえず、セットアップしてみようと試みたときのメモ

CentOS 6.5 minimal Desktopでインストール

以下rootで作業。

開発ツールの追加

# yum update
# yum groupinstall 'Development tools'

EPELとREMIリポジトリの追加

# rpm -ihv http://ftp.riken.jp/Linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -ihv http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

Nginxとphp-fpmのインストールと起動設定

  • Nginxとphp-fpmのインストール
# rpm -ihv http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
# yum install nginx
# yum --enablerepo=remi install php php-mysql php-mcrypt php-gd php-mbstring php-fpm
# service nginx start
# chkconfig nginx on
# service php-fpm start
# chkconfig php-fpm on
  • Nginxの設定
# vi /etc/nginx/conf.d/default.conf

server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/log/host.access.log  main;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm index.php; ← 追加
    }

    #error_page  404              /404.html;
中略
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {  ← コメントアウト
        root           /usr/share/nginx/html; ← 修正
        fastcgi_pass   127.0.0.1:9000; ← コメントアウト
        fastcgi_index  index.php; ← コメントアウト
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name; ← 修正
        include        fastcgi_params; ← コメントアウト
    }  ← コメントアウト

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
# vi /etc/php.ini
----------↓
; RPM note : session directory must be owned by process owner
; for mod_php, see /etc/httpd/conf.d/php.conf
; for php-fpm, see /etc/php-fpm.d/*conf
session.save_path = "/var/lib/php/session" ← コメントアウト&修正

; Whether to use cookies.
----------↑
# chown -R root.nginx /var/lib/php/session

# vi /etc/php-fpm.d/www.conf
----------↓
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
;       will be used.
; RPM: apache Choosed to be able to access some dir as httpd
user = nginx ← 修正
; RPM: Keep a group allowed to write in log dir.
group = nginx ← 修正
----------↑
  • サービス再起動と動作確認
# service php-fpm restart
# service nginx restart
# cd /usr/share/nginx/html/
# rm index.html 
# echo '<?php echo phpinfo(); ?>' > index.php

http://localhost/ にアクセスして、phpinfoが表示されることを確認

MySQLphpMyAdminインストールと設定

# yum --enablerepo=remi install mysql-server
# service mysqld start
# chkconfig mysqld on
# /usr/bin/mysql_secure_installation
# yum --enablerepo=remi install phpmyadmin

# cd /usr/share/nginx/html/
# ln -s /usr/share/phpMyAdmin/

Composerのインストール

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

Laravel導入

# cd /usr/share/nginx/html/
# composer create-project laravel/laravel laravel --prefer-dist
# cd /usr/share/nginx/html/laravel/app
# chown -R nginx.nginx storage

とりあえず...

http://localhost/laravel/public/

にアクセスしてみた。

何じゃこりゃw おめでとう的な?w

laravel