Topic: nginx config problem running wordpress on iredmail setup

- iRedMail version (check /etc/iredmail-release): 0.9.9 MYSQL edition.
- Deployed with iRedMail Easy or the downloadable installer? - Downloaded & ran iRedMail.sh
- Linux/BSD distribution name and version: Ubuntu 16.04 LTS
- Store mail accounts in which backend: MySQL
- Web server (Apache or Nginx): nginx
- Manage mail accounts with iRedAdmin-Pro? - not pro - the free version
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue: There are no access.log or error.log messages related to this problem.

I have installed iredmail on a clean server running ubuntu 16. iredmail and all its functions are working PERFECTLY.

My question here relates to moving wordpress websites of mine on to this same server and the problems I'm running into there.

I began by putting my own custom php code on to the server, and that worked great when I did it like this: I put it all in /var/www/html/xxx/ - where xxx is my php system.

I can therefore access and run my php fine from the ip address like:

However, I'm totally stumped when moving in my wordpress. My wordpress
site is bannedyoutube.com. I even used certbot to set up an SSL certificate for it.

Below is my file bannedyoutube.conf.

As you can see I've been experimenting. I created 2 blocks.
The top block is something I got from a website, which aims to redirect
www.bannedyoutube.com to bannedyoutube.com

The 2nd block was the main block for bannedyoutube.com. Later what I did as an experiment was to move 2 of the SSL 443 lines to the top of
the block to see if it helps. 

Here is what actually happens with it:-
If I type: in my browser, I then see the wordpress website showing.

But if I type: http://bannedyoutube.com then it tries to download the index.php of my website.

In the config file below you'll see that I tried to have some code for
.php because for some reason, the nginx is not executing the php. In
fact the php section in my config: # Normal PHP scripts - is what I
found in the nginx templates that iredmail had installed.

I could not understand why .php is not EXECUTED when it is run via
the config file I made for the wordpress.

I have tried error logging and checking the access logs.

I don't know what to do. Can someone help me please.

Here is bannedyoutube.conf:

server {
    listen 80;
    listen 443 ssl;
# redirect calls to www: url: https://www.nginx.com/blog/creating-ngi … ite-rules/
    server_name www.bannedyoutube.com;
    return 301 $scheme://bannedyoutube.com$request_uri;

server {
    listen       80;
    listen       [::]:80;
    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot

    server_name  bannedyoutube.com;
#    access_log   /var/log/nginx/fred.access.log;

#    error_log /var/log/nginx/yoursite.error_log info;
    error_log /var/log/nginx/bannedyoutube.error_log debug;
    rewrite_log on;
#    error_log /var/log/nginx/bannedyoutube.error_log notice;

# this works. It creates a new root location for everything
#location / {
#root /var/www/;

    root  /var/www/html/bannedyoutube/public_html/;
    index index.php index.html index.htm;

# Normal PHP scripts
location ~ \.php$ {
    include /etc/nginx/templates/fastcgi_php.tmpl;

    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

# pass the PHP scripts to FastCGI server listening on
#  location ~ \.php$ {
#    try_files $uri =404;
#    fastcgi_pass unix:/var/run/php/php7.0-fpm.pid;
#    fastcgi_index index.php;
#    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#    include fastcgi_params;
#  }

    ssl_certificate /etc/letsencrypt/live/bannedyoutube.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/bannedyoutube.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

2 (edited by fr 2019-07-26 15:34:55)

Re: nginx config problem running wordpress on iredmail setup

Hello. I had a similar problem long ago.
I solved by adding:
1) in the default.conf file I simply set the RETURN of the site to https
2) in the default-ssl.conf file instead I set all the site configuration.
I hope I was helpful.

...at the end of the site configuration you need to include (INCLUDE) the php template (now I can't remember what it's called, just find it among the templates ...)