Skip to main content

Posts

Showing posts with the label linux

Debugging a DOS

I'm not a sysadmin, but I end up doing my best now and then when one of my sites gets into trouble. This is a sort of "after action report" of an incident that I just resolved (hopefully). I woke up and happened to check email on my phone (don't always do this, will now) and was greeted with a uptime robot email that one of my sites was down, and had been for about 4 hours. I quickly checked the site on my phone and yup, it wasn't loading. Ran to the office and hopped on my laptop. SSH to the server, and everything seems fine. Very little load on the server (AWS instance). Did a restart of apache/php/mysql and the site is still down. Weird. Running the site's index.php file on the command line works as expected and fast. Ask a few other people to check, and it's down for them. Then I logged into the AWS console and checked on status there - everything is up and running.... WTF? This is a lightsail instance, and then I noticed the outgoing network traffic h...

WSL - great tool for LAMP webdev!

 So I've been using WSL (Windows System Linux) for well over a year ago. I started with WSL 1 and then moved WSL 2 recently. All in all it's been a pretty smooth ride. I decided to ditch my mac after well over a decade of using macs and move to Windows. I wasn't happy with the price of the hardware I was getting for that price. Windows is better than it used to be... but that's not really saying much. And I've always been firmly in the Linux world when it comes to web development and hosting. So what to do? WSL fills the bill perfectly. Right now I have Ubuntu installed - all I have to do is open a Windows terminal window and type 'wsl' and I'm in a nice comfy linux world. Start up apache and MySQL, open localhost in my browser and I'm working off my local environment, almost like I was using MAMP. I did consider setting up dual-boot Windows and Linux - but my laptop just doesn't have the disk space for that. Upgrade the disk is an option, but tr...

Setting up a simple LAMP stack in WSL/Ubuntu

As I've mentioned before, I've been running WSL (Windows Subsystem for Linux) for roughly a year now. It's still a little mind-blowing to me - when I got started Microsoft was about as anti-linux as can be. Weird times! Anyways, I have a fairly simple setup right now that's been working well for me. I'm using an older version of WSL right now, and apparently the newer version is much faster - but this works well enough for my needs right now. This guide assumes you already have WSL set up and working, and can get a bash command line... Install Apache and MySQL This is easy, just run: sudo apt install apache2 and sudo apt install mysql-server and while you're at it, you can start them up: sudo service apache2 start sudo service mysql start You may run into some weird issues - I used this guide if you need any other info. Now you have the most basic bits set up, it's time to get your actual sites up and running locally! Setting up your projec...

WSL and Windows Terminal

I've been back on Windows now for awhile, and WSL has made it quite an easy adjustment. You still get the occasional "WTF Windows" moment, especially after a big update - but I'm pretty happy with it. At the time I just couldn't justify splashing out for a pricy macbook with no escape key and a stupid "hotbar" thing... Anyways, if you're used to working in the LAMP stack and haven't tried out the combo of WSL and windows terminal, give it a try! Or at least try WSL if you don't use command line much. WSL (Windows Subsystem for Linux) basically lets you run linux inside windows. I use it to then run MySQL and Apache/PHP - and I'm good to go. Most of my work happens inside a Windows Terminal window, which has become a pretty slick, configurable terminal. I have a 'projects' directory set up, in which each of my various projects reside. When I want to work on one, all I have to do is edit the apache config to use that particular ...

My Setup - updated

Reading through my old posts, I found it ironic that one of them was about how I was back to using Macs again for work. Ironic because after eight years of using a mac, I switched back to Windows about a year ago. The reason was that my old mac laptop was getting long in the tooth, and I absolutely hated the new macbooks with their janky keyboard and stupid touchbar. Apparently the keyboard has gotten better since then... but I still feel that the macs are just too expensive for what you get. So I switched to Windows, thinking I'd dual-boot with Linux to give me an appropriate development environment. I still spend most of my time at the command line or in vim anyways. But I decided to try out WSL in Windows just to see what it was all about. What a pleasant surprise! I ended up getting a nice 13" gaming laptop that packs quite a punch in a lightweight package. Windows 10 is decent enough. It still has a lot of those annoying Windows quirks, but I can live with that. ...

Ooh shiny - Ubuntu 10.1

Just read this Ubuntu review - I used Ubuntu on my primary work machine for a long time, but it's been a few years since I used it now... time to get back in I think. Wonder if it will work on my old sony vaio - I suspect it has proprietary hardware that may cause problems....

Tips on moving a site, Part I

Been doing a lot of work lately moving sites from an old dedicated server to a new one with a new hosting company. The old server had no (useful) control panel, so I've been doing a lot of it by hand, and I thought I'd post a few handy pointers for anyone who may be in a similar situation. For static sites, the process is dead simple - just tar up the old site's content using something like tar -cf [tar filename].tar [path to site]/* will do it. Then depending on the site, it may save you a little time to zip the tarball. Then, after doing whatever you need to do to create a new site on the new server's control panel, login in with SSH, go to the appropriate directory and pull over the tarball with scp: scp [username]@[server]:[path to tarball]/[tar file] ./ And then extract it, and you're ready to go. One thing it watch out for is absolute paths in the content from the old site. If you know what they look like, it's pretty easy to grep for that pattern in the...

Six Reasons Why Once You Go CLI You Never Go Back!

(ok, fine I know it doesn't rhyme. I'm a coder, not a poet!) If you're still screwing around uploading and downloading your code to your web server using FTP, it's time you gave the command line a try! Not only is it more efficient to edit your code directly on the server, you'll also find the that the command line tools on your average linux install are quite powerful when it comes to web development! 1. You're on the server - Think how much time you spend dragging/dropping files in FTP, connecting and reconnecting when the FTP connection dies, etc. With a command line you're more saving time already just by avoiding all of that! 2. vi/emacs - These are the two biggies, but there's many, many other text editors available to use on the command line. I'm a vi guy, and it's definitely more powerful than the various GUI-based text editors I've used in the past. The built-in regular expressions alone are great! Sure, there's more than a li...

Recursively deleting folders on linux

Had this problem to resolve the other day. I had a fairly deep directory structure - and at the "end" of each path, there was one empty folder to delete. Thank you dreamweaver, but I don't need a _notes folder in every directory on my site! So, rather than delete this manually from every directory - on both the live and staging server, I figured there had to be a way to do this in one command on linux. Of course, I had to be careful, since you can see all sorts of ways that this could go wrong with recursively deleting folders! First, I made backups - always key when doing something like this. I just made a quick tar in my home dir, from the root of the directory I was working on: tar -cf ~/backup.tar Then, knowing I could fairly easily restore things that went wrong, I found the command I needed to delete the offending folders. find . -name "_notes" -exec rm -rf {} \; So the key here is the find command, which looks through all the directories below the cur...