PHP Warning: date(): It is not safe to rely on the system’s timezone settings.

On Apache error.log

...PHP Warning:  date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in D:\\port\\Apache24-2.4.9\\htdocs\\index.html on line 34

Use on of this :
1. Edit php.ini, then restart Apache

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = Asia/Jakarta

2. If your php.ini cannot be edit, you can use this function at the beginning of code

date_default_timezone_set('Asia/Jakarta');//or change to whatever timezone you want

3. Edit index.php without edit php.ini

if( ! ini_get('date.timezone') )
{
    date_default_timezone_set('GMT');
}

4. If you can’t modify php.ini, and don’t want to add a date_default_timezone call, then use gmdate()

<? print(gmdate("Y")); ?>
Advertisements

Integrate Tomcat, Apache, Subversion, WebSvn, SSL on Windows

# WI
# 31-MAY-2010
#

================================================================================
INSTALL APACHE TOMCAT 6.0.26
================================================================================
1. install jdk-6u17-javafx-1_2_1-windows-i586.exe
    -> C:\Program Files (x86)\Java\jdk1.6.0_17\
2. add environment variables
JAVA_HOME=C:\Program Files (x86)\Java\jdk1.6.0_17
JRE_HOME =C:\Program Files (x86)\Java\jre6
2. unzip apache-tomcat-6.0.26-windows-x86.zip
    -> G:\Tomcat\
3. edit G:\tomcat\conf\server.xml
    => <Connector port=”8123″ protocol=”HTTP/1.1″
4. edit G:\tomcat\conf\tomcat-users.xml
    => <role rolename=”manager”/>
           <user username=”wi” password=”wi” roles=”manager”/>
5. run G:\tomcat\bin\startup.bat
6. try on browser
    -> http://localhost:8123
you should see,
    >> Apache Tomcat logo,
           Apache Foundation banner,
           page with showing text :
           “If you’re seeing this page via a web browser, it means you’ve setup Tomcat successfully. Congratulations!
================================================================================

================================================================================
INSTALL APACHE HTTP SERVER 2.2.15
================================================================================
1. install httpd-2.2.15-win32-x86-openssl-0.9.8m-r2.msi
    -> G:\Apache\
2. input:
    Network Domain = localhost
    Server Name = localhost
    Administrator’s Email Address = williamxhi@yahoo.com
3. try on browser
    -> http://localhost
you should see,
    >> It works!
================================================================================

================================================================================
INSTALL SUBVERSION 1.6.6
================================================================================
1. install Setup-Subversion-1.6.6.msi
    -> G:\Subversion\
2. try on command prompt
    -> set path=%PATH%;G:\Subversion\bin
        svn help

Initialize the repository
————————-
on command prompt
1. G:
2. G:\>mkdir G:\svnrepos
3. G:\>mkdir G:\svnrepos\repo1
4. svnadmin create G:\svnrepos\repo1
================================================================================

================================================================================
INTEGRATE SUBVERSION – APACHE MODULES
================================================================================
1. copy mod_dav_svn.so & mod_authz_svn.so from G:\Subversion\bin to G:\Apache\modules
2. copy libdb44.dll & intl3_svn.dll from G:\Subversion\bin to G:\Apache\bin
2. edit G:\Apache\conf\httpd.conf, add these lines
    -> # All SVN directives
Include conf/extra/httpd-svn.conf
3. create new file G:\Apache\conf\extra\httpd-svn.conf
4. edit G:\Apache\conf\extra\httpd-svn.conf, add these lines
    -> # Load Subversion Apache Modules mod_dav.so, mod_dav_svn.so & mod_authz_svn.so from Subversion-1.6.6
          LoadModule dav_module modules/mod_dav.so
          LoadModule dav_svn_module modules/mod_dav_svn.so
          LoadModule authz_svn_module modules/mod_authz_svn.so

          # Enable Subversion
          DAV svn
          # Directory containing all repository for this path
          SVNParentPath G:/svnrepos

5. try on browser
    -> http://localhost/svn/repo1/
you should see,
    >> repo1 – Revision 0: /
================================================================================

================================================================================
INSTALL PHP 5.3.2
================================================================================
1. unzip php-5.3.2-Win32-VC9-x86.zip
    -> G:\PHP\
2. on command prompt
G:\PHP>copy G:\PHP\php.ini-development G:\PHP\php.ini /v
3. edit G:\Apache\conf\httpd.conf, add these lines
    -> # For PHP 5 do something like this:
          LoadModule php5_module “G:/PHP/php5apache2_2.dll”

    -> # Find section, add these lines
          AddType application/x-httpd-php .php
          AddType application/x-httpd-php .phtml
          -> # Find section, modify the line so it like this,
          DirectoryIndex index.html index.html.var index.php

    -> # at the end of the file, add these lines to tell Apache the path to php.ini
          PHPIniDir “G:/PHP”
