PHP 5.3 symlink() in Windows Vista and Server 2008

June 17th, 2009

I just discovered that Vista can create symbolic links via the command mklink! It performs the same thing as ln in linux with both hard and soft links. My understanding of links is fairly limited but I use them on my web server to apply seam-less templates. Until now, this was something that I could only test on my web server and not my Windows 7 development PC. PHP 5.3 automatically uses the mklink command when you use symlink() but the problem comes with enabling it in Windows Vista or 7.

If you pull up a command prompt and try to use mklink, you’ll see something like this:

D:\Web>mklink /D nnnnn.com\content templates\bluemoon
You do not have sufficient privilege to perform this operation.

Or PHP will throw this back at you:

Debug Warning: /includes/templates.inc.php line 78 - symlink() [function.symlink]: Cannot create symlink, error code(1314)

To fix this:

  1. Bring up your run box, type “secpol.msc” and click OK.
  2. Navigate under the Security Settings \ Local Policies \ User Rights Assignment folder.
  3. Find “Create symbolic links” and add the Users group to it.

I think you need to restart your computer or something after doing this.

Josh Guides, Web Development , , , , , ,

Install PHP 5.3.0 on CentOS 5 as CGI along side PHP 5.2.9

June 16th, 2009

Well, turns out I’d rather play with just PHP 5.3 RC4 for now. Here is my guide to installing it onto my CentOS 5 64-bit VPS from 1&1.

Update: PHP 5.3.0 has been released and there are some changes.

It went pretty smoothly. Here is the guide, minus the hours of trial and error, of course:

First, install anything you may need to compile with.

yum install gcc gcc-c++.x86_64

yum install \
  libicu-devel.x86_64 \
  libxml2-devel.x86_64 \
  mysql-devel.x86_64 \
  libpng-devel.x86_64 \
  libjpeg-devel.x86_64 \
  curl-devel.x86_64 \
  bzip2-devel.x86_64 \
  gettext-devel.x86_64 \
  gmp-devel.x86_64 \
  pcre-devel.x86_64 \
  freetype-devel.x86_64 \
  gd-devel.x86_64 \
  aspell-devel.x86_64

NOTE: You can copy that entire block and paste it, the backslash (\) will carry the command over to the next line automatically.

Next, make the folders for the configs and binaries.

mkdir /usr/local/php53 /etc/php53 /etc/php53.d


Begin, by downloading and extracting the latest snapshot. Don’t use the file name I have below, get it fresh from snaps.php.net.

cd ~
wget http://us2.php.net/get/php-5.3.0.tar.bz2/from/us.php.net/mirror
tar xjf php-5.3.0.tar.bz2
cd php-5.3.0.tar.bz2

# gz: tar xzf php-5.3.0.tar.gz
# bz2: tar xfj php-5.3.0.tar.bz2
# zip: tar xfZ php-5.3.0.zip


Now, set up all of your configuration options. You may want to adjust these. To see what they mean, type: ./configure --help

./configure \
  --prefix=/usr/local/php53 \
  --with-libdir=lib64 \
  --with-config-file-path=/etc/php53 \
  --with-config-file-scan-dir=/etc/php53.d \
  --with-bz2 \
  --with-curl \
  --with-exec-dir=/usr/bin \
  --with-freetype-dir=/usr \
  --with-png-dir=/usr \
  --enable-gd-native-ttf \
  --without-gdbm \
  --with-gettext \
  --with-gmp \
  --with-iconv \
  --with-jpeg-dir=/usr \
  --with-openssl \
  --with-png-dir=/usr \
  --with-pspell \
  --with-libexpat-dir=/usr \
  --with-pcre-regex=/usr \
  --with-zlib \
  --with-layout=GNU \
  --enable-exif \
  --enable-ftp \
  --enable-magic-quotes \
  --enable-sockets \
  --enable-sysvsem \
  --enable-sysvshm \
  --enable-sysvmsg \
  --enable-wddx \
  --with-kerberos \
  --enable-ucd-snmp-hack \
  --enable-shmop \
  --enable-calendar \
  --with-mysql=mysqlnd \
  --with-mysqli=mysqlnd \
  --with-pdo-mysql=mysqlnd \
  --with-mysql-sock=/var/lib/mysql/mysql.sock \
  --with-libxml-dir=/usr \
  --without-mysql \
  --with-gd=/usr


