WordPress.org

Ready to get started?Download WordPress

Forums

WordPress with Nginx causing URL issues (15 posts)

  1. sameermanas
    Member
    Posted 2 years ago #

    Hi everyone,

    I recently igrated my website from another server and thought it would be better if changed from Apache to Nginx.

    My website is running on Nginx and Ubuntu. The problem is that homepage displays just fine but the articles when opened throw a 404 error.

    However if i change the permalinks to ?p=123 then everything works fine. But i badly need the custom permalink structure for the site.

    I've tried three to four different config files for Nginx but they don't work either.

    Can anyone help me out with the Nginx server issue. This is my web URL
    http://www.bloggerstack.com

    Thanks in advance.

  2. Arnoud
    Member
    Posted 2 years ago #

    I think this is what you are looking for: Nginx compatibility plugin

  3. sameermanas
    Member
    Posted 2 years ago #

    I already installed that plugin but there is no effect yet :/

    I guess the nginx conf files need some more code, but i am not well versed with the code.

  4. Pothi
    Member
    Posted 2 years ago #

    It looks like you are using PHP-FPM to serve PHP files. Also, it is advisable to disable W3 Total Cache until the permalinks issue is resolved. Please post your nginx conf. As it would be more than 10 lines, please consider using pastebin. Kindly remove any domain related info from there. Without looking at your nginx conf, it's not possible to help.

  5. sameermanas
    Member
    Posted 2 years ago #

    Here is the Nginx.conf.

    I had to use piratepad since pastebin wasn't working at the time.

    http://piratepad.net/nQbG669fqs

    This configuration was actually from https://github.com/perusio/wordpress-nginx

    It was created for nginx and wordpress, so i gave it a try. But none of them are working for me.

    @Pothi Kalimuthu: If you want to take a look into all the files, I can provide you my credentials sir.

    Thanks in advance.

  6. Arnoud
    Member
    Posted 2 years ago #

    Do you know if you are using php-fpm?
    Do you have any files in /etc/nginx/sites-enabled/?
    If so, please paste the contents here.

    Can you tell the version number of nginx and php?
    Have you studied http://wiki.nginx.org/Configuration (don't forget the pitfalls).

  7. Pothi
    Member
    Posted 2 years ago #

    @sameermanas As Arnoud mentioned, please provide us the site specific nginx configuration. It is faster to get help here than directly from me. That said, you're welcome to provide me the credentials so that I can have a look and post the solution here. I hope you know how to contact me.

  8. sameermanas
    Member
    Posted 2 years ago #

    @ Arnoud I am using Php-Fpm and i have the [sitename].conf file in the sites-available folder(Not inside sites-enabled). Sites-enabled is not touched till now.

    The PHP version is 5.3.6 and Nginx is 1.0.5

    Yes i have been through the configuration details but unfortunately i haven't been through the pitfalls thing.

    @Pothi Kalimuthu: Here is the file of /etc/nginx/sites-available/bloggerstack.com.conf

    http://piratepad.net/hFhfRqvZ6D

    I have sent the details to you via Facebook. Please go through them once.

  9. Pothi
    Member
    Posted 2 years ago #

    @sameermanas Got the login info and fixed your site's nginx configuration that was missing the following directive...

    location / { try_files $uri $uri/ /index.php?$args; }

  10. sameermanas
    Member
    Posted 2 years ago #

    Thank you very much sir. Is there anything else i should do further to ensure less conflicts.

    Also since you asked me to disable W3Total Cache, I did that immediately.

    However in order to make sure that the Nginx and other related tools work fast, Are there any other plugins or codes that make WordPress faster and less resource hungry.

    Thank you very much once again for the help Pothi Kalimuthu Sir

    @Arnoud : Thank you very much for taking the time to look through this. Also can you suggest any changes that are needed for the "sites-available" and "sites-enabled" folders.

    I really don't understand what difference they make.

  11. Pothi
    Member
    Posted 2 years ago #

    You're welcome Sameer. From my experience, Nginx with PHP-FPM either works or doesn't work. :)

    Also since you asked me to disable W3Total Cache, I did that immediately.

    You may enable it now and please make sure to reload Nginx once you enable it so that the custom rules from W3 Total Cache are applied.

    However in order to make sure that the Nginx and other related tools work fast, Are there any other plugins or codes that make WordPress faster and less resource hungry.

    There are a lot of optimization techniques available on the internet. You may want to start from here... http://codex.wordpress.org/WordPress_Optimization

  12. sameermanas
    Member
    Posted 2 years ago #

    Thank you all for your time !

    Finally one simple question. If i host a new website on the same VPS, can i use the same conf file in site-available (Of course i will change the domain to newdomain.com in the links)

    Like /nignx/sites-available/domainone.com.conf
    /nginx/sites-available/domaintwo.com.conf
    .
    .
    etc

  13. Pothi
    Member
    Posted 2 years ago #

    If i host a new website on the same VPS, can i use the same conf file in site-available

    Yes, why not. It may be sites-enabled, though. I don't remember where I made the change. :)

  14. sameermanas
    Member
    Posted 2 years ago #

    Hi Everyone,

    I got that issue fixed after adding a line in Webmin. This is for Webmin enabled users, so make sure you have WEbmin installed.

    Go To Webmin>Servers>Nginx Webserver

    In that select the Edit Configuration Files option.

    Then select your /etc/nginx/sites-available/yourdomainname.com

    You will see something like this:

    server {
    	server_name sameermanas.com www.sameermanas.com;
    	listen 69.85.88.135;
    	root /home/sameermanas/public_html;
    	index index.html index.htm index.php;
    	access_log /var/log/virtualmin/sameermanas.com_access_log;
    	error_log /var/log/virtualmin/sameermanas.com_error_log;
    	fastcgi_param GATEWAY_INTERFACE CGI/1.1;
    	fastcgi_param SERVER_SOFTWARE nginx;
    	fastcgi_param QUERY_STRING $query_string;
    	fastcgi_param REQUEST_METHOD $request_method;
    	fastcgi_param CONTENT_TYPE $content_type;
    	fastcgi_param CONTENT_LENGTH $content_length;
    	fastcgi_param SCRIPT_FILENAME /home/sameermanas/public_html$fastcgi_script_name;
    	fastcgi_param SCRIPT_NAME $fastcgi_script_name;
    	fastcgi_param REQUEST_URI $request_uri;
    	fastcgi_param DOCUMENT_URI $document_uri;
    	fastcgi_param DOCUMENT_ROOT /home/sameermanas/public_html;
    	fastcgi_param SERVER_PROTOCOL $server_protocol;
    	fastcgi_param REMOTE_ADDR $remote_addr;
    	fastcgi_param REMOTE_PORT $remote_port;
    	fastcgi_param SERVER_ADDR $server_addr;
    	fastcgi_param SERVER_PORT $server_port;
    	fastcgi_param SERVER_NAME $server_name;
    	location ~ \.php$ {
    		fastcgi_pass localhost:9003;
    	}
    
    	location / { try_files $uri $uri/ /index.php?$args; }
    
    }

    Notice the line called "location / { try_files $uri $uri/ /index.php?$args; }"

    That is the line I added in the end. It fixes your Permalinks issues.

    At last make sure you click Save and then click on Apply Nginx Configuration

    Hope this helps anyone out there like me.

  15. Todd Lahman
    Member
    Posted 2 years ago #

    http://wiki.nginx.org/Wordpress

    The fastcgi_param can be included in a separate file as shown in the working example to simplify the nginx.conf file.

Topic Closed

This topic has been closed to new replies.

About this Topic