network-server

Posted by & filed under Servers.

I looked into setting up . This is supposed to be a faster web than apache.
For set up and installation you better search for information (Google for nginx php-fpm and your OS).

The biggest issue is the rewrite rules used by apache and located in .htaccess files. I had tried nginx before and as I need rewrite rules for other apps too I was a little hesitant because of my earlier experiences.

The rewrite rules for nginx can be confusing, a lot of sites give different information and methods, none of them worked for me.

What worked for me in the end is the try_files, apparently this is similar to checking if a file exists and use that instead of rerouting it through the index.php, so for your css, jpgs and other php files.

So I better look into the ‘location’ and ‘try_files’ for nginx.

I have now nice looking permalinks again. I have installed the nginx plugin but I am not sure if I need it.

I tested all this on a small (300mb download/4Gb) Centos Virtual Machine and also on an Ubuntu system.

# The default server
#
server {
        listen       80;
        server_name  _;
 #charset koi8-r;
#access_log  logs/host.access.log  main;
        location / {
            root   /usr/share/nginx/html;
            index  index.html index.htm index.php;
        }
        location / {
            index  index.html index.htm index.php;
            try_files $uri $uri/ //index.php?q=$uri&$args;
        }

Another thing that got me was the permissions and users assigned to the server: php-fpm runs as  user ‘apache’, I had nginx running as user ‘nginx’, this resulted in WordPress asking for ftp settings for installing and updating plugins. I assigned the apache as the user for nginx (as that is very easy to do) and changed permissions on the WordPress installation.

#php-fpm runs as apache, cause for wordpress ftp plugins?
user              apache;

Still to do is nice urls for and check some other stuff. Will retest one site that ran under apache and was tested with ‘ab’ (apache ).

 

Leave a Reply

  • (will not be published)