Centos搭建LNMP开发环境

Author Avatar
Jason Zhang 9月 11, 2018
  • 在其它设备中阅读本文章

本文最近一次更新于 365 天前,其中所包含的信息很可能已经有所发展或是发生改变。

因为需要部署ThinkPHP网站,所以就得在服务器上搭建LNMP网站环境,过程有点碱性,把中途遇到的坑记录下来。

资源下载

安装Nginx

再centos7中安装依赖

yum -y install gcc gcc-c++ make zlib-devel pcre-devel openssl-devel
wget http://nginx.org/download/nginx-1.17.0.tar.gz
./configure

default.conf

server {
        server_name  your.domain;
        listen       443; ##这里自己选择
        ssl          on;
        ssl_certificate  /etc/nginx/conf.d/SSL/SSL.pem;
        ssl_certificate_key  /etc/nginx/conf.d/SSL/SSL.key;
        ssl_session_timeout 5m;
        root   "/usr/share/nginx/html/meme"; #网站目录
        location / {
            index  index.html index.htm index.php;
            #autoindex  on;
        }
        location ~ \.php(.*)$ {
            fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/html/meme$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  /usr/share/nginx/html/meme$fastcgi_path_info;
            include        fastcgi_params;
        }
}

php.in

cgi.fix_pathinfo=1 ##760行左右

www.conf

; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
;       will be used.
; RPM: apache Choosed to be able to access some dir as httpd
user = nginx
; RPM: Keep a group allowed to write in log dir.
group = nginx

php-fpm.conf

include=/etc/php-fpm.d/*.conf #最后一行修改

安装PHP环境以及扩展程序

安装php以及php-fpm.

yum install php php-fpm -y

配置php-fpm支持nginx。

www.conf中将`user = apache; group = apache改成user = nginx; group = nginx`

php.ini中;cgi.fix_pathinfo=1改成cgi.fix_pathinfo=0

安装MySQL

测试

本文标题: Centos搭建LNMP开发环境
最后更新:2019 年 05 月 19 日 - 14:05
本文链接:https://blog.jasonzhang.xyz/posts/75f6c94a/
本文采用:署名-非商业性使用-禁止演绎 4.0 国际 协议进行许可,阅读 相关说明