标签 php7 下的文章

在Debian 9系统里安装nginx + php7-fpm + MariaDB

环境:Debian 9.4,nginx 1.10.3,php7.0.27, MariaDB 10.1.26

过程:

  1. apt update # 更新软件源
  2. apt upgrade # 更新软件版本
  3. apt autoremove # 自动删除一些“遗留”的不必要软件
  4. apt install nginx # 安装 nginx
  5. apt install php-fpm php-gd php-mysql php-mbstring php-curl php-xml # 安装 php 及相关组件
  6. 编辑默认的nginx站点配置文件/etc/nginx/sites-enabled/default,添加 index.php 类型的默认首页文件,注释掉ipv6地址的监听及启用php

         # Add index.php to the list if you are using PHP
         index index.php index.html index.htm index.nginx-debian.html;
    
         server_name _;
    
         location / {
                 # First attempt to serve request as file, then
                 # as directory, then fall back to displaying a 404.
                 try_files $uri $uri/ =404;
         }
    
         # pass PHP scripts to FastCGI server
         #
         location ~ \.php$ {
                 include snippets/fastcgi-php.conf;
         #
         #       # With php-fpm (or other unix sockets):
                 fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
         #       # With php-cgi (or other tcp sockets):
         #       fastcgi_pass 127.0.0.1:9000;
         }
  7. systemctl restart nginx # 重启 nginx 服务,以让更改生效
  8. apt install mariadb-server # 安装 MariaDB (mysql)数据库服务端
  9. 通过 mysql 命令行,创建一个新的mysql用户
    CREATE USER 'idbadm'@'localhost' IDENTIFIED BY 'meizi36829';
    GRANT ALL PRIVILEGES ON . TO 'idbadm'@'localhost' WITH GRANT OPTION;
    FLUSH PRIVILEGES;
  10. 上传或下载一个phpmyadmin,用新建的mysql用户名和密码登录,测试正常