Last active
August 29, 2022 07:28
-
-
Save kenzo0107/d78d609bb213a1db08b4 to your computer and use it in GitHub Desktop.
Revisions
-
kenzo0107 revised this gist
Jul 21, 2015 . 1 changed file with 24 additions and 20 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -63,14 +63,32 @@ $ chmod -R 0777 storage/ ###### user / group を nginx に設定 /etc/php-fpm.d/www.conf 編集 ``` # TCP/IP でなく Unix Socket通信で高速化 - listen = 127.0.0.1 + listen = /var/run/php-fpm/php-fpm.sock - user = apache + user = nginx - group = apache + group = nginx - listen.user = apache + listen.user = nginx - listen.group = apache + listen.group = nginx ``` ``` # systemctl restart php-fpm # systemctl enable php-fpm ``` ## Nginx 設定 * Nginx で php-fpmを利用する。 @@ -88,23 +106,16 @@ server { listen 80; server_name ec2-xx-xx-xxx-xx.ap-northeast-1.compute.amazonaws.com; # Document Root設定 root /usr/share/nginx/<project_name>/public; # Indexファイル設定 index index.php index.html index.htm; error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } location / { try_files $uri $uri/ /index.php?$query_string; } @@ -123,13 +134,6 @@ server { include fastcgi_params; } } ``` -
kenzo0107 revised this gist
Jul 21, 2015 . 1 changed file with 6 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -112,10 +112,15 @@ server { location ~ \.php$ { try_files $uri /index.php =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_max_temp_file_size 0; fastcgi_buffer_size 4K; fastcgi_buffers 64 4k; include fastcgi_params; } -
kenzo0107 revised this gist
Jul 21, 2015 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -66,6 +66,8 @@ $ chmod -R 0777 storage/ ``` # sed -i -e 's/user = apache/user = nginx/' /etc/php-fpm.d/www.conf # sed -i -e 's/group = apache/group = nginx/' /etc/php-fpm.d/www.conf # sed -i -e 's/listen.user = apache/listen.user = nginx/' /etc/php-fpm.d/www.conf # sed -i -e 's/listen.group = apache/listen.group = nginx/' /etc/php-fpm.d/www.conf # systemctl restart php-fpm # systemctl enable php-fpm ``` -
kenzo0107 revised this gist
Jul 21, 2015 . No changes.There are no files selected for viewing
-
kenzo0107 revised this gist
Jul 21, 2015 . 1 changed file with 11 additions and 13 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -86,14 +86,12 @@ server { listen 80; server_name ec2-xx-xx-xxx-xx.ap-northeast-1.compute.amazonaws.com; root /usr/share/nginx/<project_name>/public; index index.php index.html index.htm; #charset koi8-r; #access_log /var/log/nginx/log/host.access.log main; #error_page 404 /404.html; # redirect server error pages to the static page /50x.html @@ -103,17 +101,17 @@ server { root /usr/share/nginx/html; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { try_files $uri /index.php =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; #fastcgi_pass 127.0.0.1:9000; fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; -
kenzo0107 renamed this gist
Jul 16, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
kenzo0107 revised this gist
Jul 16, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ # CentOS 7 + Nginx + MySQL5.6 + PHP5.6 (Laravel5.1) インストール nginx+php-fpmで動作確認まで ## 環境 -
kenzo0107 revised this gist
Jul 16, 2015 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -49,10 +49,12 @@ Laravelはcomposerからインストールする為、必要になります。 ※2015/07/16時点ではバージョン `5.1.7` 以下<user>, <group> は適宜修正してください。 ``` $ cd /usr/share/nginx $ composer create-project laravel/laravel <project_name> dev-master --prefer-dist $ sudo chmod -R <user>:<group> <project_name> $ cd <project_name> $ chmod -R 0777 storage/ ``` -
kenzo0107 renamed this gist
Jul 16, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
kenzo0107 created this gist
Jul 16, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,135 @@ # CentOS 7 + Nginx + MySQL5.6 + PHP5.6 (Laravel5) インストール ## 環境 * AWS EC2 t2.micro * CentOS Linux release 7.0.1406 (Core) * PHP 5.6.11 * MySQL 5.6 * Laravel Framework version 5.1.7 (LTS) --- # Nginx インストール <https://gist.github.com/kenzo0107/7436d67051ee28f24965> ## PHP 5.6 インストール <http://kenzo0107.hatenablog.com/entry/2015/07/16/114113> ## MySQL 5.6 <http://kenzo0107.hatenablog.com/entry/2015/07/16/154810> --- # Laravel インストール 上記までで以下がインストールされている状態です。 * Nginx 1.9.3 * php 5.6 * MySQL 5.6 ## composerインストール Laravelはcomposerからインストールする為、必要になります。 ``` # curl -sS https://getcomposer.org/installer | php # mv composer.phar /usr/local/bin/composer ``` ## Laravelを `/usr/share/nginx/` にインストール ※2015/07/16時点ではバージョン `5.1.7` ``` $ cd /usr/share/nginx $ composer create-project laravel/laravel <project_name> dev-master --prefer-dist $ sudo chmod -R nginx:nginx <project_name> $ cd <project_name> $ chmod -R 0777 storage/ ``` ## php-fpm 設定 ###### user / group を nginx に設定 ``` # sed -i -e 's/user = apache/user = nginx/' /etc/php-fpm.d/www.conf # sed -i -e 's/group = apache/group = nginx/' /etc/php-fpm.d/www.conf # systemctl restart php-fpm # systemctl enable php-fpm ``` ## Nginx 設定 * Nginx で php-fpmを利用する。 * ドキュメントルートを <project_name>/public/ディレクトリに設定する。 ##### nginx default.conf設定 ``` # vi /etc/nginx/conf.d/default.conf ``` ``` server { listen 80; server_name ec2-xx-xx-xxx-xx.ap-northeast-1.compute.amazonaws.com; #charset koi8-r; #access_log /var/log/nginx/log/host.access.log main; location / { root /usr/share/nginx/<project_name>/public; index index.php index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { root /usr/share/nginx/<project_name>/public; 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 # #location ~ /\.ht { # deny all; #} } ``` ## Laravel Topページにアクセス 以下の様に表示されればひとまず設定完了です。  以上