N
N
NeTLeaDeR2018-02-18 16:02:43
Nginx
NeTLeaDeR, 2018-02-18 16:02:43

How to link a domain to vps?

I'm trying to bind a domain to a vps (ubuntu 14.04)
File from sites-available (stuffplace.ru - name + domain name)

server
{
  include common/upstream;
  include common/php-fpm;
  include common/cache;
  listen	80;
  listen	443	ssl;	# использовать шифрование для этого порта
  root			/var/www/phalcon/public;
  index			index.php index.html index.htm;
  server_name		stuffplace.ru www.stuffplace.ru;
    location ~ \.php$ {
        try_files     $uri =404;

        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index /index.php;

        include fastcgi_params;
        fastcgi_split_path_info       ^(.+\.php)(/.+)$;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
  
  location ~* ".+\.(?:ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|css|swf|js|atom|jpe?g|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$"
  {
    access_log	off;
    log_not_found	off;
    expires		max;
  }

    # Настройки порта или сокета PHP-FPM производятся в файле "/etc/php5/fpm/pool.d/www.conf"
  fastcgi_pass	php-fpm;
  # Порядок важен - строчка "include fastcgi_params" должна быть первой
  include fastcgi_params;
  fastcgi_split_path_info			^(.+?\.php)(/.*)?$;
  # Вместо переменной "$document_root" можно указать адрес к корневому каталогу сервера и это желательно (см. http://wiki.nginx.org/Pitfalls)
  fastcgi_param	SCRIPT_FILENAME		$document_root$fastcgi_script_name;
  fastcgi_param	PATH_TRANSLATED		$document_root$fastcgi_script_name;
  # См. http://trac.nginx.org/nginx/ticket/321
  set		$path_info		$fastcgi_path_info;
  fastcgi_param	PATH_INFO		$path_info;
  # Additional variables
  fastcgi_param	SERVER_ADMIN		[email protected];
  fastcgi_param	SERVER_SIGNATURE	nginx/$nginx_version;
  fastcgi_index	index.php;
  
    location ~ /\.ht {
        deny all;
    }

  upstream php-fpm
  {
    # PHP5-FPM сервер
    server unix:/var/run/php5-fpm.sock;
  }
}

If I create a symbolic link in sites-enabled nginx gives an error
[emerg] 9238#0: "upstream" directive is not allowed here in /etc/nginx/common/upstream:2

How to fix?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Twelfth Doctor, 2018-02-18
@verdex

upstream must be outside the server

upstream php-fpm
  {
    # PHP5-FPM сервер
    server unix:/var/run/php5-fpm.sock;
  }
server
{
  include common/upstream;
  include common/php-fpm;
  include common/cache;
  listen	80;
  listen	443	ssl;	# использовать шифрование для этого порта
  root			/var/www/phalcon/public;
  index			index.php index.html index.htm;
  server_name		stuffplace.ru www.stuffplace.ru;
   ...
}

And why do you need upstream if you write
location ~ \.php$ {
        try_files     $uri =404;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index /index.php;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question