Tag Archives: ubuntu

Getting PHP 7.2 to work with NGINX (UBUNTU)

This took a while. I’m much, much more familiar with running apache. I really like how fast and light nginx is, though, and was going to start using it, no matter what.

In the end, it was a combination of all of these things:

  • When I upgrade to nginx 1.17, there is a new “include” line in the nginx.conf file, and suddenly nginx was looking for site config files in this directory (/etc/nginx/conf.d/) instead of the usual one (/etc/nginx/sites-enabled). Had to change that first thing.
  • The nginx process was trying to run under the “nginx” user, instead of “www-data”. Basically, the “user” config in both your php conf files and your nginx conf files must match, or the php-fpm process ignores the requests from nginx.
  • Most tutorials I’ve found on the internet want you to insert specific php-related config into your nginx site config that points php to a certain port, like this:
    • "fastcgi_pass 127.0.0.1:9000;:".
  • However, my php-fpm was configured to run under a unix socket only (you find this via the “listen” param in your php config). So, I had to add the following line to my nginx site config instead in the php section:
    • "fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;"
  • I had to include the following line in my php-specific config in my site conf file for nginx. Even the nginx example conf file is not explicit about this:
    • include snippets/fastcgi-php.conf;

Converting Your Existing Ubuntu Installation Into a VirtualBox Virtual Machine

Update for 2018: some of the commands have been changed  below to reflect new  possibilities present in Ubuntu 18.04, namely the excellent losetup command.)

I often find myself in the position of having to transfer all my files, applications, and other configurations that make my laptop “mine” onto a new laptop.

What’s so strange about that, you might add? Well, I go through all of this once every six months.  It’s not that I keep buying new computers — I don’t.  But I often obtain them in other ways — I trade, I help someone buy a new computer and in turn get their old one, etc.

So, tired of having to constantly re-install everything (or, at the very least, if I’ve imaged one laptop to another, having to spend a week or so having to get everything running just right), I decided to just convert my current main computer into a VM that I could just run on any computer, running any sort of OS that’s enough to run VirtualBox.

(This tutorial was created with VirtualBox in mind, but other VM’s have similar ways of converting the final file after you get to about step 3 or so.)

It seems like it should be easy, and after a little bit of work, I found out that it’s not too hard.

  1. First, you’ve got to make an image of your current installation.  (This is much easier if you have your entire Ubuntu install on one partition, i.e., no /home partitions on another hard drive or partition.  You can probably figure out how to manage that, but this tutorial will be just for one-partition installs).
    • Boot your computer with another startup disk (CD, jump drive, whatever), and then perform the following command:
      • dd if=/dev/sda1 of=image.bin
    • “/dev/sda1” refers to the partition name that your main install is on — you can find this by doing a “sudo blkid” or “sudo fdisk -l”
    • “image.bin” refers to the output file that the image will be contained in — this can be anywhere you want, but set it to a location that’s not on the hard drive you’re trying to image.
  2. At this point, I tried to turn the image.bin file into a .vdi file so that VirtualBox could use it for a virtual machine — the problem is, at this point, your .bin file is just a partition, and not a real “virtual” hard drive.  There’s no partition table, etc. — you have to simulate these things.
    • You do this by creation an empty “sparse image” where we’ll copy the image, simulating a hard disk, and then create a partition table:
      • dd if=/dev/zero of=newhd.img bs=1G count=0 seek=100
      • In this, “newhd.img”represents the location of the file we’re creating, and “100” represents the size of the virtual hard drive we’re creating, in gigabytes.  You may want to make this larger or smaller depending on the image you made.
    • Now, edit the image with “fdisk newhd.img“, and, following the commands presented in the fdisk interface, create a new partition table, and create a partition as large as the image you created. (The commands inside fdisk are pretty self-explanatory.)
    • Now, make the partitions available as individual devices to your system.
      • sudo kpartx -a newhd.img
    • Now, copy the original .bin file you made in step 1 onto the newly mounted partition:
      • sudo cp image.bin /dev/mapper/loop0p1
    • Now, run a disk check, and expand the copied partition to fill all of the available space, and then finally close the mounted partitions:
      • sudo e2fsck -f /dev/mapper/loop0p1
      • sudo resize2fs /dev/mapper/loop0p1
      • sudo kpartx -d newhd.img
  3. At this point, you should have a newhd.img file, which represents the entire hard drive you’ll virtually mount in your VM — the only step left is to convert it from a raw image of a hard drive into a .vdi file for use in VirtualBox:
    • VBoxManage convertfromraw -format VDI newhd.img newhd.vdi

