1.Ubuntu15は最初からApache2が入っているのでまず削除する。
sudo systemctl stop apache2.service
sudo systemctl disable apache2.service
sudo apt-get remove apache2
2.nginxとphp5-fpmインストール
sudo apt-get install nginx php5-fpm
3.nginx設定ファイル編集
/etc/nginx/sites-available/default
location ~ \.php$ {
include snippets/fastcgi-php.conf; #この中身を下に表示
# With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
snippets/fastcgi-php.conf
# regex to split $uri to $fastcgi_script_name and $fastcgi_path
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# Check that the PHP script exists before passing it
try_files $fastcgi_script_name =404;
# Bypass the fact that try_files resets $fastcgi_path_info
# see: http://trac.nginx.org/nginx/ticket/321
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
fastcgi_index index.php;
include fastcgi.conf;
3.php5-fpm設定
/etc/php5/fpm/php.ini
cgi.fix_pathinfo=0
date.timezone = Asia/Tokyo
参考
https://www.howtoforge.com/tutorial/installing-nginx-with-php-and-mysql-on-ubuntu-lemp/