Install Nginx
Add repository
$ sudo rpm --import http://nginx.org/keys/nginx_signing.key
$sudo rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
Install
$ sudo yum install nginx
Add server
$ sudo systemctl enable nginx
start Nginx
$ sudo systemctl start nginx
Enter the browser
Nginxis runnging…
Install MariaDB
Install
$sudo yum install mariadb-server mariadb
Add server
$ sudo systemctl enable mariadb
Start MariaDB
$ sudo systemctl start mariadb
Set security – MariaDB must run
$ sudo mysql_secure_installation
Set root pwd : [you key]
Remove anonymous users : y
Disallow root login remotely : n(If youwant to remote connect to the database)
Remove test database and access to it : y
Reload privilege tables now? : y
Set success!
Install PHP
intstall
$ sudo yum install php php-mysql php-fpm
php-fpm configuration file with root privileges
$ vi /etc/php.ini
Edit
cgi.fix_pathinfo=0
Add server
$ sudo systemctl enable php-fpm
start php-fpm
$ sudo systemctl start php-fpm
Disable httpd
$ sudo systemctl disable httpd
Set Nginx
$ vi /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.php index.html index.htm;
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
charset utf-8;
#access_log /var/log/nginx/log/host.access.log main;
location /{
}
error_page 404 /404.html;
#redirect server error pages to the static page /50x.html
error_page 500502503504/50x.html;
location =/50x.html {
}
# nginx passes PHP scripts to FastCGIserver via a TCP/9000 socket
#this setting much be consistent with /etc/php-fpm.d/www.conf
# try_files prevents nginx from passing badscripts to FastCGI server
location ~ \.php$ {
try_files$uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_indexindex.php;
fastcgi_paramSCRIPT_FILENAME $document_root$fastcgi_script_name;
includefastcgi_params;
}
}
Restart Nginx
$ sudo systemctl restart nginx
Test php processing on Nginx
$ vi /usr/share/nginx/html/phpinfo.php
phpinfo.php
<?php phpinfo();?>
Enter the browser
Ifshow php.ini , then configure it successfully….
Deleteindex, display directory browse
Enter thebrowser
Youcan see the directory….