Categories
Programming Server 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;
Categories
Computing Linux Science and Technology Ubuntu

rsync to AWS using .PEM key

Took me a little while to figure this out, but it’s a pretty standard implementation of the rsync command — you use the “-e” command and then specify an entire ssh command to use, like below:

function amazonrsync {
rsync -rave “ssh -i ~/.ssh/AWS_key.pem” $1 $2
}

That’s an entire shell function, by the way, that makes the whole thing easier to use.  Feel free to put it in your shell alias file.

Source: Rsync to AWS EC2 Using .PEM key – AnthonyChambers.co.uk Blog

Categories
Computing Hacking Internet Linux Programming Science and Technology Ubuntu

OpenVPN One-Command Server Install Script

I have been looking for a script like this for about a year now:

https://github.com/Nyr/openvpn-install

For some reason that I never understood, installing and setting up an OpenVPN has always been a pain in the ass.  I’ve had one I’ve been using for about a year, but it’s on Amazon’s AWS as was installed through an appliance install, and I really wanted to learn how it worked myself.

Every tutorial I saw either didn’t make sense, or the steps didn’t work.  I set about to try and create a one-script install myself, and then thought, “No — somebody has to have done this before.”

And lo and behold — that’s where I found the above github repo.  It’s amazing, and it works.  I’m going to donate to this person, because they saved me a good bit of work.

 

Categories
Computing Hardware Linux Ubuntu

GeekBench for Linux ARM?

Just got a Rasberry Pi and you’re wanting to benchmark it against other computers that you’ve benchmarked with GeekBench?

It’s not possible, for the most part — no release version of GeekBench for the ARM platform exists, but the creator of GeekBench did release a one-time build of GeekBench 2 a while back:

Source: GeekBench for Linux ARM? / Geekbench / Discussion Area – Primate Labs Support

Categories
Internet Linux Programming Science and Technology Ubuntu

mysql_connect() breaking with an upgrade to PHP7?

mysql_connect() has been finally removed from PHP7 (it was deprecated for some time), and now you have to use mysqli_connect();   The same goes for any other mysql_ commmand.  (I simply did a find/replace for “mysql_” and changed it to “mysqli_” in my php code.

Also, if you’re running your own server, you probably need to install the “php-mysql” after upgrading to PHP7 — it doesn’t seem to be installed along by default anymore.

Categories
Hacking Linux Programming Science and Technology Ubuntu

Using Dreamhost’s VPS as a MySQL Server

[Editor’s Note: Dreamhost no longer allows sudo access on their VPS servers, so the below is no longer possible. If you’re reading this, you might want to check out Amazon’s AWS. Nowhere near as user friendly as Dreamhost, but MUCH more powerful.]

I’ve been a happy customer of DreamHost for many years now — for $9.95 a month, I was able to get loads of diskspace and unlimited bandwidth, all from a great company that was staffed by great people who were very technically competent.

It is “shared hosting,” however — that means you’re getting it that cheap because you’re sharing server CPU power, available RAM, etc, with many other people who are also getting a great deal. You’ll notice this in any WordPress sites you may run on Dreamhost’s shared hosting — there’s about a 7-10 second delay between when you navigate to your site and when your page actually loads, mostly because your server processes are waiting in line behind everyone else’s.

So, Dreamhost does offer a “VPS” service — with this, you’re getting an absolute amount of RAM, CPU power, etc, that will only be used for your sites. It’s a tiny bit more expensive, at $14.95 or so a month, but it’s worth every penny.

If you’ve run WordPress installations on a Dreamhost site, though, you know that your mysql databases are on a seperate server entirely, and that may slow things down as well. Even if you move your WordPress installs to a VPS, your mysql databases will still be on shared hosting. DreamHost offers a “MySQL VPS,” but it costs another $15 a month (minimum), and you have no control over it at all.

A better solution would be to run your own MySQL server on DreamHost’s main VPS, since they give you root command-line access. There are a few hiccups in this process (some put there by DreamHost itself), but otherwise you should be able to do it.

  1. First, create an admin user for your VPS that has sudo abilities, and log into your VPS with that through ssh.
  2. Second, you have to tweak apt so you can even install the mysql-server package. It appears as if part of installing packages through apt involves temporarily storing files in /tmp and then running them from there.Unfortunately, the /tmp directory is mounted on DreamHost’s VPS servers with the noexec option, which means that you can’t run files that are present in that directory. That basically prevents you from installing the mysql-server package until you tweak apt to temporarily stage files in /var/tmp instead. Do this by:Creating a file called apt.conf in the /etc/apt/ directory, and edit it so the contents are the following:
    APT::ExtractTemplates::TempDir "/var/tmp";
  3. Then, install the mysql-server package:
    sudo apt-get install mysql-server;
    

    (When it asks to set a root password, make sure and set one.)

  4. Now, edit the file /etc/mysql/my.cnf and set the following options:
    bind-address=psXXXXX.dreamhostps.com

    (Replace psXXXXX with the name of your dreamhost VPS.)

  5. Restart your mysql service:
    sudo service mysql restart

At this point, you should be able to log in to your new mysql server:

mysql -u root -p

and then perform what SQL functions you need to.

A great thing to do is to install phpmyadmin using the tutorial here: http://wiki.phpmyadmin.net/pma/Quick_Install

First you’ll want to create a user (that isn’t your root user) to log into phpmyadmin:

mysql> CREATE USER ‘newusr’@’%’ IDENTIFIED BY ‘your_password';
mysql> GRANT ALL PRIVILEGES ON *.* TO ‘newusr’@’%’ WITH GRANT OPTION;

At this point, you can sync your old databases to your new mysql server using the built-in sync tool that’s in DreamHost’s installations of phpmyadmin.  Then, just edit the wp-config.php file in the folder of your WordPress installations, and change the line that says the following to your DreamHost VPS:

define('DB_HOST', 'psXXXXXX.dreamhostps.com');

Sources:

Installing mysqld on Dreamhost VPS

https://bugs.launchpad.net/ubuntu/+source/debconf/+bug/90085

http://serverfault.com/questions/72356/how-useful-is-mounting-tmp-noexec

 

 

Categories
Ubuntu

Ubuntu Touch on the Nexus 7 (2013)

I tried Ubuntu for devices — once I figured out what I was doing wrong (you have to flash your device to complete stock and wipe it beforehand), the install went pretty well.

The system is beautiful.  The way to navigate through the UI is beautiful as well.  You swipe from the right to switch between apps.  You swipe up from the bottom very lightly to access the app’s context menu. You swipe from the top to access your notification panel, and you swipe from the left to access a quick launch menu of apps.

However… there aren’t many apps to speak of yet, and the ones that are there are mostly web frames.

Categories
Life Linux Ubuntu

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

Categories
Hardware Linux Science and Technology Ubuntu

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.

Categories
Gaming Linux Ubuntu

Steam for Linux, with Repository, but no GPG Key?

Steam For Linux Now Available To All Users ~ Web Upd8: Ubuntu / Linux blogGreat job on making Steam for Ubuntu there, Valve, but (boo! hiss!) on not including the damn key with the installation so people can actually update it when they install it.

This blog mentions how to fix it, with the command below:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F24AEA9FB05498B7