I’m trying to deploy this PHP app that was developed by a third-party web developer. I have no idea how exactly this was written so the nginx configuration file I’m using isn’t working. When I access the root URL (www.example.com), it shows the homepage fine but none of the functionalities on the homepage work. For example, clicking on the Search changes the URL to the query - www.example.com/search?limit_s=0&limit_e=10 but it doesn’t lead to the search result page. The homepage just refreshes. The same happens for other pages as well. There’s a button for creating new blog posts. If I click on that, the URL changes to https://example.com/make-an-entry but it just refreshes the homepage, doesn’t lead me to the page for creating new posts.
This is the nginx config I’m using currently:
server {
server_name example.com www.example.com;
root /var/www/html/example;
index index.php index.html index.htm;
access_log /var/log/nginx/example.access.log;
error_log /var/log/nginx/example.error.log;
client_max_body_size 100M;
location / {
try_files $uri $uri/ /index.php?$query_string;
#try_files $uri $uri/ =404;
}
location ~ [^/]\.php(/|$) {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PHP_VALUE "memory_limit = 1024M";
include fastcgi_params;
}
listen [::]:443 ssl; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/example.com/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
}
server {
if ($host = www.example.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = example.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
server_name example.com www.example.com;
return 404; # managed by Certbot
}
I’m not exactly allowed to reveal the actual URL right now but if it can’t be helped at all, I can give you the link to visit the site.
Thanks a lot in advance!
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
location / {
try_files $uri $uri/ /index.php?$query_string;
#try_files $uri $uri/ =404;
}
Remove the second line and its should be like this. You are passing the URL with index.php so how will it work my dear friend.
location / {
try_files $uri $uri/ =404;
}
Anyways, Welcome in Advance, Your Friend from devopsbro.com
Hello,
You should be able to use
location / {
try_files $uri $uri/ /index.php?$args;
#try_files $uri $uri/ =404;
}
Additionally, I would assume the website was built on Apache and it had .htaccess where it had some mandatory rules. I would recommend contacting the third-party web developer and asking them what’s needed to configure it properly.
Regards, KFSys
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.