Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts

Monday, August 2, 2010

Existing PHP / Ruby not working with MySQL installed with 'sudo port install'

By Default OSX 10.x contains PHP & Ruby installed already. I wanted to make work few applications which used MySQL, PHP & Ruby. So to do this, I installed Xcode & MacPorts too. Then installed mysql using 'sudo port install' and installed successfully. But when I executed the applications, I found that neither PHP nor Ruby could know which mysql.sock can be used to make the existing application work. After a deep search found that port install uses different location and stores the mysql socket. I tried to edit the php.ini file to make sure that it gets connected to the existing socket, but still it didn't worked.

When executed the PHP code I got this warning "Warning: mysql_connect(): [2002] No such file or directory (trying to connect via unix:///tmp/mysql.sock) in /Users" but without this solved I can't connect to DB and get the code working.

When I tried with Ruby also it gave me some weird error "ruby `initialize`: wrong number of arguments (4 for 0) (ArgumentError)" and I got frustrated little bit.

So instead of debugging more I thought I can remove the existing PHP & Ruby and install them using the port install command. So I followed the few steps like mentioned below:

sudo mv /System/Library/Frameworks/Ruby.framework/Versions/1.8 /System/Library/Frameworks/Ruby.framework/Versions/1.8.dead

sudo port install ruby
sudo port install rb-rubygems

sudo mv /usr/bin/ruby /usr/bin/old_ruby
sudo mv /usr/bin/gem /usr/bin/old_gem
sudo ln -s /opt/local/bin/ruby /usr/bin/ruby
sudo ln -s /opt/local/bin/gem /usr/bin/gem

sudo gem update --system

sudo gem install xml-simple
sudo gem install mysql

sudo port install php5
sudo port install php5-mysql
sudo port install php5-mbstring

sudo cp /opt/local/etc/php5/php.ini-production /opt/local/etc/php5/php.ini

locate mysqld.sock
==> /opt/local/var/run/mysql5/mysqld.sock (mostly this will be)

sudo vim /opt/local/etc/php5/php.ini

and change all mysql & mysqli default_socket = /opt/local/var/run/mysql5/mysqld.sock

sudo mv /usr/bin/php /usr/bin/old_php

The above commands will rename the existing PHP & Ruby and uses the new Ruby & PHP installed using the port install commands. After updating the php.ini my existing code worked perfectly as though there were no issues. Even the Ruby also didn't gave me any error, even that too worked fantastically.

I hope this will help you to resolve your problem easily rather than debugging the issue which might eat up your time.

Friday, July 30, 2010

Uninstall Ruby / PHP in existing Mac OS

Hi Guys, posting this after a long period as was little busy ;-). Anyways lets get into the subject.

Whenever OSX 10.x version installed, by default PHP / Ruby will also be installed. This is good but sometimes we don't want the particular version installed so to remove this we need to do the following steps.

For Ruby
sudo mv /System/Library/Frameworks/Ruby.framework/Versions/1.8 /System/Library/Frameworks/Ruby.framework/Versions/1.8.dead
sudo mv /usr/bin/ruby /usr/bin/old_ruby
sudo mv /usr/bin/gem /usr/bin/old_gem

For PHP
sudo mv /usr/bin/php /usr/bin/old_php

Tuesday, July 28, 2009

Basic SCiTE configuration for Drupal

Suppose you are working on Drupal and new to SCiTE editor and you want to customize then try this little below trick to help your eyes feel cool. The below info will help you to colorize little. This is just a start and would let you guys know how easy to do the stuff. I know most of the guys working in Ubuntu + SCiTE + Drupal for their projects.

In the SCiTE editor click Options Menu then click "Open User Options File"

copy paste the below settings

# PHP
style.php.118=fore:#CD1C69,back:#25272B,eolfilled
# Matching braces
style.php.34=fore:#E21E1E,back:#25272B,font=Monospace,size:12
# Not maching braces
style.php.35=fore:#FF0000,back:#25272B,font=Monospace,size:12
# Double quoted String
style.php.119=fore:#E17C4A,back:#25272B
# Single quoted string
style.php.120=fore:#F6E443,back:#25272B
# Keyword
style.php.121=fore:#FCFDFA,back:#25272B
# Number
style.php.122=fore:#CC9900,back:#25272B,
# Variable
style.php.123=fore:#53B6F0,back:#25272B
# Comment
style.php.124=fore:#999999,$(font.comment),back:#25272B,eolfilled
# One line comment
style.php.125=fore:#929394,$(font.comment),back:#25272B
# PHP variable in double quoted string
style.php.126=fore:#00007F,italics,back:#25272B
# PHP operator
style.php.127=fore:#FCFDFA,back:#25272B

# File patterns
file.patterns.php=*.php;*.php4;*.inc;*.module;*.info;*.install;*.views.inc;*.admin.inc;

if PLAT_GTK
selection.alpha=90
selection.back=#C0CCCC
find.files=*.php *.inc *.module *.views.inc *.admin.inc *.info *.install

#SCiTE Cursor Config
caret.fore=#FF0000
caret.width=2
caret.line.back=#FFFED8
caret.line.back.alpha=33
caret.period=310


Just Save an you will feel the difference when you open the Drupal's / PHP code file. Please let me know if you need more.