Установка и настройка nginx + php + phpMyAdmin под Debian 9…

Устанавливаем nginx

apt install nginx

Устанавливаем PHP-FPM

apt install php7.0-fpm php7.0-cgi php7.0-mcrypt php7.0-gd php7.0-mysqli

Настраиваем nginx и приводим файл /etc/nginx/nginx.conf к виду…

user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
	worker_connections 1025;
	# multi_accept on;
	use epoll;
}

http {

	##
	# Basic Settings
	##

	sendfile on;
	tcp_nopush on;
	tcp_nodelay on;
	keepalive_timeout 65;
	types_hash_max_size 2048;
	# server_tokens off;

	# server_names_hash_bucket_size 64;
	# server_name_in_redirect off;

	include /etc/nginx/mime.types;
	default_type application/octet-stream;

	##
	# SSL Settings
	##

	ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
	ssl_prefer_server_ciphers on;

	##
	# Logging Settings
	##

	access_log /var/log/nginx/access.log;
	error_log /var/log/nginx/error.log;

	##
	# Gzip Settings
	##

	gzip on;
	gzip_disable "msie6";

	# gzip_vary on;
	# gzip_proxied any;
	# gzip_comp_level 6;
	# gzip_buffers 16 8k;
	# gzip_http_version 1.1;
	# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

	##
	# Virtual Host Configs
	##

	include /etc/nginx/conf.d/*.conf;
	include /etc/nginx/sites-enabled/*;
}

Далее в /etc/nginx/sites-enabled создаем файл dimanao.cf.conf (ставить свой домен)

server {
  listen 80;

  server_name dimanao.cf;
  charset utf-8;

  root /var/www/dimanao.cf;
  index index.html index.htm index.php;

  access_log /var/log/nginx/dimanao.cf_access.log;
  error_log /var/log/nginx/dimanao.cf_error.log;
  include /etc/nginx/templates/php-fpm.conf;

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/dimanao.cf/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/dimanao.cf/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


    if ($scheme != "https") {
        return 301 https://$host$request_uri;
    } # managed by Certbot

   location /sqlad/ {                               
            alias       /usr/share/phpmyadmin/;
            index       index.html index.htm index.php;
        }       

}

server {
 
  listen 80; 
 
  server_name dimanao.cf;
  rewrite ^(.*) http://dimanao.cf$1 permanent;
}

Устанавливаем phpmyadmin

apt install phpmyadmin
ln -s /usr/share/phpmyadmin /var/www/dimanao.cf/sqlad

Устанавливаем mysql и создаём пользователя

apt install mysql-server mysql-client
mysql -u root -p
USE mysql;
CREATE USER 'phpmyadmin'@'localhost' IDENTIFIED BY 'some_pass';
GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
Posted in *nix, Admin, Web