install vmwaretools in debian

August 4, 2012 Leave a comment

once vmwaretools install is enabled from your vm guest machine, run below as root
mount /dev/cdrom /media/cdrom
cd /tmp
tar -zxf /media/cdrom/VMwareTools-1.0.8-126538.tar.gz
/tmp/vmware-tools-distrib/vmware-install.pl

Install VMWare Tools on a Debian 5 Guest Virtual Machine

Categories: Uncategorized Tags: , ,

PHP check folder permissions for owner/group/world

May 25, 2011 Leave a comment

where $folder is your folder path,

echo substr(sprintf('%o', fileperms($folder)), -4);

For example to check if your folder has read-write-execute permission for owner and group, and read only for world, you could do:

if (substr(sprintf('%o', fileperms($folder)), -4) == "0774") {
      $dir_writable =  true;
} else {
      $dir_writable = false;
}

Of course, you can change the octal value to 0664 or whatever suites your need or permission need to be given for owner/group/world.

Categories: PHP Tags: ,

openssl – how to disable passphrase prompt on apache2 restart

November 30, 2010 16 comments

Whenever apache2 restart and you have to manualy Enter the pass phrase of your ssl key.

To automatically start/restart apache2 without the prompt dialog, you can either store the passphrase in a secure folder or remove the password.

OPTION 1. store passphrase:

from your ssl.conf under /etc/apache2/mods-enabled/ssl.conf

SSLPassPhraseDialog  exec:/securepath/to/passphrase-file

then create passphrase-file and type

#!/bin/sh
echo "passphrase"

save file then make it executable

# chmod +x /passphrase-file

http://www.linuxquestions.org/questions/linux-server-73/apache-requires-ssl-passphrase-671559/

OPTION 2. Remove password:

# openssl rsa -in website.com.key -out website.com.key.nopass

then from update the location of your key file in your apache2 virtual hosts.

http://chrisschuld.com/2008/08/removing-the-password-on-an-apache-ssl-certificate/

 

install vmware server on windows server 2008 domain controller

August 18, 2010 16 comments

Installing VMware Server 2 on a Windows Server 2008 SBS throws out a warning if the Windows Server is set as domain controller.

Warning 25008: It is recommended that you don't install this product on a domain controller.

After google-ing for explainations, i found on vmware knowledge base docs that we would ignore it and go on with installations. Bad idea.

Everything was working fine until we had to restart SBS server and everything started to fall over.

VMware server installs a VMware DHCP service and SBS primary physical network card couldn’t have a gateway assigned automatically. The VM ethernet card took over as dhcp and assigned its own default virtual gateway

Solution: disable vmware dhcp service from the administrative tools and everything was back to normal. It cannot be disabled from the VMware Manage Virtual Networks tool.

Obama promotion at Dreamhost

January 22, 2009 2 comments

YES WE CAN!

Dreamhost web hosting is offering this awesome offer with unlimited disk space and unlimited bandwidth on all their hosting plans. For just $5.95/month you can have the ‘all-you-can-eat’ deal to get started with your website. check it out what you can get at http://dreamhost.com/hosting.html

Obama web hosting dreamhost

phalanger jcx conflict

November 15, 2008 Leave a comment

What IDE do you use for your PHP web dev.? As a .NET developer, first choice is of course Visual Studio. Most PHP developers probably use Dreamweaver or for the hardcore code monkeys use notepad++? SSH directly onto dev server?

JCX Software is the best PHP IDE, if not the only one, IDE add-on for Visual Studio – also supported in VS2008. After I found about the Phalanger project and installed in from codeplex.com/phalanger, I am no longer able to create a simple PHP project in VS2008 using PHP IDE supposedly due to conflicting between the two addon having the same file extensions. How do I fix this? uninstall on of them? email JCX to change their file extension? or the Phalanger dev. guys to choose a different phpproj extension?

phpide_phalanger

phpide_phalanger

Microsoft and Zend Collaboration

November 13, 2008 1 comment

PHP: Hypertext Processor is the most popular scripting language for web development according to TIOBE and coming from a .NET background I was thrilled to hear that Microsoft Corp. has been in collaboration with PHP vendor, Zend Technologies Ltd. John K. Waters’ article What’s Next for Microsoft and PHP? briefs Microsoft Silverlight in adopting PHP for RIA (Rich Internet Application), following Adobe Flex. More interestingly is the support of PHP in the Dynamic Language Runtime announcement to add services to the .NET CLR. If now IronPython and Ruby are supported in .NET, why not PHP?

This article surely got me excited to google for more and found that this collaboration between Microsoft and Zend is back dated since 2006 in “Microsoft Opens PHP Door” and in “Microsoft Hosts Project to Run PHP on .NET” not for the support of PHP under IIS (wich seems to be a terrible combination due to performance and reliability issues), but for the initial partnership in supporting PHP on .NET. The effort project called Phalanger to bringing PHP onto a .NET environment can be followed at http://www.codeplex.com/Phalanger


Categories: .Net, PHP Tags: , , , ,

simple AHAH (Asynchronous HTML And HTTP) library

November 12, 2008 Leave a comment

Just thought of sharing a very simple javascript AHAH library and quickly demo a simple usage in one line of code. AHAH works very similarly to AJAX but without the X of Ajax. It unables you to dynamically update your page content without a whole page refresh. Instead of parsing XML data back you could simply return html. Here is how simple it is to dynamically reload your page content using AHAH.

File: ahahlib.js

Step1: Create a javascript file and copy the code in the following steps.

Step2: Write the following function to specify the XMLHTTPrequest object from different browsers

