Categories
Linux Tutorials

Ubuntu Rackspace, how to set up a server qualified domain name?

Easy tutorial to Fix the error: apache2: Could not reliably determine the server’s fully qualified domain name after installing Ubuntu 12.04 on your host.

Categories
Linux Tutorials

Setup a folder so that new files created in it inherit default permissions and group

A quick tutorial showing you how to ensure that new files created in your file structure will inherit the existing user and groups (no matter which user creates the new files). This tutorial is for Debian/Ubuntu and Mac:

Categories
MAMP Tutorials

Amazing tutorials to setup Apache, PHP and MySQL on Mountain Lion

After installing Mountain Lion I discovered that Apple changed their settings for Apache. Here are some amazing tutorials I came across that will help you get your Mac Mountain Lion Apache PHP MySQL server up and running.

Installing Apache MySQL, PHP and setup Virtual Hosts

http://todsul.com/lamp-mac-os-x-lion

Installing and configuring Apache, MySQL, PHP and phpMyAdmin

http://coolestguyplanettech.com/downtown/install-and-configure-apache-mysql-php-and-phpmyadmin-osx-108-mountain-lion

http://akrabat.com/computing/setting-up-php-mysql-on-os-x-10-8-mountain-lion/

Enabling .htaccess

http://book.cakephp.org/2.0/en/installation/advanced-installation.html#apache-and-mod-rewrite-and-htaccess

http://www.codepotato.co.uk/2012/07/25/enabling-localhost-on-os-x-mountain-lion/

Fixing httpd.conf for Server.app

http://petercompernolle.com/2012/07/26/fixing-httpdconf-in-osx-mountainlion

 

Categories
MySQL Uncategorized

How to reset the root mysql password if you forget it

I’ve been setting up a LEMP server, Nginx Mysql PHP, on Ubuntu and lost my root mysql password. Here’s what I did to reset the password in Terminal.

After logging into my server via SSH on Terminal I ran the following lines in Terminal.

# /etc/init.d/mysql stop
# mysqld_safe --skip-grant-tables &
$ mysql -u root

mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit

# /etc/init.d/mysql stop
# /etc/init.d/mysql start
$ mysql -u root -p

I found this solution in an answer by Benjamin Manns to a StackOverflow question here.

Categories
Git PHP

Solved: Running git pull from a php script causing an error?

I wanted to improve my Git workflow, so I went about using GitHub’s Service Hooks to set up a web hook to my development server. The idea being that I would have GitHub ping my server every time I or anyone else pushes to the master GitHub repository.

The idea was pretty simple. I would have a php file located on my development server with following command.

<?php shell_exec('git pull'); ?>

However, I quickly ran into the following permission error.

error: cannot open .git/FETCH_HEAD: Permission denied

The reason being was that my server’s Apache user doesn’t and shouldn’t have access to the root. However, to run git pull, it was trying to access the host keys, which are stored in the ~/.ssh/known_hosts file. As you can see, these files are located in the root.

So I was scratching my head for a solution when I came across this terrific tutorial, Github playground servers and auto pull from master, posted by Konstantin Kovshenin. Konstantin proposed a simple, but brilliant, solution of using the GitHub service hook to ping a local php file that would signal a server cron job to handle the git pull. If you are trying to do the same thing, and experienced the above error, follow the Konstantin’s tutorial and it should work for you.

Final notes: having a development server automatically pull from the Git repository is very useful, however it is not a good idea for production servers. It is more secure and more controlled to manually update your production servers git repository from the command line.

Categories
Git

Great video lessons on the basics of using Git version control

Git is a fast version control system. I am sure you are probably already familiar with it, but if you are not you can read about it on the official website here. Basically Git is a really useful way of backing up projects and saving ‘snapshots’ in the case where you might need to go back and reuse an old file because the new file was badly written.

The problem with Git is that it has a big learning curve. However, I found some great video tutorials created by Jason Semko on Youtube. The videos are really easy to follow and offer step-by-step instructions on the basics of using Git. If you would like to use a great version control system or if you are knew to git, here are the videos to watch.

How to use Git – Git Video Tutorial

Part 0 (Installation)

How to use Git – Git Video Tutorial

Part 1 (add, commit, push, pull, status)

How to use Git – Git Video Tutorial

Part 2 (log, reflog, show, gitk, checkout, reset)

How to use Git – Git Video Tutorial

Part 3 (The basic file flow, rm, add, commit, gitignore)

How to use Git – Git Video Tutorial

Part 3.5 (Setting up a new user account)

How to use Git – Git Video Tutorial

Part 4 (Merge Conflicts)

How to use Git – Git Video Tutorial

Part 5 (More Merge Conflicts)

How to use Git – Git Video Tutorial

