663424 发表于 2017-2-10 13:24:45

debian8.7.1安装lnmp

                      1.安装方式:aptitude方式一键安装
2.安装较新的版本,默认debian没有,所以先添加源。vim /etc/apt/source.list
2.1Nginx源
deb http://nginx.org/packages/mainline/debian/ jessie nginx
deb-src http://nginx.org/packages/mainline/debian/ jessie nginx
2.2php7.0源
deb http://packages.dotdeb.org jessie all
deb-src http://packages.dotdeb.org jessie all
2.3导入nginx及php7.0公钥

#wget http://nginx.org/packages/keys/nginx_signing.key
#apt-key add nginx_signing.key
#wget https://www.dotdeb.org/dotdeb.gpg
#sudo apt-key add dotdeb.gpg
2.4 更新源aptitude update
3.安装Nginx-1.11.9
#aptitude install nginx
3.1检查版本
root@debian:~# /usr/sbin/nginx -v /-V信息更详细
nginx version: nginx/1.11.9
4.安装Mysql,会提示输入mysql管理员密码,输完两次即可。
#aptitude install mysql-server
5.安装php7.0
#aptitude installphp7.0
#aptitude installphp7.0-mysql
#aptitude installphp7.0-fpm
#aptitude installphp7.0-curl php7.0-xml php7.0-mcrypt php7.0-json php7.0-gd php7.0-mbstring php-xml
5.1检查版本信息
root@debian:~# /usr/bin/php7.0 -v
PHP 7.0.15-1~dotdeb+8.1 (cli) ( NTS )

调试配置文件
nginx默认目录/etc/nginx/conf.d/default.conf ,请先备份。
#vim /etc/nginx/conf.d/default.conf
server {
    listen       80;
    server_namelocalhost;

    location / {
      root   /usr/share/nginx/html;
      indexindex.php index.html index.htm;
    }

    error_page   500 502 503 504/50x.html;
    location = /50x.html {
      root   /usr/share/nginx/html;
    }

    location ~ \.php($|/) {
         try_files $uri =404;
         root         /usr/share/nginx/html;         

         fastcgi_pass   unix:/run/php/php7.0-fpm.sock;
         fastcgi_indexindex.php;                  
         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
         include      fastcgi_params;                                  
   }

    #日志错误提示:/usr/share/nginx/html/favicon.ico" failed 添加如下#
    location = /favicon.ico {
                log_not_found off;
   }
}

PHP默认配置文件目录/etc/php/7.0/fpm/pool.d/www.conf
listen = /run/php/php7.0-fpm.sock #跟nginx的配置监听一样

报错:cat /var/log/nginx/error.log
提示无权限访问 fastcgi
nginx.conf 及 /etc/php/7.0/fpm/pool.d/www.conf 两个的user gruop账号不一致。


最后测试了,
vim /usr/share/nginx/html/index.php
<?php
phpinfo ();
?>


网页输入ip,显示php信息了。


友情提示:
若是不知道目录在哪可以whereis php7.0   whereis nginx
                  

页: [1]
查看完整版本: debian8.7.1安装lnmp