$ sudo yum update
$ sudo yum -y install wget
$ sudo yum -y install epel-release
$ wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
$ sudo rpm -ivh remi-release-7.rpm
$ sudo timedatectl set-timezone Asia/Tokyo
#Confirmation
$ date
$ sudo yum --enablerepo=epel install nginx
$ sudo vi /etc/nginx/conf.d/default.conf
default.conf
server {
listen 80;
server_name centos7;
root /var/www;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
include fastcgi_params;
}
}
sudo vi /etc/nginx/nginx.conf
nginx.conf
user nginx;
worker_processes auto;
worker_rlimit_nofile 100000;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 2048;
multi_accept on;
use epoll;
}
http {
server_tokens off;
include /etc/nginx/mime.types;
default_type text/html;
charset UTF-8;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile off;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 10;
client_header_timeout 10;
client_body_timeout 10;
reset_timedout_connection on;
send_timeout 10;
limit_conn_zone $binary_remote_addr zone=addr:5m;
limit_conn addr 100;
gzip on;
gzip_http_version 1.0;
gzip_disable "msie6";
gzip_proxied any;
gzip_min_length 1024;
gzip_comp_level 6;
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript application/json;
open_file_cache off;
client_max_body_size 20m;
server_names_hash_bucket_size 64;
include /etc/nginx/conf.d/*.conf;
}
$ nginx -t
$ sudo systemctl enable nginx
$ sudo systemctl start nginx
$ sudo systemctl status nginx
$ sudo yum install --enablerepo=epel,remi-php72 php php-mbstring php-fpm php-mcrypt php-mysql php-pdo php-json php-xml
If the PHP path does not pass, pass it
$ php -v
sudo vi /etc/php-fpm.d/www.conf
www.conf
user = nginx
group = nginx
listen = /var/run/php-fpm.sock
listen.owner = nginx
listen.group = nginx
sudo systemctl enable php-fpm
sudo systemctl start php-fpm
sudo systemctl status php-fpm
Please put phpinfo.php in the WEB folder and check the operation of PHP.
Recommended Posts