Passenger – Run Rails app in development mode

When you run Rails app using Phusion Passenger (modrails), by default, it runs in ‘production’ mode. However, if you want to run it in ‘development’ mode for any reason, you need to add a directive in your apache/nginx configuration.

Apache:

RailsEnv development

Continue reading →

Easy Control Nginx!

Nginx

Nginx

Recently I am trying to learn managing nginx web server. Most probably it is going to take the place of Apache or at least seat beside Apache. The main benefit Nginx is claimed to be low memory footprint.

So far I have configured three VPS with nginx (also mysql & php). But every time I felt uneasy to start and stop the service as it can’t be started or stopped as ordinary service call.

For example:

To start apache/httpd we write:

service httpd start

But to start Nginx we have to write:

/usr/local/nginx/sbin/./nginx

[I assume that Nginx is installed in default directory]

Again to stop apache, we write:

service httpd stop

But in case of Nginx:

kill -9 `cat /usr/local/nginx/logs/nginx.pid`

or

killall -9 nginx

Today I thought to make it a bit easier. So after mining the internet, I have made a small script to take care of start, stop, restart and check the status of Nginx. I am new to shell scripting.

How to implement it?

  1. I expect your Nginx installation is completed successfully and you can start/stop the server using the earlier methods.
  2. Download this file
  3. Store the file in /sbin/ as nginx. So that path of this file will be /sbin/nginx
  4. Chmod it to 744 by calling:
    chmod 744 /sbin/nginx
  5. You are done.

Now to start the server:

nginx start

Stopping the server:

nginx stop

Restarting the server:

nginx restart

Checking Status:

nginx status

Hope you like it :).

So, any suggestion is

Permission denied: .htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable

Do you get the following error message when you try to visit a site/your site?
Forbidden
You don’t have permission to access / on this server.

Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

You may see this message when you try to visit a folder in your domain like http://xenexbd.com/hello/. Most of the time, I have found this error for subdomains like http://hello.xenexbd.com. Most probably this is very common in a cPanel server. You may get this error after your install/uninstall FrontPage Extension in the main domain. I was repeatedly facing this problem. I usually solved it by installing/uninstalling/reinstalling the FrontPage extension on that subdomain. Continue reading →