LNMP:Linux + Nginx + MySQL+PHP
LAMP:Linux + Apache + MySQL+PHP
四种软件均为免费开源软件,组合到一起,成为一个免费、高效、扩展性强的网站服务系统
安装epel扩展源
[root@localhost ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
安装LNMP环境所需要的安装包
[root@localhost ~]# yum install nginx mariadb-server php php-mysql php-gd php-fpm -y
php-frm配置
[root@localhost ~]# vim /usr/local/nginx/conf/nginx.conf
添加在server前面
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
php配置
[root@localhost ~]# vim /etc/php.ini
date.timezone = "Asia/shanghai"
cgi.fix_pathinfo=0
启动服务
[root@localhost ~]# systemctl restart nginx mariadb php-fpm
测试协同工作
测试nginx和php的协同
[root@localhost ~]# cd /usr/local/nginx/html/
[root@localhost html]# vim phpinfo.php
<?php
phpinfo();
?>