Part 6 (branch, checkout, remote)

Huge thanks to Jason Semko for making these videos. Visit his channel here.

Categories
Apple TV

How to hook up your Apple TV to a computer monitor

Is it possible to hook up an Apple TV to a computer monitor? Absolutely. One of the really cool things with the Apple TV is the ability to hook it up to a computer monitor. That is exactly what I did with my 24inch Samsung monitor.

Important: Your computer monitor must be HDCP compliant for Apple TV to work. I wasn’t sure if my Samsung 2433 BW monitor was. So it was a gamble, but it worked.

Apple TV to computer monitor
Here's my setup

What you need:

1. Apple TV

2. WiFi or DSL internet connection

3. HDCP Compliant Monitor with an HDMI or DVI input.

4. If your monitor only has a DVI input (like mine) you will need an HDMI to DVI converter as well.

5. HDMI cable

6. If you monitor does not have speakers (most don’t). A stereo/amp with an optic input (for sound).

7. An optic cable.

Instructions to hook it up:

1. Connect your Apple TV to your Computer monitor with an HDMI cable. ( I used a DVI to HDMI adapter here on my monitor as well )

Apple TV to Computer Monitor with HDMI cable

2. Plug your Apple TV power cable and computer monitor in and power both of them on. You should see Apple TV loading on your monitor when you power it on. If you don’t see it, make sure your computer monitor is plugged in and powered on as well.

3. Make sure your internet connection is working.

4. Follow the Apple TV instructions setup instructions on your computer monitor

5. To have sound, connect your Apple TV to your stereo with your optic cable. (If you haven’t used an optic cable before, make sure you remove the caps on the ends of the cable before plugging them in).

Optic cable connecting Apple TV to stereo amp

6. Set your stereo to play music from the correct input.

Congratulations you are finished! Now all you have to do is enjoy your new Apple TV by watching some videos, playing music or streaming content from your iPad and iPhone.

Categories
Tutorials

How to remove apps from Mac OS X Lion LaunchPad

Mac OS X Lion LaunchPad

Today I had some apps remain on LaunchPad after deleting them from the applications folder. Apple has some work to do as there was no way of removing these apps from LaunchPad except through terminal. Here is how to use Mac Terminal to remove apps from LaunchPad.

Replace APPNAME with the name of the app. It’s case sensitive.

sqlite3 ~/Library/Application\ Support/Dock/*.db “DELETE from apps WHERE title=’APPNAME’;” && killall Dock

Here’s an example removing Picassa

sqlite3 ~/Library/Application\ Support/Dock/*.db “DELETE from apps WHERE title=’Picassa’;” && killall Dock

Categories
Tutorials

What do URL and URI stand for?

So today I thought, I wonder what the definitions for the URL and URI acronyms are. Just incase anyone else out there is curious too.

URL: Uniform Resource Locator

URI: Uniform Resource Identifier

 

So what’s the difference between the two? All URLs are URIs, but not all URIs are URLs.

It’s like trying to explain that a Human is a Mammal but a Mammal is not always a Human. – DamnHandy

These are URLs

http://somewebpage.com

http://somewebpage.com/abc/

http://somewebpage.com/abc?g=t

Since they are all URLs they are therefore all URIs too.

This is a URI but is not a URL

urn:mpeg:mpeg7:schema:2001urn:isbn:0451450523

 

Hopefully that makes sense.

Categories
PHP

The Scope Resolution Operator (::) explained

Double Colon object oriented programming

I remember when I first came across the mysterious double-colon (::), also known as the Scope Resolution Operator. I was experimenting with a php library I hadn’t written, but was asked to extend, and at the time I had no idea what classes were, how they worked, or how they helped.

To try and figure out what the double-colon did I remember I peppered Google search with questions like, “What is the :: ?” or “what does the :: symbol mean?”  Those searches proved useless. At the time php5 was still very new and most PHP coders were writing procedural code rather than object-oriented code.

Now that I use object-oriented design every day I thought I would explain what the double colon :: means, just in case there are any new PHP programmers, like I was, and are confused by the mysterious double colon.

When and how to use the double-colon:

You use the double-colon to access static methods from a class. To get the color of the bear, from the example class I wrote about here, you would write the following.

Bear::getColor();
Code language: CSS (css)

I will break the above line of code into its three parts.

1. Bear – First you write the name of the class you are referring to. In this case Bear.

2. :: – Then you use the double-colon because the method is declared as static.

3. getColor(); Then you write the name of the function you are calling that exists within that class.

And that’s the basic use of the double-colon to call a method from within a class.

The double-colon is simply a way of referencing the class object and accessing the static methods (functions) and constants within that class. If you are new to this I just said a lot. I explain these things briefly here.