Debian(树莓派)下搭建LNMP

来源:互联网 发布:c语言substring 编辑:程序博客网 时间:2024/05/21 11:34

一、更新apt安装源
sudo apt-get install update

二、安装nginx
sudo apt-get install nginx
安装完成后,使用sudo service nginx start启动服务
nginx -v查看当前安装的版本

三、安装php

使用apt工具安装:
apt-get install php5-fpm php5-gd php5-mysql php5-curl

安装完成之后,可以使用“php5-fpm -v”查看PHP的版本。

四、配置nginx,使其支持php脚本的解释
打开nginx的配置文件:
sudo vi /etc/nginx/sites-enabled/default

  # Self signed certs generated by the ssl-cert package        # Don't use them in a production server!        #        # include snippets/snakeoil.conf;        root /var/www/html;#设置nginx访问的虚拟主机空间地址

将注释的地方按如下更改:

 # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000       #       location ~ \.php$ {               include snippets/fastcgi-php.conf; #包含fastcgi的配置文件               # With php5-cgi alone:               #fastcgi_pass 127.0.0.1:9000; #使用ip的方式请求cgi,即将http发来的php后缀的文件交由127.0.0.1:9000来处理,方法一               # With php5-fpm:               fastcgi_pass unix:/var/run/php5-fpm.sock;#使用socket文件的方式处理,方法二。其中unix:后面的地址为个人电脑上php5-fpm.sock的真实路径               #以上两种处理方式选择其一即可               }

更改完毕后,保存配置文件,重新启动nginx服务。

五.写一个php文件,测试一下就OK了

原创粉丝点击