安装Nginx apt-get install nginx
systemctl start nginx ------设置nginx服务开机自启动 systemctl start nginx ------开启nginx服务 systemctl status nginx.service --------查看nginx状态
nginx -v
将www-data作为网站的根目录使用者,默认情况是root使用
chown www-data:www-data /usr/share/nginx/html/ -R
在安装nginx时候,默认创建用户www-data用户
cat /etc/passwd | grep www-data www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
安装mariadb数据库
apt-get install mariadb-server mariadb-client
配置mariadb数据库
mysql_secure_installation
安装PHP 插件
apt-get install php7.0 php7.0-fpm php7.0-mysql php-common php7.0-cli php7.0-common php7.0-json
PHP插件服务的启动及状态的查看
systemctl enable php7.0-fpm systemctl start php7.0-fpm systemctl status php7.0-fpm
vi /etc/nginx/sites-available/default
rm /etc/nginx/sites-enabled/default
vi /etc/nginx/conf.d/default.conf   -------将以下文本粘贴到文件中。 将192.168.1.108替换为您的实际服务器IP地址。
server {
  listen 80;
  listen [::]:80;
  server_name 192.168.1.108;      ----ip地址替换为自己的ip地址
  root /usr/share/nginx/html/;
  index index.php index.html index.htm index.nginx-debian.html;
  location / {
    try_files $uri $uri/ /index.php;
  }
  error_page 404 /404.html;
  error_page 500 502 503 504 /50x.html;
  location = /50x.html {
    root /usr/share/nginx/html;
  }
  location ~ \.php$ {
    fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    include snippets/fastcgi-php.conf;
  }
  location ~ /\.ht {
    deny all;
  }
}