function getXMLHTTPreq(){
try {
req = new XMLHttpRequest(); /* Firefox */
} catch (e){
try{
req = new ActiveXObject(“Msxml2.XMLHTTP”);  /* previous versions of IE7 */
} catch (e) {
try {
req = new ActiveXObject(“Microsoft.XMLHTTP”); /* IE7+ */
} catch (err) {
req = false;
}
}
}
return req;
}

Step3: Create a function to write the return text to the designated document page element

var http = getXMLHTTPreq(); //XMLHTTPrequest object
function responseAHAH(pageElement) {
var output = ”;
if(http.readyState == 4){
if(http.status == 200){
output = http.responseText;
document.getElementById(pageElement).innerHTML = output;
}
}
}

Step4: Create the function that will be called from your html

/* call this AHAH function for dynamic html content display*/
function getAHAH(url, pageElement, LoadingMessage)
{
document.getElementById(pageElement).innerHTML = LoadingMessage;
http.onreadystatechange
= function(){responseAHAH(pageElement);};
http.open(“GET”, url, true);
http.send(null);

}

Example:

<script language=”Javascript” src=”ahahlib.js”></script>

<input type=”text” id=”mypage” name=”mypage” size=50>
<input type=”button” onClick=”getAHAH(document.getElementById(‘mypage’).value, ‘displaydiv’, ‘Loading content…’)” value=”Display page content”>
<br>
<div id=”displaydiv”></div>

In the above example, we have an input text to let you display whatever page you want to.

ahah

In displayTasks.php you may have simple echo strings to complex server side data thrown from database.

<?php
echo “Task1:<br><b>Configure SQL Server…<b>”;
?>

In step2, the xmlhttprequest object property readyState reports on the status of the request where

0=uninitialized, 1=loading, 2=loaded, 3=interactive, 4=completed

The status property returns the HTTP status code as 200 returns a successful request.

PHP and SQL Server Stored Procedures, how to insert a new record under 4 steps

November 11, 2008 3 comments

Having SQL Server storing data for your PHP web application isn’t a common combination but is a far better option than having MySQL when it comes to larger database. I wont brag about why choose SQL Server over MySQL instead will quickly demonstrate in few steps how to execute stored proc in PHP using mssql database extension library.

We will be using mssql_query to execute the stored procedure and return records added using SCOPE_IDENTITY(). Please accept my appologies for coding indentation and lack colouring! @@

Let’s take a task list scenario where we manage our to-do tasks in a table having an ID, name, date added, priority task, and active fields.

First step, create your table in SQL server like the following:

tbltask

Step 2, Create a stored procedure to insert records:

CREATE proc [dbo].[usp_InsertTask]
(
@TaskName varchar(255),
@TaskDateAdded datetime,
@TaskPriority int,
@TaskActive bit
)
as
insert into tblTask(TaskName, TaskDateAdded, TaskPriority, TaskActive)
values (@TaskName, @TaskDateAdded, @TaskPriority, @TaskActive)
SELECT SCOPE_IDENTITY() as id
RETURN

Note “SELECT SCOPE_IDENTITY() as id” will return the inserted record TaskID set as auto increment.

Check out Pinal Dave, SQL Server MVP, blog on the differenced between SCOPE_IDENTITY() vs @@IDENTITY vs IDENT_CURRENT to retrieve the last inserted record.

Step3, back to PHP to create your mssql_connect connection and execute stored procedure

<?php
$myServer = “10.64.0.7”;
$myUser = “mydevuser”;
$myPass = “mydevpassword”;
$myDB = “devdatabase”;

// connection to the database
$dbhandle = mssql_connect($myServer, $myUser, $myPass)
or die(“Couldn’t connect to SQL Server on $myServer”);

// select a database to work with
$selected = mssql_select_db($myDB, $dbhandle)
or die(“Couldn’t open database $myDB”);

//setup variable data
$TaskName = ‘Configure SQL Server’;
$TaskDateAdded = ’12/22/2008′;
$TaskPriority = 2;
$TaskActive = true;

$result = mssql_query(“usp_InsertTask ‘$TaskName’, ‘$TaskDateAdded’, ‘$TaskPriority’, ‘$TaskActive'”, $dbhandle);
OR
$result = mssql_query(“EXEC dbo.usp_InsertTask @TaskPriority = ‘$TaskPriority’, @TaskName = ‘$TaskName’, @TaskDateAdded = ‘$TaskDateAdded’, @TaskActive = ‘$TaskActive'”, $dbhandle);
$result = mssql_fetch_object($result);
echo “Record ID = “.$result->id;

// close the connection
mssql_close($dbhandle);
?>

Step 4, DONE!

Most blog posts found when google-ing php and stored procedures SQL Server will go on about using mssql_execute function instead of mssql_query directly. But you will find much more posts about how it actually doesn’t work as php.net/mssql manual suggested. Probably because of new version of SQL server? PHP? or wrong mssql driver or configuration?

The steps i have provided is working under PHP5 on a Debian dev server and SQL Server 2008 CTP.

Microsoft HTTPAPI/2.0 disabling Apache

November 7, 2008 209 comments

I’be been working on php for 2 months now and developing on my laptop with WAMP installed before uploading to work’s dev server. Now working with SQL Server instead of MySQL, I’ve installed SQL SERVER 2008 CTP for test and suddently Apache went down as port 80 was used by Microsoft HTTPAPI/2.0.

I then found SSRS (SQL Server Reporting Services) was still running after uninstalling SQL Server 2008 as it features a web service even though IIS is not installed according to wiki.

I couldn’t find any info on google relating to this small issue that puzzled me for a short while. i hope this helps finding ppl stupid like me sometimes to solve their problem