4. create new file, phpinfo.php in the folder G:\Apache\htdocs\
    -> <?php
          phpinfo();
          ?>
5. try on browser
    -> http://localhost/phpinfo.php
you should see text,
    -> PHP Version 5.3.2 and it’s parameter info
================================================================================

================================================================================
INSTALL WEBSVN 2.3.1
================================================================================
1. unzip websvn-2.3.1.zip
    -> G:\WebSVN
2. on command prompt
G:\WebSVN>copy G:\WebSVN\include\distconfig.php G:\WebSVN\include\config.php /v
3. edit G:\WebSVN\include\config.php, add these lines
    -> $config->setSVNCommandPath(‘G:\\Subversion\\bin’);
          $config->parentPath(“G:/svnrepos”);
          $config->addTemplatePath($locwebsvnreal.’/templates/calm/’);
          $config->addTemplatePath($locwebsvnreal.’/templates/BlueGrey/’);
          $config->addTemplatePath($locwebsvnreal.’/templates/Elegant/’);
          $config->setTemplatePath($locwebsvnreal.’/templates/calm/’);
          $config->useTreeIndex(true);
          $config->useFlatView();
          $config->setAlphabeticOrder(true);
          $config->setDefaultLanguage(‘en’);
          $config->addInlineMimeType(‘text/plain’);
          $config->setMinDownloadLevel(2);
          set_time_limit(0);
          $config->expandTabsBy(8);
4. edit G:\Apache\conf\httpd.conf, add these lines
    -> # Find section, add these lines
          Alias /websvn/ “G:/webSVN”

    -> <Directory “G:/WebSVN”>
          AllowOverride None
          Order allow,deny
          Allow from all
          </Directory>

5. try on browser
    -> http://192.168.51.10/websvn/index.php
you should see text,
    -> Subversion Repositories…

Setting Password Authentication
——————————-
1. on command prompt,
    -> G:\mkdir G:\svnrepos\conf
          G:\G:\Apache\bin\htpasswd -c -m           G:\svnrepos\htpasswd harry [enter new password & re-type]
          G:\G:\Apache\bin\htpasswd -m           G:\svnrepos\htpasswd sally [enter new password & re-type]
          G:\G:\Apache\bin\htpasswd -m           G:\svnrepos\htpasswd ross [enter new password & re-type]
          G:\G:\Apache\bin\htpasswd -m           G:\svnrepos\htpasswd rachel [enter new password & re-type]
          G:\G:\Apache\bin\htpasswd -m           G:\svnrepos\htpasswd william [enter new password & re-type]

Enable SSL
———-
1. edit G:\Apache\conf\httpd.conf, find “mod_ssl.so”, uncomment the line
    -> LoadModule ssl_module modules/mod_ssl.so
2.

================================================================================

Access to Tomcat server has not been authorized

For the first time, when I try to deploy a project using Netbeans, i got this message,

 

Deployment error:
Access to Tomcat server has not been authorized. Set the correct username and password with the “manager” role in the Tomcat customizer in the Server Manager.
See the server log for details.
After I googling, the solution,
– edit the content of C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.18\conf\tomcat-users.xml file.
-make sure you have role = manager and user that have manager role, like this
<tomcat-users>
<role rolename=”manager”/>
<role rolename=”standard”/>
<user username=”admin” password=”pwd” roles=”standard,manager”/>
</tomcat-users>
-save the file and restart Tomcat server

 

How to install Ruby On Rails running Xampp on Windows (hello world, Ruby!)

Hohoi…i’m so interested to write a post on my struggles to get my first Ruby on Rails work on Windows.
Thanks to internet which provided so many Guru who want to share their knowledge and skills.
Finally, this was a lot simpler than i had figured.
You may install Apache2 on windows or you may use some Apache2 install packages.
I picked XAMPP beside AppServ, Apache2Triad, WAMP just because i like packages included on it.
So here some step that i use,

