LEMP stack restarting error

February 15, 2013 10.3k views
I followed the LEMP stack tutorial at https://www.digitalocean.com/community/articles/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-12-04 and after configuring nginx (step6) when I restart nginx it says:
nginx: [emerg] "fastcgi_pass" directive is duplicate in /etc/nginx/sites-enabled/default:69
nginx: configuration file /etc/nginx/nginx.conf test failed
3 Answers
As it says, you got the fastcgi_pass variable two times in your configs. Remove one of em.
Open your /etc/nginx/sites-enabled/default and find fastcgi_pass you have written two times. remove one
Example
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

# # With php5-cgi alone:
fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;

}

Comment one directive. You have both uncommented. just do this as mine.

# pass PHP scripts to FastCGI server
#
location ~ .php$ {
include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
fastcgipass unix:/var/run/php/php7.2-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi
pass 127.0.0.1:9000;
#}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    location ~ /\.ht {
            deny all;
    }

}

Have another answer? Share your knowledge.