Finally, compile and install!

gmake
gmake install


Lastly, you’ll likely want to use it in Apache… Here is how I set up my domain to use PHP 5.3:

<VirtualHost 74.208.46.111:80>
  ServerName php53.mainelan.com:80
  ServerAlias www.php53.mainelan.com
  UseCanonicalName On
  ServerAdmin "webmaster@mainelan.net"
  DocumentRoot /var/www/vhosts/php53.mainelan.com/httpdocs

  # PHP 5.3
  ScriptAlias /php53-cgi /usr/local/php53/bin/php-cgi
  Action application/x-http-php53 /php53-cgi
  AddHandler application/x-http-php53 .php

  . . .

Josh Guides, Web Development ,

Installing PHP 6 on CentOS 5

June 15th, 2009

I started playing in PHP 5.3 with Zend’s Early Access 7.0 Studio and Server CE and wanted to put it on my web server. Problem: It isn’t released yet and the library name is “php5″, same as PHP 5.2. I didn’t want to replace my production-ready PHP installation with a release candidate. I’m sure that would make my clients happy about unknown security holes, yadda yadda. The only solution is to install PHP 6 and enable it by virtual domain or directory. Please note that it is entirely possible to install PHP 5.3 along side PHP 5.2.9 using the first as CGI, but I want to avoid the confusion.

My CentOS 5 64-bit server is a VPS from 1&1.

Final notes before we get started. I did a “yum update” to bring my system to the latest everything. And no, installing libxml2 or icu via yum won’t help you. You can skip the gmake test, it is 7180 individual tests that can take a LOT of time on slower servers. CentOS is based on RedHat, so this will likely work with it as well.


# install the stuff you need to compile

yum install gcc gcc-c++.x86_64
yum install mysql-devel.x86_64 libpng-devel.x86_64 libjpeg-devel.x86_64

# compile and install icu where php6 can find it

mkdir /usr/local/icu
wget ftp://ftp.software.ibm.com/software/globalization/icu/3.6/icu4c-3_6-src.tgz
tar xkmfz icu4c-3_6-src.tgz
cd icu/source
./configure --prefix=/usr/local/icu
gmake
gmake install
cd ../..

# compile and install icu where php6 can find it

mkdir /usr/local/libxml2
wget ftp://xmlsoft.org/libxml2/libxml2-2.7.3.tar.gz
tar xkmfz libxml2-2.7.3.tar.gz
cd libxml2-2.7.3
autoreconf
./configure --prefix=/usr/local/libxml2
gmake
gmake install
cd ..

# compile php6 from http://snaps.php.net
# with libxml2, GD (jpeg + png) and MySQL

# make the config path
mkdir /etc/php6
mkdir /etc/php6.d

# download and extract the latest path, get it from snaps.php.net
wget http://snaps.php.net/php6.0-############
tar xkmfz php6.0-############
cd ~/php6.0-############

# refresh the conf
autoconf

# paste in this entire block and press enter:
./configure \
--prefix=/usr/local/php6 \
--with-config-file-path=/etc/php6 \
--with-config-file-scan-dir=/etc/php6.d \
--with-icu-dir=/usr/local/icu \
--with-libxml-dir=/usr/local/libxml2 \
--with-gd \
--with-jpeg-dir=/usr/lib64 \
--with-png-dir=/usr/lib64 \
--with-zlib-dir=/usr/lib64 \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-mysql-sock=/var/lib/mysql/mysql.sock

# alt for mysqli: --with-mysqli=/usr/bin/mysql_config

# compile and install. you can skip test if you want.
gmake
gmake test
gmake install

# prepare configuration
cp php.ini-* /etc/php6

# and ONE of the following to set up your php.ini

# if you plan to host pages to the outside world
cp php.ini-production /etc/php6/php.ini

# if you plan to use this installation as a test site for development
cp php.ini-development /etc/php6 php.ini

# if you have issues with mysql:
ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock

Oh yeah, and running along side PHP 5? Toss something like this in a new file: /etc/httpd/conf.d/php6.conf


ScriptAlias /php6-cgi /usr/local/php6/bin/php-cgi
Action application/x-http-php6 /php6-cgi
AddHandler application/x-http-php6 .php6

Now anything .php6 will run php6 as cgi. If you have problems with CGI or MySQL, try nixing SuExec first. If you want to use it, you’ll need to be recompile it with a special folder permission for PHP 6.

