rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum install nginx php php-fpm mariadb mariadb-server
firewall-cmd --zone=public --list-all
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload
firewall-cmd --zone=public --list-all
user nginx;
worker_processes 2; #by your cpu
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
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 on;
#tcp_nopush on;
server_tokens off;
keepalive_timeout 65;
gzip on;
include /etc/nginx/conf.d/*.conf;
}
server {
listen 80;
server_name localhost;
#charset koi8-r;
access_log /var/log/nginx/host.access.log main;
root /usr/share/nginx/html;
index index.html index.php index.htm;
location / {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# session path
# for mod_php, see /etc/httpd/conf.d/php.conf
# for php-fpm, see /etc/php-fpm.d/www.conf
cgi.fix_pathinfo=0
listen = /var/run/php-fpm/php-fpm.sock listen.owner = nobody listen.group = nobody listen.mode = 0666 user = nginx group = nginx
reference to https://twasa.github.io/post/my-db/
<?php
phpinfo();
?>
chown -R nginx:nginx /usr/share/nginx/html/
chcon --reference=/usr/share/nginx/html/index.html /usr/share/nginx/html/*