Jump to content

Not getting IPS4 URLs to work within MAMP and Nginx


Ivo Pereira

Recommended Posts

Posted

Hello,

As I was looking to develop some plugins, I've seen the best way to test it with an IPS installation would be to install IPS locally. So that's what I did.

I've installed MAMP - running Nginx - (as I've seen in another topic here that it is what some staff uses) and I've copied my licensed copy from my live server to localhost as well as the database. I've changed the settings in conf_global.php, gave some permissions, and the forum homepage seemed to be working. At least, until I've clicked any link.

URL rewrite was not working at all. As my live server is Nginx either, I guessed that the settings I had on my live server would be similar to the one that I should apply to MAMP, however it doesn't look like it is working.

Here is my Nginx, right from MAMP with minor changes that I've got from my live server: My root in localhost is http://localhost:7888/ipb/

user                         ivopereira staff;
worker_processes             2;
 
events {
    worker_connections       1024;
}
 
http {
        client_max_body_size 100M;
    include                              mime.types;
    default_type             text/html;
        gzip                     on;
        gzip_types               text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon;
    fastcgi_read_timeout        300;
    sendfile                 on;
 
        server {
                listen               7888 default_server;
 
                # MAMP DOCUMENT_ROOT !! Don't remove this line !!
                root                 "/Applications/MAMP/htdocs";
 
                access_log           /Applications/MAMP/logs/nginx_access.log;
                error_log            /Applications/MAMP/logs/nginx_error.log debug;
 
                location / {
                        index            index.html index.php;
                }
                       
                location ~* /MAMP/(.*)$ {
                        root             /Applications/MAMP/bin;
                        index            index.php;
 
                        location ~ \.php$ {
                                try_files        $uri =404;
                                fastcgi_pass     unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI.sock;
                                fastcgi_param    SCRIPT_FILENAME $document_root$fastcgi_script_name;
                                include          fastcgi_params;
                        }
                }
               
                location ~* /ipb(.*)$ {
                        index            index.php;
                        try_files $uri $uri/ /index.php?$is_args$args;
 
                        location ~ \.php$ {
                                try_files        $uri =404;
                                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                                fastcgi_pass     unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI.sock;
                                fastcgi_index index.php;
                                fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
                                include fastcgi_params;
 
                        }
                }
 
 
                location ~* /phpMyAdmin(.*)$ {
                        root             /Applications/MAMP/bin;
                        index            index.php;
 
                        location ~ \.php$ {
                                try_files        $uri =404;
                                fastcgi_pass     unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI.sock;
                                fastcgi_param    SCRIPT_FILENAME $document_root$fastcgi_script_name;
                                include          fastcgi_params;
                        }
                }
 
                location ~* /phpPgAdmin(.*)$ {
                        root             /Applications/MAMP/bin;
                        index            index.php;
 
                        location ~ \.php$ {
                                try_files        $uri =404;
                                fastcgi_pass     unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI.sock;
                                fastcgi_param    SCRIPT_FILENAME $document_root$fastcgi_script_name;
                                include          fastcgi_params;
                        }
                }
               
                location ~* /phpLiteAdmin(.*)$ {
                        root             /Applications/MAMP/bin;
                        index            index.php;
 
                        location ~ \.php$ {
                                try_files        $uri =404;
                                fastcgi_pass     unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI.sock;
                                fastcgi_param    SCRIPT_FILENAME $document_root$fastcgi_script_name;
                                include          fastcgi_params;
                        }
                }
               
                location ~* /SQLiteManager(.*)$ {
                        root             /Applications/MAMP/bin;
                        index            index.php;
 
                        location ~ \.php$ {
                                try_files        $uri =404;
                                fastcgi_pass     unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI.sock;
                                fastcgi_param    SCRIPT_FILENAME $document_root$fastcgi_script_name;
                                include          fastcgi_params;
                        }
                }
               
                location /icons {
                        alias /Applications/MAMP/Library/icons;
                        autoindex on;
                }
               
                location /favicon.ico {
                        alias /Applications/MAMP/bin/favicon.ico;
            # log_not_found off;
            # access_log off;
                }
 
                location ~ \.php$ {
                        try_files        $uri =404;
                        fastcgi_pass     unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI.sock;
                        fastcgi_param    SCRIPT_FILENAME $document_root$fastcgi_script_name;
                        include          fastcgi_params;
                }
 
                location ~ /\. {
                        deny all;
                }
 
                # location ~* \.(gif|jpg|png|pdf)$ {
        #       expires          30d;
                # }
 
                # location = /robots.txt {
        #       allow all;
        #       log_not_found off;
        #       access_log off;
                # }
 
            # location ~* \.(txt|log)$ {
        #       allow 127.0.0.1;
        #       deny all;
                # }
               
                # location ~ \..*/.*\.php$ {
        #       return 403;
                # }
 
                location /nginx_status {
                        stub_status      on;
                        access_log       off;
                        allow            127.0.0.1;
                        deny                     all;
                }
        }
 
    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;
 
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;
 
    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;
 
        #        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;
 
    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
}

(I thought about placing this in pastebin but meh.. anyone could need this topic in future)

Any ideas on what I am missing?

Posted

Try to remove "?$is_args$args" from try_files $uri $uri/ /index.php?$is_args$args;

It also would seem that the try_files inside this part:

location ~ \.php$ {
                                try_files        $uri =404;
                                fastcgi_pass     unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI.sock;
                                fastcgi_param    SCRIPT_FILENAME $document_root$fastcgi_script_name;
                                include          fastcgi_params;
                        }

Might override the previous try_files above, so you could try to remove that.

Posted

@TSP thanks for your answer but it did not help. I've tried removing it but it did not work.

Same thing for php block. As far as I know the precedence always come from the block you are accessing it - I'm new in Nginx, however I guess it's like that.

Anyway, after 3 days trying to solve this, I've gone through another option. Installing all the stuff with homebrew, and got it working after 5 minutes.

For those who find this topic and want to try out, this is the tutorial I've followed:

http://blog.frd.mn/install-nginx-php-fpm-mysql-and-phpmyadmin-on-os-x-mavericks-using-homebrew/

And my current Nginx file:

server {
    listen       80;
    server_name  localhost;
    root       /var/www/ipb;
    index      index.php;

    access_log  /usr/local/etc/nginx/logs/default.access.log  main;

    location / {
        try_files $uri $uri/ /index.php?$is_args$args;
        include   /usr/local/etc/nginx/conf.d/php-fpm;
    }

    location = /info {
        allow   127.0.0.1;
        deny    all;
        rewrite (.*) /.info.php;
    }

    error_page  404     /404.html;
    error_page  403     /403.html;
}

Simple and working!

Thanks!

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...