Josh Guides, Web Development , , , ,

Installing/Updating APKs onto an Android Phone

June 4th, 2009

While developing for Android, I found myself installing and reinstalling various .apk files. I use Windows 7, but this applies to Windows in general. I created a shortcut so that I can just double-click an apk and install it.

Read more…

Josh Android , , , ,

JavaScript (V8 Engine) and Source

February 17th, 2009

I decided that I would try implementing V8 with the only game engine I am familiar with: Source.  With no intention to finish the project, it should at least be a good learning experience.  But regardless, I didn’t foresee such a hindering factor…  Now, my skills are: BASIC (G/W to .NET 3.5), C/C++ (GNU to .NET), PHP (3, 4 & 5), C#, SQL, HTML/CSS, Java, lua.  With one crucial thing missing…  You guess it: JavaScript.  I don’t know hardly anything about the structure of the language.  I can do a document.write like nobody’s business but beyond that, I’ve got nothing.  Another project failed before it started…. Or maybe I’ll just learn JS.

Josh Game Programming

Life happens, when I get around to it.

February 12th, 2009

Wow, it is amazing how many projects a proctrastinator can take on and ever accomplish anything.

Fallout 3, started playing, lost my steam when I have to head across the world to some stupid Vault furthest end of unexplorer territory.  Oblivion has horses, as if nobody can get a car working 200 years after a nuclear apocolypse.

Grand Theft Auto 4.  Both on the PC (runs like poop) and the Xbox (no HD tv), I’ve gotten nowhere in single player.  I just need ambition to go back to playing it.  Unfortunately I’ve got too many more important things on my plate than playing games.  Hence why I haven’t touched my new 360 in a month.  The only thing I play is Garry’s Mod, probably because I can develop for it.  I’d love to get into professional game development.  To have artists to actually make something I code pretty would be the difference between abandon project to indie hit.

Waterworld gamemode for Garry’s Mod.  Flood sucked but the premise was delightful, so I made my own from scratch without a sandbox base.  Now that I have made it a bit past Flood, I don’t have ambition to go back an add the perks and bonuses.  I have excuses though, no artist to draw my icons and Garry is ignoring my bug reports (nothing new there).

Contracted web development and automated data entry.  Who knew there would be a high demand for this?  I’ve started two projects and I’m stuck learning everything Drupal.  For such a smart platform it is a bitch to comprehend the reasoning behind form field names.  Good thing people pay me after the work is complete.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec augue. Vestibulum sollicitudin. Nulla facilisi. Nam feugiat porttitor neque. Proin neque libero, tempus sit amet, interdum vitae, lacinia vel, elit. Maecenas dictum, lectus fermentum bibendum vulp.  Sorry NDA.

Electrical engineering… A fantastic hobby but requires a lot of cash to order new toys.  Still need to shell out $80 for a USB AVR programmer because my bloody mobo doesn’t have a parellel header.  Getting good with soldering though.

Upcoming daughter.  While I’m extremely excited and distracted by the prospect of my daughter, I just have no ambition to read books about parenting.  Isn’t that shit supposed to come naturally?Last half year at quarter-century.  While this is my last year at 25 and I’ll be starting the next quarter century of my life in June, I’ve accomplished only one life goal (see above) and absolutely nothing else.

Josh Daughter, Gaming, Life

First sight of my first baby

December 4th, 2008

Here is the ultrasound at 12 weeks, 1 day.  Supposedly closer to 13 weeks according to Liss, but whatever, between 12 weeks and 13 weeks somewhere. It’s my baby and it is growing, case closed.

If you can’t see YouTube, download the low quality abridged (32.8mb) or high quality unabridged (140mb).

Josh Daughter, Life

My first breadboard

September 6th, 2008

I started getting paid for my last hobby so I had to obtain another one, my pick?  Engineering.

It has always been my dream to create devices and program them.  I really never cared what, whether TV remotes, clock radios or smart phones.  I just always wanted the ability to create but I never had the ambition or money to get started.  I used to break apart my radios and other electronics that I’d find lying around.  I never fully understood how they worked but I was determined to learn something from them.  I supposed there was one thing, I learned that four 1.5v batteries powering a single led using tinfoil as a conductor could start a cardboard box on fire.  Like I’d know to use resistors when I was 8 years old.

