nginx: [emerg] unknown directive “if(-f”

Posted by Lloyd on May 19, 2012 at 10:34 am

Nerd Talk

If you’re working on nginx configuration and you can’t start or reload it because you’re getting an error like this:

nginx: [emerg] unknown directive "if(-f" in /etc/nginx/nginx.conf:67
nginx: configuration file /etc/nginx/nginx.conf test failed

You need to make sure that the “if” and the “(” are separated with a space:

# will cause syntax error
if(-f $document_root/$uri.php) {
   rewrite ^(.*) $1.php last;
}
 
# this is correct
# notice the space between "if" and "("
if (-f $document_root/$uri.php) {
   rewrite ^(.*) $1.php last;
}

That should fix the issue and you should be able to start/reload nginx successfully.
As a programmer I tend to assume that “if(-f … )” will work because in essence it’s a valid syntax for if statements. For nginx, you should play by its rules because you’ll get a bunch of these errors if you don’t.

Instagram

Posted by Lloyd on May 13, 2012 at 2:52 pm

I like it, in fact I’m starting to get addicted to it :)
My only complaint so far is it doesn’t actually have a description field as your main caption goes into comments – there’s also no caption/tags edit functionality yet.

New ToDos

Posted by Lloyd on May 13, 2012 at 8:57 am

I figured I should cut down the usual habits to make room for new-old-forgotten ones. Not very long ago I started getting less active on Facebook – it includes no commenting, likes, private messaging, chat, etc. So basically you won’t feel my presence as if you don’t have me as a friend or you’ve totally forgotten my existence. I still visit but not as “sociable” as before, the only activity that I have for the past few months is just uploading landscape photos which nobody appreciates. Now that I’ve said all that, I have a small list which I will try to fulfill as a mini personal goal:

1) Less to no Facebook usage - just because
2) Tweet more – it’s fun!
3) Write new blog posts
4) Visit people’s websites to make new connections – hopefully!
5) Do more photography work
6) Write/read codes on free time (if not doing photography work) to exercise brain
7) Read more tech news and articles to get up to date infos
8) Find a girlfriend (optional)

That sounds about right, I think I will just keep on updating my list as soon as something comes up but it should be a good start.

Blogging again soon!

Posted by Lloyd on May 06, 2012 at 12:37 am

NOT! Well, I might actually do it if I can pull something out of my head but guess what? No one reads this stuff anyway! HAH! I just updated my WordPress installation to the latest and greatest – and they used that silly update message again! I’m also hoping to get those pesky spams out of my previous posts by using the Akismet API.

Next time I’ll try to write something other than site updates ^_^
Morning edit: Want to know a secret? I’m eating a very sweet mango now! Not anymore, that was last night!

Hello 1

Posted by Lloyd on February 26, 2012 at 12:35 pm

Today I have time to update my WordPress installation and I found it funny, too.
“Thank you for updating to the latest version! Using WordPress 3.3.1 will improve your looks, personality, and web publishing experience. Okay, just the last one, but still. :)”

Wait..this turned out to be my first 2012 post!

Happy Birthday!

Posted by Lloyd on November 27, 2011 at 3:42 am

age++;

Not busy?

Posted by Lloyd on November 19, 2011 at 10:18 am

It’s surprising how I only have few tabs opened during weekends compared on weekdays where I have more than a dozen and more than 2 windows opened. It’s also surprising that I’m taking the time to write about it, too.

Quick update 2

Posted by Lloyd on August 24, 2011 at 5:49 pm

The guy who owns this site is busy and lazy to post. He just logged in today and updated WordPress to the latest version. That’s all.

Adobe Flash player update installation 2

Posted by Lloyd on April 02, 2011 at 9:04 pm

I always notice things, even unimportant ones. Today, I noticed Adobe’s flash update installer. When updating a software you usually see the word Install once and after that you only need to press Next and Done. For Adobe, showing the Install button once is not enough, they show it twice. It’s not a problem really, but I’m guessing or probably the first Install button should indicate a Download button because clicking it doesn’t install the update, it downloads it and then installation happens. I took some screenshots of the update process and it shows that I may be correct with my guess.

First one says install:

The next one which happens after clicking the “Install” button is actually a download:

Next one, there is another “Install” button, this time it’s the real one:

Last one, installation is completed:

See what I’m saying?

Windstruck 1

Posted by Lloyd on March 27, 2011 at 10:06 am

It’s probably the saddest movie I’ve ever watched. It’s so sad I had a teary eye, I really felt it. Srsly. It’s korean and it’s good. There are funny parts at the beginning but through out the movie it’s all sad. Get yourself a good sad movie, I recommend it. After watching, this song should remind you of the movie.

Watch the movie and then watch this another movie as they have some connections.

PHP session not persistent after server migration

Posted by Lloyd on March 27, 2011 at 8:52 am

Nerd Talk

I remember when we setup an Apache web server to move from Lighttpd, after we installed PHP we just copied over the same php.ini file to use the same settings. During testing I had a problem with sessions not persisting between pages, it was a pain to realize the problem at first. The cause of the issue is with the session.save_path, since we just copied over the old php.ini file, the folder path set to where the session should be saved is, well, not existing. I created the folder, the session folder, set write permissions and sessions are flying across pages!
You can find the session.save_path directive in /etc/php.ini and check out where sessions are saved, ex:

session.save_path = "/var/lib/php/session"

I believe it’s not the best practice to set 0777 (means everyone can read/write) permissions for the sessions folder as other users of the server may be able to hijack session files so be careful on this.

Literally, this is the song that played on my head when things started to work. It’s one of my childhood anime song. Watch and listen to this!

I’m eating bacon and rice for breakfast right now, btw. Just saying ;p

Exclude svn folder when copying files to another location

Posted by Lloyd on March 19, 2011 at 3:11 am

Quick Tip

Copy files from an SVN folder to another location and excludes all .svn folders. This copies files from the source to destination recursively, -r.

rsync -r --exclude=.svn /path/to/source /path/to/destination

More about rsync here.

Added to wishlist 2

Posted by Lloyd on February 19, 2011 at 8:27 pm

Apart from wanting to buy a Nintendo 3DS, I also want to buy a DSLR – Nikon D3100. I’m hoping to buy either one of the two this year.

And for today, a random image of Lucy going nuts! xD

Image of the day 1

Posted by Lloyd on January 08, 2011 at 9:15 am

Anime time!

I don’t have any new animes to watch lately so I’m re-watching one of my favorites, Fullmetal Alchemist Brotherhood! There are really a lot of funny moments all through out series which is why I don’t mind watching it again. Today, I find this one particularly funny when Ed was asking Al and Winry why Al got rejected to be Winry’s wife, Winry said “I don’t want a man shorter than myself” which kinda lead to this picture of them XD

Ed and Al always had a talk during their childhood about who would take Winry as a wife.

Freeze! 1

Posted by Lloyd on January 08, 2011 at 8:30 am

This happened last night while at the office waiting for some uploads to finish I was playing around with my Ubuntu (11.04) box when I got this CRAZY art using Firefox. I remember the old days when I used to get this all the time when using IE6.


^ Back to Top