The Perfect Web Server – Nginx, Ajenti, Ubuntu

 

ajenti-dashboard

I’ve done a lot of installing of web servers over the last while, some of which have been effortless, others a thorn in my side. I’ve decided to compile a guide for my latest server setup that I’ve fallen in love with;

First a breakdown of what we’ll be installing today;

Nginx: (pronounced Engine X) is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. Nginx doesn’t rely on threads to handle requests. Instead it uses a much more scalable event-driven (asynchronous) architecture. This architecture uses small, but more importantly,predictable amounts of memory under load.
Even if you don’t expect to handle thousands of simultaneous requests, you can still benefit from Nginx’s high-performance and small memory footprint. Nginx scales in all directions: from the smallest VPS all the way up to clusters of servers.

Ajenti: “The admin panel your servers deserve.” Easily extensible using Python. Plugin development is fast and pleasant with rich APIs. Includes lots of plugins for system and software configuration, monitoring and management.

Ajenti V: A plugin for Ajenti that makes website setup easy – including app servers, database, and routing.

Ubuntu: If you don’t know what Ubuntu is we’re in trouble.

Now I’m going to take a leap of faith and assume you can either install Ubuntu yourself or figure out how to get a server with it already. A DigitalOcean droplet works perfectly here. So lets log in as root and run all this:

You should now be able to log in to your Ajenti control panel at https://yourserver.com:8000 with:

username: root
password: admin

 

Now that’s done you’ll notice if you open /etc/nginx/nginx.conf that files inside /etc/nginx/conf.d/ are loaded before any other .conf files, this is where you should put any additional configuration for Nginx. However if you are just configuring a specific domain or website you should just put the configuration in the Ajenti  website configuration’s advanced section.

That’s all folks! :)

Being a PHP Developer in 2015

This is just some thoughts on being a PHP developer in 2015;

A standard web project before used to just require you to setup a local web server, and then you’d upload to a standard web host with some worries about PHP versions perhaps but little to no thought required for the server side of things.Frameworks were a new thing, CodeIgniter was (to me at the time) the best thing to happen to PHP,  introducing me to PHP MVC patterns, easily integrated vendor libraries (I never got into Zend Framework) and Twig.

Now a web project involves using programs such as Composer, Bower and Grunt just to manage project dependencies. Then you have PHP & JS frameworks like Symfony, Laravel,  AngularJS that have really made life so much easier for us developers. Of course this all comes at a cost of having to put in time into learning all these new frameworks and tools, but the benefits of doing so are just amazing; development time goes way down and you create much better products. I wish I could further go into the benefits of each but they all require posts of their own to really get across their individual uses, I’ll attempt to get to that!

Working with UNIX servers is pretty standard for most web developers now, myself included. I’ve been using DigitalOcean for all my hosting, they really are a great host and I recommend them to anyone searching. Anyway a tool I found lately for server management which I guess is what has caused this post is Ajenti, before this I was using ISPConfig for the aim of being able to manage my servers easier than via ssh, however I found it’s interface pretty clunky and just overall slow, always ending up in ssh. After testing Ajenti in a fresh droplet I changed completely over to it on my other servers, so far it’s been amazing, I’m still using ssh here and there but overall Ajenti has really solved my problem so thanks guys. The install was amazingly simple too I recommend anyone looking for a GUI for their server to check it out.

So there seems to be a lot more to PHP web development now in 2015 than there was just a few years ago, though I personally feel all of it is for the better, making my life easier. It makes me wonder what it will be like in another few years though, whats next? :D

Apache Localhost Rendering Slowly?

Is your localhost taking longer than expected to load?

A possible quick fix is to edit your httpd.conf file and set ‘ServerName’ to 127.0.0.1:80 . This can make the difference between millisecond load times and crying while Apache tries to load.


# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
ServerName 127.0.0.1:80

We’re Back / Moving Forward

So I’ve truly neglected here, my original space on the internet. . It’s been almost two years since my last post, which was really just a code snippet.

So moving forward I’m going to be blogging about completely different topics that I haven’t blogged about before. .

For my current subscribers (it’s hard to believe I still have subscribers) you may want to unsubscribe and decide if this is something you want to subscribe to moving forward.

So whats happened?

Well, a lot has happened since I’ve last posted on here. It’s even kind of hard to timeline the last two years myself. I started my own web development company in Kilkenny (coder.ie), I did that for around a year and a half.. Learned a lot of valuable lessons throughout doing that. Got myself the funds needed to get to Canada (barely), now I’m living in Vancouver and working at Motbot .

I love my new job, I don’t think I would go back to owning my own company anytime soon. Landing a job after landing in Vancouver was a breath of relief and I really lucked out ending up with a company that are doing some amazing stuff. My co-workers are really experienced in their respective fields and I don’t think a day goes by where I don’t learn something new. It’s so refreshing after the stress of working on my own for so long  and nearly losing my love for programming. I think that’s partly why I stopped posting on here, when I finished working the last thing I wanted to do is use the computer any further.

I can’t see myself returning to Ireland if I can work out staying here. Canada is an amazing country and Vancouver is just such a beautiful city.. So much is better here, its hard to even put into words, I’ll try over a series of articles! :P

What are my future plans? 

I think this works better in list format:

  • Improve as a poker player 
    Yes we’ve gotten very into poker in the last year playing mainly online tournaments, I won’t really get into this much here as there will be more content on it later.
  • Create a game using Unity
    Anyone who knows me knows I’ve always wanted to create a game, that’s what originally got me into programming. I’ve tipped my toes into a few games along my way, but I’ve never actually created my own game and had complete creative control. That’s the next plan. I’m going to create a 2D game over the coming months and document my progress here along the way.
  • Learn C#
    Kind of ties into “Create a game using Unity” since C# will be the language I use most.. I never did get around to learning Python, hopefully that doesn’t happen here, though its more unlikely since I’ll actually have a use for it.
  • Live Healthier
    I’m probably the picture of unhealthy living at the minute, I’ve been trying to make small changes to change this and hopefully all these small changes will turn into massive changes. Like quitting smoking, we’ve just been putting off doing that forever!!

So that’s all I have for now, I hope this clarifies what way content will be headed in future!

How To – Control Your Computer with an Xbox Controller


Today I’m going to walk you through setting up an xbox controller to work on your computer and control the mouse / keyboard.

First your going to need an Xbox Controller that works on Windows.  If you already have an Xbox controller you can just pick up one of these receivers. (Both links to Amazon, you can  find on  eBay cheaper).

Next you’ll need to install the drivers for the controller. You can find them on Microsoft’s website here.

Now you should be able to connect your controller to the computer and play any games using it. However you can’t use it to control the mouse yet. What we will need to do next is download JoyToKey from here. I went with the latest Beta version however you can also download the stable (v 4.6 at time of writing).

The second last step is to download my config and shortcut to the on-screen keyboard put the configuration in the folders shown and run JoyToKey.

The last step is to enjoy being lazy! ;)

WordPress – Shortcode in PHP files


So in WordPress with plugins etc. you end up using shortcode in posts to keep things simplier, an example would be if you want to display a gallery you would just use:
[galleries id="1"]
However trying to this when your outside of the “WordPress Loop” [in your theme files usually] you will hit the problem that WordPress won’t parse the shortcode. So whats the soloution? Super simple just append the following to your shortcode:
echo apply_filters('the_content', '[galleries id="1"]');
Presto, it works!

To read up more on shortcodes in WordPress click here.