Cannot figure out why nginx continues to redirect to the Welcome to nginx page. I am trying to install and run an open source app (question2 answer). Just trying to get it to run locally in my VM first.
I am on a vagrant vm machine. Ubuntu running 16.04. I edited my /etc/hosts files in my local machine to match those in my vagrant box. Ive tried different tutorials as well as SO but still redirecting to welcome page
This is my server file
server {
#Nginx should listen on port 80 for requests to yoursite.com
listen 80;
listen [::]:80;
#Create access and error logs in /var/log/nginx
access_log /var/log/nginx/yoursite.access_log main;
error_log /var/log/nginx/yoursite.error_log info;
#Nginx should look in /var/www/q2a for website
root /var/www/q2a.org/q2a/;
#The homepage of your website is a file called index.php
index.php;
server_name local-q2a.org;
#Specifies that Nginx is looking for .php files
location ~ \.php$ {
#If a file isn’t found, 404
try_files $uri =404;
#Include Nginx’s fastcgi configuration
include /etc/nginx/fastcgi.conf;
#Look for the FastCGI Process Manager at this location
fastcgi_pass unix:/run/php/php7.1-fpm.sock;
fastcgi_param HTTP_X_FORWARDED_FOR
$http_x_forwarded_for;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
}
}
I am trying to get the app to run at least locally.
Thought I'd post an answer in case anyone was struggling with a similar issue. Below is my code. I also had to create a symlink from my sites available to my sites enabled. In addition, I edited my etc files with my private network vagrant box to the specified URL I wanted. Then I got fancy and linked that to ngrok and made it live on the internet for demo purposes.
server {
listen 80;
listen [::]:80;
root /var/www/html/question2answer;
index index.php index.html index.htm;
server_name local-q2a.org www.local-q2a.org;
client_max_body_size 100M;
autoindex off;
location / {
try_files $uri @question2answer;
}
location @question2answer {
rewrite /index.php$uri last;
}
location ~* "^/index\.php(/|$)" {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~* "\.php(/|$)" {
rewrite ^ /index.php$uri last;
}
}