I came across a website named Sparkfun.  They sell various “goodies” for people that want stuff cheap and in small quantities.  Not to be confused with Digikey, which just supplies components, Sparkfun has layman-termed descriptions, pictures, comments, tutorials and forums.  They also have breakout boards for components too difficult to solder.

After finding a tutorial from Sparkfun named Beginning Embedded Electronics, the dream of starting seemed within reach.  On the second page, it lists the parts I needed, it even added them to my shopping card.  Only delayed by the fact that I forgot to add a breadboard.  With my second order, I nabbed a couple black-light LEDs to play with, neat!

Soldering the Breadboard Power Supply Kit

With my new soldering iron and breadboard power kit, I began my first attempt at soldering.  It seemed to go alright.  I had to reflow some joints and straighten them.  Once it came to testing it, it was a different story.  My multimeter read 3.01V on 3.3V setting and 3.23V on 5V setting.  Not good.  I discovered that the wall wart I purchased wasn’t within the minimum voltage, 5V and the range is 6V to 12v.  Oops.  So with a 6.5V in one hand and my multimeter in the other I tried again.  15mV on 3.3V and 1.1V on 5V.   My first guess, I didn’t solder my joints properly.  Under close examination, that was the case.  My solder didn’t make it all the way though the board in several places.  After reflowing those pads and adding some solder, the final test was very exciting.  Ready?  3.32V and 5.05V!

Breadboard Power Kit (Top) Breadboard Power Kit (Bottom)

The First Project

After making a button turn on an LED, it was time to really get my feet wet and touch the breaker box.  Pulling out my ATmega168 (basically a little CPU that runs at 1 or 8MHz by itself, 20MHz with a quartz).  I did Sparkfun’s little “make the LED blink” then “make it blink faster” using the quartz.  Well, installing someone else’s code was boring.  I wanted to interact with my new toy.  How could I make it think?

Since I had a button, three LEDs (well, more LEDs but only three resistors to use them), and elite programming skills, I’d make a little recording program.  Basically, you enter a pattern using the button and it plays it back after.  It can remember up to 128 button pressed and up to 4.99 seconds per event (a press or release).  The whole process took about two hours to debug, after I released that you have to put a resistor on a button’s pin, it went a lot smoother.

Nark Pattern Record - Version 1

That’s my first completely custom circuit!

On day three with my breadboard, I decided to recode it a bit and make the layout a little prettier.  Here is version two:

Nark Pattern Record (Front) - Version 2 Nark Pattern Record (Back) - Version 2

Code anyone? nark_patternrecorder.zip

Josh Electrical Engineering

Carnival Valor

May 19th, 2008

Carnival Valor taken at Grand Cayman (by Larissa) Well… Today is my second visit to the Carnival Valor.  It certainly didn’t take long to remember the layout of the ship.  My cabin last time (two years ago) was on Deck 7 Forward (front of the ship) with a forward window.  This time I’m near the bottom Deck 2 Forward with no window.

When you travel with a group, there is always at least one that makes the traveling part tortuous.  Apart from being blatantly unpleasant, everything went smoothly except for the preselect plane seats.  Miami was fun and relaxing for a night but the “travel” wasn’t effectively over until we hit our stateroom.

Doris, Phil Jr, Me, Amanda, Phil 3rd, Tina, Rachel (taken by Larissa)

Anyway, more tomorrow…

Tags: , ,

Josh Cruise 2008 , ,

No choice for you!

September 6th, 2007

I had higher expectations.  BioShock’s choices in the story are really only one.  How do you want the game to end, obviously the good ending or the bad ending.  The choice is obviously clear once you meet your first Little Sister.  Besides choosing what Plasmids to purchase and weapons to upgrade and where to spend your loot, there isn’t another damn choice to be made.

The story is great and the lack of choices fit in nicely near end game but I was really hoping for more.  It is a kill everything you see that reminds me of the likes of Wolfenstein.  The only difference is you have more combative options available.  Playing on medium difficulty, I found the whole game to be insultingly easy.  Hints pretty much move any element from puzzles.

The graphics and the gameplay is a fresh break from everything else but I would really like to see this revolutionary combination of RPG and FPS that was claimed to rival Deus Ex.  Even the second iteration of Deus Ex has this looking like every other FPS out there with a couple new bells and whistles.

Story and combat still make this a great game, I just feel lied to.

Tags:

Josh Gaming, Review