php7.2インストール
ninja@localhost:~$ sudo apt-get update
ninja@localhost:~$ sudo apt-get upgrade
ninja@localhost:~$ sudo apt-get install software-properties-common
ninja@localhost:~$ sudo add-apt-repository ppa:ondrej/php
ninja@localhost:~$ sudo apt-get update
ninja@localhost:~$ sudo apt-get install php7.2
ninja@localhost:~$ sudo apt-get install php7.2-mbstring php7.2-mysql
ninja@localhost:~$ sudo apt-get install php7.2-curl
ninja@localhost:~$ sudo apt-get install php7.2-xml php7.2-gd php7.2-zip php7.2-fpm
ninja@localhost:~$ sudo apt-get install php7.2-curl
apache削除
ninja@localhost:~$ sudo apt-get purge apache2 apache2-utils apache2-bin apache2-data
ninja@localhost:~$ sudo apt-get autoremove
/* apache2のフォルダの場所を探す。 */
ninja@localhost:~$ whereis apache2
ninja@localhost:~$ sudo rm -rf /etc/apache2
nginxインストール
ninja@localhost:~$ sudo apt-get install nginx
php7.2設定
ninja@localhost:~$ sudo vi /etc/php/7.2/cli/php.ini
post_max_size = 10M
cgi.fix_pathinfo=0
upload_max_filesize = 10M
ninja@localhost:~$ sudo vi /etc/php/7.2/fpm/php.ini
post_max_size = 10M
cgi.fix_pathinfo=0
upload_max_filesize = 10M
nginx設定
/etc/nginx/sites-available/default.
ninja@localhost:~$ sudo vi /etc/nginx/sites-available/default
/* 全て消して書き換える*/
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/html;
index index.php index.html index.htm;
#server_name XXX.net;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
/etc/nginx/nginx.conf
ninja@localhost:~$ sudo vi /etc/nginx/nginx.conf
# httpの中に追加以下を追加
client_max_body_size 10m; # defaule 1m
nginxの動作確認
ninja@localhost:~$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
ninja@localhost:~$ sudo service php7.2-fpm restart
ninja@localhost:~$ sudo service nginx restart
ninja@localhost:~$ sudo ufw app list
Available applications:
Nginx Full
Nginx HTTP
Nginx HTTPS
ninja@localhost:~$ sudo ufw allow 'Nginx Full'
ブラウザから動作確認
XXX.XXX.XXX.XXX/info.phpにアクセスして表示されればOK