The only steps left at this point are to create your new VM in VirtualBox, and then start it using this HD.  It more than likely won’t boot, so what you’ll need to do is start it with a livecd of your choice, and then fix the boot (I used the wonderful boot-repair utility available to Ubuntu).

 

 

Sources:

https://unix.stackexchange.com/questions/41137/convert-image-of-a-partition-into-image-of-a-disk-with-partition-table

https://superuser.com/questions/554862/how-to-convert-img-to-usable-virtualbox-format

https://askubuntu.com/questions/69363/mount-single-partition-from-image-of-entire-disk-device

HP Pavilion Touchpad Not Working (you need to “kick” it)

So, for about two days the touchpad on my HP laptop stopped working.  Of course it was right after a kernel update in Ubuntu, so I immediately blame that.  You know… because 9/10 times it is.

So, I’m checking and checking things but can’t find anything.  It’s weird.  It’s not like it’s not working correctly, or is misconfigured — it’s like Ubuntu, which is actually pretty good at picking up on hardware changes today, can’t even see it.  So on a hunch I reboot into Windows, but it’s not working there either.

So now, instead of having to tromp through the utterly useless Ubuntu forums (full of unresolved issues where people complain about some update or the other breaking something), I can now expand my search to various HP Windows forums. Where in about five minutes, I found this gem.

Apparently, on some HP laptops (or maybe all laptop hardware is set up like this, I’d honestly never encountered it before), you have to perform what’s called a “kick”:

  1. Turn off your laptop.
  2. Unplug your AC adapter.
  3. Take out your battery. (If you can’t take out your battery externally, time to pull out a screwdriver and start taking your laptop apart.)
  4. Hold down the power button on your laptop for at least 30 seconds, preferably more (just to make sure, since time is a relative construct perceived differently by all sentient forms of matter).
  5. Put in your battery, and turn back on.  Your touchpad should now be visible to your OS, be it Ubuntu or Windows, again.

Why or how this works is anyone’s guess.  I think it resets the BIOS (it seemed to do a strange double boot the first time plugging it in after performing this procedure, which is similar to what happens on a BIOS upgrade).  I’m just glad it does.

Installing the Brother HL-2270DW Printer on Ubuntu 10.04

Brother, I appreciate that you at least made an attempt at providing Linux installation files, even going so far as to provide .DEB and .RPM files.

However, none of the solutions works, and even on my version of Linux, Ubuntu 10.04, probably the most common one around, the .DEB files did next to nothing.  They didn’t setup Ubuntu’s printer configuration so that the printer showed, nor did they enable the drivers to be found when I tried to install the printer manually. (The Brother HL-2270DW is apparently so new that Ubuntu doesn’t have any default drivers in its repositories.)

What did work?  Selecting HL-2170W from the default drivers list in Ubuntu.  Seems to work fine! :P

An Abundance of GIMP Synergy

Installing GIMP 2.6 on Ubuntu 8.04

wilberWell, I got tired of being stuck with the version 2.4 of the GIMP (GNU Image Manipulation Program) that ships with Ubuntu 8.04.  It’s old, it uses the old window system that I can’t stand anymore, and version 2.6 (the current version) fixes tons of more issues that it has.

However, you can’t just go to your package manager and add it — Ubuntu locks program versions when it ships (for example, the latest version of GIMP available to Ubuntu 8.04 users is 2.4).  This is done for compatibility reasons — if version 2.4 of the GIMP works fine when Ubuntu 8.04 ships, then they lock those versions together. That way, it’s always guaranteed to work, no matter when Ubuntu is installed in the future.

However, there’re sites likes GetDeb.net which lets developers upload installer files of popular programs for Ubuntu, so that users of older versions of Ubuntu can install new programs.

So, I went to the GetDeb page for GIMP 2.6 and downloaded all the files you need to install GIMP 2.6 on Ubuntu 8.04:

Usually, in 99% of situations, you just download these files and install them, even on Ubuntu. However, on Ubuntu 8.04 with GIMP 2.6, there’s a bit of a problem — you have to force these files to install.

Now, you can do fancy command-line kung-fu if you want to, but you shouldn’t have to on Ubuntu, so I’ve included a file here for you:

Just save that file, put it along with the 5 files you downloaded from GetDeb.net into their own folder, and then run that file. (Make it executable in its properties, and then double-click on it).

And that’s it!

(I got the inspiration for that install file from this blog post here!)

The Synergy of Mac, Linux, and Windowslogo

I’ve always heard about the program called Synergy, but I’ve never used it, and that’s a damn shame.

Have a lot of computers side by side that you manage all at once? Tired of going from one keyboard and mouse, to another, even though the computers you’re working with are side by side?

