configuring nginx for gpeasy cms

cogpEasy CMS is a lightweight content management system ideal for maintaining small websites, especially in shared hosting environments. It outperforms most other content management systems in terms of raw performance and ease of use for those unfamiliar with website maintenance. With no database requirements and a straightforward installation process, there is much less to configure and maintain than other content management systems with similar features, such as WordPress.

nginx is an extremely efficient and robust http server capable of putting limited resources to much greater use than most other http servers, including the popular Apache http server. nginx, like gpEasy, is ideal for extracting speed and cutting down overhead for small to mid-sized websites in shared hosting environments.

Coupling the two technologies seems like a great idea – unfortunately configuring nginx so that gpEasy works properly is not well documented and riddled with roadblocks for those unfamiliar with nginx’s rewrite rules. nginx’s “try_files” directive seemed like an ideal solution, but never did work correctly in my tests. So, without further ado, here is what you need to know to get gpEasy working with nginx:

  1. First, you should edit the index.php file in gpEasy’s root directory. Uncomment the line that mentions “gp_indexphp”, so that your file looks likes this:
    //define('gpdebug',true);
    define('gp_indexphp',false);
    //define('gptesting',true);
    require_once('./include/main.php');

    This tells gpEasy to use permalinks without “index.php” appearing in the URL.

  2. Next, you need to edit the appropriate nginx site configuration file so that is has a conditional rewrite rule like the one below:
    location /gpeasy/ {
    
      index index.php index.htm index.html;
    
      if (!-e $request_filename){
        rewrite ^(.+)$ /gpeasy/index.php?$1 last;
      }
    
    }
  3.  (Note that if your gpEasy installation is in your site’s root directory, then you’ll replace “/gpeasy/” with “/” throughout the block above.)
  4. Lastly, restart nginx and proceed with the installation of gpEasy.

If you run into problems, or even if everything goes as planned, please leave a comment letting me know.

5 Responses

  1. Zoltan Toth says:

    Hello,
    I just did as you explained but whenever I try to move away the startpage (another page, and admin too) I receive an “500 Internal Server Error;nginx/0.7.67” error. Fastcgi, Debian Squeeze, gpEasy 2.2, alienvps.
    Maybe you have an idea. Thanks in advance.
    Zoltan

  2. fox says:

    When I add the rewrite i get :
    sh: 0: getcwd() failed: No such file or directory

    idea ?

  3. fox says:

    I have now managed to start the server without error , and the rewrite seams to work, BUT no assests are found ? no pictures are shown no css

  4. revanx says:

    This try_files directive works for me:

    location / {
    index index.php;

    try_files $uri $uri/ /index.php?$uri&$args;
    }

Leave a Reply

Your email address will not be published. Required fields are marked *