LNMP搭建(yum)

时间:2023-07-14 22:50:11

CentOS官方镜像不提供nginx,
http://nginx.org
http://nginx.org/en/linux_packages.html#stable

yum install nginx
yum -y install php php-fpm
/etc/nginx/                         #配置文件目录
/etc/nginx/conf.d/default.conf #配置文件
/etc/nginx/fastcgi_params #fast-cgi
/etc/nginx/nginx.conf #主配置文件
/etc/nginx/scgi_params
/usr/share/nginx/html/index.html #默认首页
[root@localhost ~]# cat /etc/nginx/fastcgi_params
.....
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; //新添加
.....
[root@localhost ~]# vim /etc/nginx/conf.d/default.conf
......
location / {
root /usr/share/nginx/html;
index index.html index.htm index.php;
}
......
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
.......
service php-fpm restart
service nginx restart
[root@localhost ~]# chkconfig --level 345 php-fpm on
[root@localhost ~]# chkconfig --level 345 nginx on
root@localhost ~]# cat /usr/share/nginx/html/index.php
<?php
phpinfo();
?>