Then download Synergy, configure it, and run it on all of your computers (Mac, Linux, and Windows).

And that’s it. Honestly. It’ll take you about 20 minutes and you’ll spend the next few hours wondering how you ever lived without it.

It treats all of your computers like one giant desktop — just move your mouse “off” of the side of your monitor towards your other computer, and your mouse will instantly reappear on that computer’s monitor. If you need to type something, you type it with the first computer’s monitor. Seriously.

Ah, a caveat — on Mac and Linux, the setup isn’t as streamlined and easy as it is on Linux, so there’s a program called QuickSynergy that can do it for you. If you’re using Ubuntu, it’s already in the repositories — just go to your “Add/Remove Applications” menu item, and install QuickSynergy from there.

Conky, Dell i8k Modules, and My First Ubuntu Bash Script

Conky Screenshot

Well, I started playing around with Conky yesterday — if you haven’t heard of it before, just know that it’s a neat little Linux program that runs in your background and uses very little resources that displays a very neat desktop overlay.  (Like in the picture in the Lifehacker article.)

Now, some of the stock Conky scripts were more than adequate, but I had always wanted my laptop’s CPU temperature to be displayed as well, so I had to figure out a way to do that.

Now, if you’re somewhat familiar with tinkering in Linux, you’ve probably heard of the wonderful “lm_sensors” package — it’s a neat package for Linux that helps display lots of information about motherboard temps and whatnot.  Unfortunately, due to most laptops “prorietary-ness,” lm_sensors does very little for you if you’re trying to get it to work on a laptop.

Now, I had heard of the “i8kutils” package for Linux — this was a package designed for Dell laptops in particular, to display and control fan and temperature information.

So, with that, I was off to work!

(Note — these instructions are mostly for Ubuntu/Debian installations, because that’s what I use.)

First, install the package “i8kutils” using your Linux computer’s package manager (Synaptic, if you’re using Ubuntu).

Second, add the module “i8k” to your “/etc/modules” file.  (This will start the process at boottime.)  Restart your laptop.

Third, you’ll have to create some Conky script files.  I assume you’ve already had a bit of experience at least installing Conky and starting it up.  If not, play around with the instructions in that Lifehacker article and come back here afterwards.

Now, I noticed that one of my conky script files was a file called “hddmonit.sh” which contained the text:

#!/bin/bash
echo “$(nc localhost 7634 | cut -d’|’ -f4)”

Now, using a little bit of deduction, I figured that this file used a command called “nc localhost 7634” to display a little bit of information, and then used pipe commands (the little “|” symbol) to further splice the info, extracting just the temperature of my laptop’s hard drive.

So, while “nc localhost 7634” outputted this:

|/dev/sda|ST980815A|43|C|

Using the command “(nc localhost 7634 | cut -d’|’ -f4” would output just “43”, which was the temperature of my hard drive.

(The “cut” command splices out specific text from a string it’s given, in this case the fourth (-f4) chunk of text seperated by a “|” chracter.)

Now, I learned that the “i8k” module, once loaded, could be accessed with the file at  “/proc/i8k”, which just contains a string like:

1.0 A32 7GGGGGG 53 -22 1 -22 90300 -1 2

From this you can see various Dell-specific information, the important part being “53”, which was my current processor temp.  (The items in the string are separated by spaces.)

So, I quickly made myself a new script file called “i8ktemps.sh” copying the contents of “hddmonit.sh” and changing them to:

#!/bin/bash
echo “$(head /proc/i8k | cut -d’ ‘ -f4)”

This file, when executed, will just output the fourth “chunk” in the file “/proc/i8k”, which as you remember is my current processor temp.

Now, I needed to edit my Conky configuration file, which is located in your home folder and is called “.conkyrc”.

Then I simply located the line:

${font weather:size=28}x ${font}HDD ${execi 1 ~/scripts/hddmonit.sh}C

Which displayed my hard drive temperature, and changed it to:

${font weather:size=28}x ${font}CPU ${execi 1 ~/scripts/i8ktemps.sh}C HDD ${execi 1 ~/scripts/hddmonit.sh}C

Which, when Conky was restarted, would display my hard drive temperature and my current processor temperature.

See?  It’s not that hard to program this stuff!  I did this all, both programming in the Linux “Bash” shell and coding in Conky’s personal configuration code, without any experience in either.  I just looked at what was there, and changed it.

Relevant Links:

http://www.arachnoid.com/linux/shell_programming.html

http://ubuntuforums.org/showthread.php?t=411800

http://www.linuxcommand.org/wss0010.php