1. install Xampp from ApacheFriends (http://www.apachefriends.org/en/index.html),
for a simpler download (http://www.apachefriends.org/download.php?xampp-win32-1.6.6a-installer.exe).
I install Xampp at c:\xampp

2. install Ruby (ruby186-26.exe or new version) from RubyForge ((http://rubyforge.org/projects/rubyinstaller/),
download an easy one-click Ruby installer, a self-contained installer that includes the Ruby language,
dozens of popular extensions, a syntax-highlighting editor and the book “Programming Ruby: The Pragmatic Programmer’s Guide

3. install Rubygem (rubygems-0.9.5.zip or new version) from RubyForge (http://rubyforge.org/projects/rubygems/)
tract it and then run ruby setup.rb

4. install Rails

gem update
gem install rails –include-dependencies

The install could take minutes which will show you like this message,
Bulk updating Gem source index for: http://gems.rubyforge.org

If you encounter an error like this,

Updating installed gems…
ERROR: While executing gem … (Gem::RemoteFetcher::FetchError)
getaddrinfo: no address associated with hostname.(SocketError)

then you must make sure you have internet connection
or may be your are behind a firewall.

When you don’t have internet at home or at office, then you will need
to go to a netcafe and download some files separately from rubyforge gems
(http://rubyforge.vm.bytemark.co.uk/gems/)

The following files need to download,
a. actionmailer
b. actionpack
c. actionwebservice
d. activerecord
e. activesupport
f. rails

Next, install it one by one,
gem install activesupport
gem install activerecord
gem install actionwebservice
gem install actionpack
gem install actionmailer
gem install rails

5. create a rails application
i create it at C:\xampp\htdocs\FirstProject, so run
rails -d mysql C:/xampp/htdocs/FirstProject

6. open C:\xampp\apache\config\httpd.conf file in a text editor,
scroll to the bottom and add the following,

#################################
Listen 3000
LoadModule rewrite_module modules/mod_rewrite.so

ServerName rails
DocumentRoot “c:/xampp/htdocs/FirstProject/public”
<Directory "c:/xampp/htdocs/FirstProject/public/"

Options ExecCGI FollowSymLinks
AllowOverride all
Allow from all
Order allow,deny
AddHandler cgi-script .cgi
AddHandler fastcgi-script .fcgi

#################################

7. start server with run this command,
cd c:/xampp/htdocs/FirstProject
ruby script\server

8. run the following at the command-line to keep from getting an “Unknown database” error,
rake db:create

10. make sure your connection to mysql can connect with right user and password,
set C:\xampp\htdocs\FirstProject\config\database.yml

11. to use Rails without a database, open C:\xampp\htdocs\FirstProject\config\environment.rb,
find the commented out line that reads,
# config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
remove the comment and you must remove the Active Record framework

Rails is a MVC (Model View Controller) framework, so all the output will happen in the controllers and views.

12. generate a controller named “hello” with an action “index”
ruby generate controller hello index

If you browsing to http://localhost:3000/hello, you will get
Hello#index
Find me in app/views/hello/index.html.erb

That message occurs because an action after “hello” doesn’t specified,
rails then search the “index” action and a view for this action doesn’t created too.

13. open the controller file at C:\xampp\htdocs\FirstProject\app\controllers\hello_controller.rb

Any public methods in a controller become actions in Rails. Notice the index action.
Add the following method just before end of file,

def world
@greeting = “hello world!”
end

The “@” sign lets views access the variable.

12. When browse to http://localhost:300/hello/world,
we have error like this,
Template is missing
Missing template hello/world.html.erb in view path C:/xampp/htdocs/FirstProject/app/views

13. “Template” is Rails word for the “View”. So Rails expecting the template at the path listed. Create or edit C:\xampp\htdocs\FirstProject\app\views\hello\world.rhtml, add the following text,

Try again, browse http://localhost:3000/hello/world and voila, “hello world, Ruby!”

Happy Rails developing and if you have any other learning resources that you’d like to share, please leave them in the comments!

OCI.dll could not be loaded in PHP-Apache

I’ve installed XAMP 1.6.6a  and running of apache 2.2.8 and PHP 5.2.5 versions. I also install oracle instant client 10.2.0.1.0 so i want to connect to oracle via php using oci.  I got this message when i start apache

Apache.exe
This application has failed to start because oci.dll was not found. Re-installing the application may fix this problem.

I had try to set these variable

ORACLE_HOME, ORACLE_SID, NLS_LANG

and uncomment the following lines in php.ini file

;extension=php_oracle.dll
;extension=php_oci8.dll;
also
;extension=php_pdo_oci.dll
;extension=php_pdo_oci8.dll

but error message would not dissapear

Then I copy oci.dll to folder apache\bin and restart apache, it works fine now. But make sure your oci.dll from Oracle 10, older version will not work.

You can test it using php.exe -m, if you can’t find any error or warning and you see oci8 in list then congratulations!! you succeed to setup oracle extension.

If another error message, such as

The procedure entry point OCIStmtPrepare2 could not be located in the dynamic link library OCI.dll,

then copy oci.dll to php directory and restart apache and test again