17
17

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 5 years have passed since last update.

Centos6.5にNginx+hhvm+mysql+Laravelをインストールしてみた

Last updated at Posted at 2014-07-12

タイトル通り
メモ用にさくっと
全部root権限でやってます。

###Nginx(1.6)インストール

nginx
rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm

yum -y install nginx

#↓コンフィグ設定(ドキュメントルートを/var/www/html/laravel/publicにしています)
sed -i -e '9s/\/usr\/share\/nginx\/html/\/var\/www\/html\/laravel\/public/' /etc/nginx/conf.d/default.conf

#10行目にindex.phpを追加

#↑と同じdefault.confの location / { のネストの中に下記を追加(後で追加したので何行かは覚えていない)
#ネットで try_files \$uri \$uri/ /index.php?\$query_string;
#のような形で書いているサイトがあるがそれだと laravel使用時のpublic参照に問題があるので注意!
try_files $uri $uri/ /index.php?$query_string;


#↓ドメイン変更+ポート解放(公開サーバーのみ)
#sed -i -e '3s/localhost/[ドメイン名]/' /etc/nginx/conf.d/default.conf

iptables -I INPUT 5 -m state --state NEW -p tcp --dport 80 -j ACCEPT
service iptables save
service iptables restart

chkconfig nginx on

###hhvmインストール(hop5)

hhvm
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
cd /etc/yum.repos.d/
wget http://www.hop5.in/yum/el6/hop5.repo

#↓removeしてるので依存関係は慎重に
yum -y remove boost-filesystem-1.41.0-18.el6.x86_64
yum -y install hhvm
wget http://pkgrepo.linuxtech.net/el6/release/x86_64/liblcms2-2.4-1.el6.x86_64.rpm
yum -y install liblcms2-2.4-1.el6.x86_64.rpm

#↓nginxのコンフィグにfastcgiの項目を追加
sed -i -e "38i location \~ \\.php$ {\nfastcgi_pass   127.0.0.1:9000;\nfastcgi_index  index.php;\nfastcgi_param  SCRIPT_FILENAME  \$document_root\$fastcgi_script_name;\ninclude        fastcgi_params;\n}"  /etc/nginx/conf.d/default.conf

#logfileに書き込む設定
sed -i -e "5i UseLogFile = true\nFile = /var/log/hhvm/error.log"  /etc/hhvm/config.hdf 

#↓サーバー起動時にhhvm起動
sed -i -e '$ahhvm --mode daemon -vServer.Type=fastcgi -vServer.Port=9000' /etc/rc.d/rc.local 

hhvm --mode daemon -vServer.Type=fastcgi -vServer.Port=9000

###mysql(5.5)インストール

mysql
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
yum install -y perl-DBD-MySQL libaio libaio-devel openssl-devel
yum --enablerepo=remi --disablerepo=updates,base install -y mysql mysql-server mysql-devel

#ログ関連(人それぞれなので、その都度変えること)
sed -i -e "4i log-warnings=1" -e "4i slow-query-log=myerrorslow.log" -e "4i long-query-time=30" -e "4i log-queries-not-using-indexes" -e "4i log-slow-admin-statements" -e "4i log-bin=mysql-trans-log" -e "4i log-bin-index=mybin.index" -e "4i max-binlog-size=1G" -e "4i expire-logs-days=30" -e "4i binlog-do-db=ui"  /etc/my.cnf
#その他(人それぞれなので、その都度変えること)
sed -i -e "4i character-set-server = utf8" -e "4i collation-server = utf8_general_ci" -e "4i port = 3306"  -e "4i query_cache_size = 16M" -e "4i thread_cache_size = 4" -e "4i query_cache_limit = 16M" -e "4i tmp_table_size = 16M" -e "4i max_heap_table_size = 16M" -e "4i thread_cache_size = 4" -e "4i innodb_buffer_pool_size = 512M"  -e "4i innodb_log_file_size = 64M"  -e "4i open_files_limit = 1024" -e "4i max_connections = 100" /etc/my.cnf
sed -i -e '$a\n\[mysql\]\ndefault-character-set = utf8\n\n\[client\]\nport = 3306\n\n\[mysqldump\]' /etc/my.cnf

rm /var/lib/mysql/ib_logfile0
rm /var/lib/mysql/ib_logfile1

#↓パスワード初期設定とか
#mysql_secure_installation

chkconfig mysqld 

###laravel(4.2)+(Sentry2.1)インストール

laravel

#↓依存関係+composerインストール
yum -y install php php-mcrypt php-mbstring libmcrypt libmcrypt-devel libxml2 libxml2-devel openssl openssl-devel httpd httpd-devel
curl -sS https://getcomposer.org/installer | php -- --install-dir=/bin

#↓php5.4以上が必要なのでphp再インストール
yum remove php*
rpm -ivh  http://ftp-srv2.kddilabs.jp/Linux/distributions/fedora/epel/5/x86_64/epel-release-5-4.noarch.rpm
yum install --enablerepo=remi --enablerepo=remi-php55 php php-devel php-mbstring php-mcrypt php-mysql php-phpunit-PHPUnit php-pecl-xdebug php-cli

#↓laravelのプロジェクト作成
cd /var/www/html
composer.phar create-project laravel/laravel laravel

cd laravel
chmod 777 -R app/storage/

#↓/laravel/app/config/app.phpを変更()
sed -i -e '42s/UTC/Asia\/Tokyo/' /var/www/html/laravel/app/config/app.php
sed -i -e '55s/en/ja/' /var/www/html/laravel/app/config/app.php
#↓公開サーバーのみ
#sed -i -e '29s/localhost/[ドメイン]/' /var/www/html/laravel/app/config/app.php

#↓/laravel/app/config/database.phpを変更(mysqlで設定したuserなど)
#sed -i -e '58s/forge/[db]/' /var/www/html/laravel/app/config/database.php
#sed -i -e '59s/forge/[user]/' /var/www/html/laravel/app/config/database.php
#sed -i -e '60s/\'\'/[pass]/' /var/www/html/laravel/app/config/database.php

#↓sentryの記述を追加を変更
sed -i -e '7s/$/,/g' /var/www/html/laravel/composer.json
sed -i -e "8i \"cartalyst/sentry\": \"2.0.*\"" /var/www/html/laravel/composer.json

cd /var/www/html/laravel/
composer.phar update

sed -i -e "124i \'Cartalyst\\\Sentry\\\SentryServiceProvider\'," /var/www/html/laravel/app/config/app.php
sed -i -e "192i \'Sentry\'          => \'Cartalyst\\\Sentry\\\Facades\\\Laravel\\\Sentry\'," /var/www/html/laravel/app/config/app.php


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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?