NGINX : failed (2: No such file or directory) in /etc/nginx/nginx.conf

My first configuration of an NGINX server left me high and dry for a while. Coming from an Apache back-ground (where everything is done for you), NGINX felt a little archaic at first.
There was not much help out there for this issue so I will fill in the gap.

The error (in this case) was due to my symbolic link not being created correctly in sites-enabled.
I will go into a little more detail.

nginx: [emerg] open() "/etc/nginx/sites-enabled/mysite.co.uk" failed (2: No such file or directory) in /etc/nginx/nginx.conf:62

This is the error (above) was being shown with any of the following commands :

  • Testing the configuration: sudo nginx -t
  • Starting or reloading the service:
    sudo service nginx restart
    sudo nginx -s reload
nginx: [emerg] open() "/etc/nginx/sites-enabled/mysite.co.uk" failed (2: No such file or directory) in /etc/nginx/nginx.conf:62

This message is a bit vague, but there is a subtle hint here. The last path is pointing to the file containing the problem and the appended number correlates to the specific line number in that file.

In my case, line 62 was:
include /etc/nginx/sites-enabled/*;

I know the syntax of the line is correct because I compared it with the default file included in the installation.

Similar to Apache, the sites-enabled directory is meant to store symbolic links of configuration files that are stored in sites-available. Unlike Apache, however, the symbolic links need to be manually created by the admin, as apposed to an Apache command that automatically creates and removes the links when asked.

Navigating to /etc/nginx/sites-enabled, I checked the symbolic link using the following command

sudo ls -la

lrwxrwxrwx 1 root root   32 Jul 19 20:16 mysite.co.uk -> sites-available/mysite.co.uk

I previously created this link whilst in the /etc/nginx folder using the following command:
sudo ln -s sites-available/mysite.co.uk sites-enabled/

Looking back at the ls output, the local filename is correct, however the file path that it is pointing to isn’t.
The correct path should be:
/etc/nginx/sites-available/mysite.co.uk

The solution was to simply create a new symbolic link to the configuration file, but using absolute paths instead of being lazy.

sudo ln -s /etc/nginx/sites-available/mysite.co.uk /ect/nginx/sites-enabled/

After this, NGINX complained no more and after a silent reload, instantly served my webpage on the World Wide Web. Nice.

Yes, this was complete user-error spurred from my lack of knowledge of symbolic links, however this is no longer a problem and I can get back to development.

Hopefully this will save someone else loads of time!

Linux vs Windows: Python Virtualenv

Although Virtualenv is available on both Linux and Windows, there are some differences that you may find useful to understand.

Is there a difference to creating virtualenvs?

No, creating virtualenvs in Windows and Linux is exactly the same.

Can I use the same venv folder on both systems?

No. You will need to create 2 separate virtual environments. I suggest creating folders named winvenv and linvenv to tell them apart. You will have access to the same packages through pip, although you will need to use pip freeze if you wanted to replicate the packages exactly.

Do I activate the venvs in the same way?

No, but you CAN activate, and the differences are subtle. After creating the virtualenv, follow these steps:

Windows

\winvenv\Scripts> activate

Navigate to Scripts within the venv root. Type activate to use your venv in the current prompt

Linux

$ source linvenv/bin/activate

In the terminal, type source followed by the path to /bin/activate within the viretualenv folder

Windows, VS Code, Git and SSH Authentication with passphrases

Have you spent the past several hours frantically searching the web for a solution of integrating Git with VSCode? Are you tempted to remove passphrases from your SSH Key just to get around Permission denied (publickey) errors every time you try and clone a repo?

Yes, it is disappointing that there is no clear documentation for this.
Hopefully, this will fill the gap.

Pre-requisites

Windows 10
Git installed
VSCode installed
Created an SSH key using the Git terminal and is passphrase protected.
Added your SSH public key to your chosen Git Service.

Solution

Before starting VSCode, open up a new Windows CMD window.
Enter the command: start-ssh-agent and you will be prompted to provide the passphrase to your SSH Key.

cmd start-ssh-agent
start-ssh-agent

Now you will be able to open VSCode and clone into your repository.

Automation

If you wanted to automate start-ssh-agent and open VSCode at the same time, I have built a batch script that will do just this.

Open text editor and paste in the code below. Save file as VSCode_ssh-agent.bat

I decided to place this file in my Windows home directory. On the Desktop, I created a shortcut to the .bat file and set the icon to point to:

C:\Users\[USER]\AppData\Local\Programs\Microsoft VS Code\Code.exe

The final result:

  1. Check if SSH-AGENT is running.
    If not, start SSH-AGENT and ask for the passphrase for your key.
  2. Start VSCode

Slow/Laggy/Poor graphics performance: Linux Guest VirtualBox 6.0

I have spent many an hour trying to figure out why VirtualBox 6 has given me terrible graphical performance on Linux Guests. I’m going to give you a no-mess solution that just might save your sanity.

Within the Settings for Your Virtual Machine, navigate to the Display > Screen tab.
Under the Graphics Controller dropdown, select VMSVGA for your Linux guest.

Next, you will need to boot into the virtual machine and reinstall the VBOX Guest Additions for this to work (and cement it in with the obligatory reboot)

So you may be wondering why or when you might need to use this guide?
You may have upgraded to VB6 from VB5 or earlier and trying to use a pre-existing VM.
You may have installed VB6 for the first time, created and installed a new Linux guest VM and experienced graphical slowness.
You may have tried (mostly) every setting within VBOX and viewed every forum post on the internet regarding VB performance issues and have got no further.

Admittedly, I was incredibly close to giving up altogether with VBOX 6 and going back to VBOX 5 as I have been struggling with this since VBOX 6 release. Finally, I have my VM back =)

A New Home for the PC

Whilst moving from an FX-6350 to Ryzen 2600, I couldn’t help but notice how poorly designed my case was. Sure, there’s a great need for aesthetically pleasing units and there’s a wide selection available, but let’s have a reality check.

As do many, budgeting on the case and PSU (as did I in 2016) for better hardware could be problematic. With cheaper cases, the choice is limited and picking the best unit for your needs might take a bit more time than simply adding one to your basket that meets the budget.

Changes in modern case design are a lot more noticeable for those used to having a “drive rail” at the front of the case and is worth understanding what has changed from the “classic layout”. Let’s explore this further.

ODDs

ODDs (optical disk drives) are less likely to make an appearance then maybe 10 years ago. This might be because flash media is smaller, less noisy, more efficient and can be supplied whilst buying Windows. Also, games aren’t bought on CD or DVD anymore and are usually downloaded straight from the source.
This conclusion has allowed the limitation or in some cases (no pun intended), the complete removal of ODDs completely in Mid-Towers.
Full towers still have plenty of bays.

Storage

Before SSDs became mainstream, the standard storage unit fell to hefty 3 ½” HDDs. SSDs are now considered to be mainstream and usually found in smaller sizes: 2 ½” and M.2 and of course the less-seen size in the form of a PCI-e card.
Like ODDs, the 3 ½” drives are just about hanging on with at most a couple of spaces dedicated for the larger HDD. There’s more room now dedicated for SATA 2 ½” SSDs because of their form factor in Mid-Towers.
Full Towers usually have plenty of space for HDDs and are worth considering if you need space for your RAID 5 array.

PSUs

This may be a little odd but there are some points worth mentioning. Modern Mid-Towers tend to position the PSU on the bottom of the case. There are a few reasons for this which are helpful to understand.

  • The weight is closer to the ground, and this is important in the reduction of unit being “top-heavy”
  • A dedicated ventilation grill for the PSU that isolates the airflow through the PSU to the rest of the system.
  • Modular PSUs can be helpful in cable management by reducing unnecessary plugs or cables.

Cable Management

Cable Management is an aesthetic “nice to have” but can play an important role during maintenance and any more adding/removing hardware. I also realise that it can help to reduce dust settling on meters of cable. As I like to think of it, keeping your workspace clean and tidy allows you to work more efficiently. The same can be said whilst maintaining your system.
A well-managed case is heavily dependant on the design. This is achieved with:

  • Space behind the rear access panel for cables
  • Space around the PSU for tucking away lengthy cables
  • Access points around the motherboard for cables to connect from behind the motherboard tray, such as front I/O headers and SATA connectors.

GPUs

GPUs have grown in size and is worth making sure that the card you are buying/have will fit. Usually, case manufacturers are good at letting you know the maximum length of the card that could house.

Also, think about future upgrades and expansions; it could be worth finding the size of the largest GPU and seeing if it will meet the specifications to be better suited for years to come.

CPU Coolers

Many budget coolers are quite tall and you’ll want to be sure it will fit. Again, most good case manufacturers will note the maximum height of the cooler for the case and could impact your buying decision.

Front I/O

USB-C is still quite a way off from being mainstream, but it could be worth looking into, even if your motherboard doesn’t currently have an I/O header for it. If you use USB frequently, having a nice choice of USB2 and USB3 interfaces on the front can be a deal maker. If you are into photography or use SD often, card readers integrated to the case isn’t too uncommon.


Everyone is different and has different needs and tastes. Doing the research properly will allow for a better-equipped case for your needs, and may help you decide about the cooler you buy!

A case can (and should) last longer than the original hardware that it originally intended to house and being clear on current hardware trends can future-proof your purchase, even if it is bought to a budget.

Buying correctly will not only cut down on e-waste but will save your future-self some money too.