LEMP stack On CentOS 7

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

http://localhost


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

http://localhost/phpinfo.php


Ifshow php.ini , then configure it successfully….

Deleteindex, display directory browse

Enter thebrowser

http://localhost


Youcan see the directory….

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值