一、lnmp安装
lnmp的安装参照了某博客网站上的教程,实用其安装脚本,省去了很多事。教程地址如下:
https://blog.linuxeye.cn/31.html
二、配置
1、PHP配置
进入php的安装位置,使用上面脚本安装默认安装在/usr/local/php下,在/usr/local/php/etc找到php.ini配置文件,将将cgi.fix_pathinfo的值改成1,然后service php-fpm reload重启;
2、nginx配置
进入路径下/usr/local/nginx/conf/vhost,新建一个.conf文件,文件内容如下:
server {
listen 80;
server_name goooooo.top www.goooooo.top;
access_log /data/wwwlogs/www.goooooo.top_access.log;
error_log /data/wwwlogs/www.goooooo.top_error.log;
set $root /data/wwwroot/www.goooooo.top/public;
location ~ .*\.(gif|jpg|jpeg|bmp|png|ico|txt|js|css)$
{
root $root;
}
location / {
root $root;
index index.html index.php;
if ( -f $request_filename) {
break;
}
if ( !-e $request_filename) {
rewrite ^(.*)$ /index.php/$1 last;
break;
}
}
location ~ .+\.php($|/) {
fastcgi_pass unix:/dev/shm/php-cgi.sock;
fastcgi_split_path_info ^((?U).+.php)(/?.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $root$fastcgi_script_name;
include fastcgi_params;
}
}
具体内容不一一细说了,关键注意的是下面这段内容
fastcgi_pass unix:/dev/shm/php-cgi.sock;
上面这段内容主要看你的php-fpm.conf上面的配置,路径是/usr/local/php/etc,比如我的php-fpm.conf配置是
[www]
listen = /dev/shm/php-cgi.sock
listen.backlog = -1
listen.allowed_clients = 127.0.0.1
listen.owner = www
listen.group = www
listen.mode = 0666
user = www
group = www
三、注意
以上内容只针对上面的安装脚本进行过测试,其他的安装方法未必有效
四、参考地址:
http://www.thinkphp.cn/topic/40391.html
https://www.cnblogs.com/xuey/p/7631690.html
https://blog.csdn.net/qq_35912734/article/details/78477924