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

Saturday, June 25, 2011

Building PHP 5 on Solaris 10

This is an article I meant to publish a long time ago. I was going through my blog posts, and noticed this entry as a draft from four years ago. I thought it may still be relevant to some folks and decided to publish it. There may be circumstances which require native PHP. This is how I did it using the native version.

Note: Today I would recommend using Quercus on GlassFish 3 instead of using pure PHP.  Please see Quercus PHP 3.2.1 on GlassFish 2.1 as an example of how to implement it.

1. Set the path as follows:

export PATH=/opt/csw/bin:/usr/sfw/bin:/usr/sbin:/usr/bin: \
/usr/openwin/bin:/usr/dt/bin:/usr/ccs/bin


2. Install the following packages from blastwave.org

pkg-get -U
pkg-get -i autoconf
pkg-get -i automake
pkg-get -i gsed
pkg-get -i libxml2


2. Check software revision levels

which autoconf && autoconf --version | head -2
/opt/csw/bin/autoconf
autoconf (GNU Autoconf) 2.59
Written by David J. MacKenzie and Akim Demaille.


which automake && automake --version | head -2
/opt/csw/bin/automake
automake (GNU automake) 1.9.6
Written by Tom Tromey .


which gsed && gsed --version | head -2
/opt/csw/bin/gsed
GNU sed version 4.1.4
Copyright (C) 2003 Free Software Foundation, Inc.


which gcc && gcc --version | head -2
/usr/sfw/bin/gcc
gcc (GCC) 3.4.3 (csl-sol210-3_4-branch+sol_rpath)
Copyright (C) 2004 Free Software Foundation, Inc.


which gmake && gmake --version | head -2
/opt/sfw/bin/gmake
GNU Make 3.80
Copyright (C) 2002 Free Software Foundation, Inc.

which flex && flex --version | head -2
/usr/sfw/bin/flex
flex version 2.5.4

which bison && bison --version | head -2
/usr/sfw/bin/bison
bison (GNU Bison) 1.875
Written by Robert Corbett and Richard Stallman.

#which gm4 && gm4 --version | head -2
/opt/csw/bin/gm4
GNU M4 1.4.5
Written by Rene' Seindal.

which perl && perl -v | head -2
/opt/csw/bin/perl
This is perl, v5.8.8 built for sun4-solaris-thread-multi

which gunzip && gunzip -V | head -2
/usr/bin/gunzip
gunzip 1.3.3-patch.1
(2002-03-08)

which gtar && gtar --version | head -2
/opt/csw/bin/gtar
tar (GNU tar) 1.15.91
Copyright (C) 2006 Free Software Foundation, Inc.


4. Use the following build script

./configure \
--enable-so \
--with-apxs2=/usr/apache2/bin/apxs \
--enable-fastcgi \
--enable-debug \
--with-zlib \
--with-bz2 \
--enable-calendar \
--enable-dba=shared \
--with-flatfile \
--enable-dbase \
--enable-ftp \
--with-openssl \
--with-ldap \
--with-ldap-sasl \
--enable-soap \
--with-oci8=/opt/oracle/app/oracle/product/10.2.0/db_1 \
--with-libxml-dir=/opt/csw \
--enable-mbstring \
--with-mycrpt

5. Run make all

6. Run make install


Enhanced by Zemanta

Friday, August 20, 2010

Why Movable Type, Drupal, or Wordpress on GlassFish?

WordPress





The question of relevance has come up on why would you implement Movable Type, Drupal, or Wordpress on GlassFish. Is it because you can?

The answer is one of technology fundamentals and implementation strategies. I am a Java developer (if you could not figure that out from the blog title). I have access to GlassFish which I use for all of my web based application deployments. I want to be able to simplify my administration requirements by using a unified deployment platform. I also want to be able to combine the extensive libraries and frameworks that are available for Java. I want a simple intuitive administration console to handle most of my day-to-day needs. I want administration, and deployment to be scriptable. GlassFish solves a number of these issues, along with using Java, and Java based implementations of some popular languages like JRuby, and Jython.

First, GlassFish versions 2 and 3 are the reference implementations for Java Enterprise Editions (EE) 5 and 6 respectively. If you are doing enterprise software development, and want to use the latest reference versions, you should use GlassFish. I often write about Java Enterprise Edition (EE). I try to focus on the core technology since this keeps it compatible across other EE containers should you choose to move it to another container. GlassFish version 3 has made a number of positive steps in JEE 6 to make it easier to use. The new profiles in GlassFish make it easier to do web development.

Apache web server is very powerful. There is no question about that, but installing modules, and configuring it is not simple. If a module is not available in one of the pre-configured and installed versions on your system, you must compile it yourself. I am a very competent Apache administrator, and I have never had a simple download, and compile deployment. Let me contrast that with GlassFish, if you have Java 6 installed on your system, download and run it. If you are using JRuby, or Jython, GlassFish can handle it right out  of the box. In the case of JRuby, there have been a number of performance tests to show JRuby on Glassfish is faster that Ruby on WEBrick, or Mongrel. The Common Gateway Interface (CGI) servlet will allow you to take advantage of additional CGI technologies with simple configuration on a server wide basis, or on a per application basis.

Apache Web Server and GlassFish can take advantage of a number of frameworks. Apache Web Server can run Ruby applications with the appropriate module. However, it can not take advantage of other independent frameworks. Java on GlassFish allows Ruby developers to use Java frameworks like Swing within their applications. You can even create polyglot applications which use JRuby, Jython, and Clojure. This may be possible  with Apache Web Server, but I am unaware of it. This is a comment point for readers.

Simple and Intuitive administrative interface. That describes GlassFish administration console to a tee. I would even include elegant, and beautiful.

GlassFish Administration Console

Glassfish includes a very complete command-line interface. Anything you can do on the GUI based interface, you can do from the command-line. It also includes a number of advanced features which are not available in the adminstrative GUI.

Finally, as I noted above it has multiple configuration points with languages and technologies including Microsoft technologies.

I have found that GlassFish handles all of my Web based needs in a single platform. This combination of technology and integration points makes it easy to install relevant best of breed software like Drupal, Movable Type, or Redmine on the same platform and integrate functionality between them as necessary. It is very nice to have Redmine and Hudson CI running on the same platform. Combine it with Mercurial, and share a common SSO. This is not done easily on Apache Web Server, or any other platform.

I hope this clarifies my position on its relevance with Movable Type, Drupal, Wordpress, etc.

Wednesday, February 18, 2009

Drupal on GlassFish using Quercus

I will explain how to get Drupal running on GlassFish in 10 minutes.

Requirements:
Database:
  1. Create the Drupal user in the database.
    GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON drupal.* TO 'drupal'@'localhost' IDENTIFIED BY 'drupal';
    Note: This is not secure and should only be used for demo.

  2. Create a new database in mySQL called drupal.
    create database drupal character set utf8;
Quercus:

Download and extract the quercus-3.2.1.war file.
jar -xvf quercus-3.2.1.war WEB-INF
Drupal:
  1. Download and extract Drupal 6.9
  2. Copy the WEB-INF directory and files from the Quercus into the Drupal directory.
NetBeans:

  1. Create a new project in NetBeans. Choose Java Web and Web Application with Existing Sources.


  2. Fill in the Name and location properties for the project.

    Note: Please make sure that you choose a different folder for the project files. Please see the image below as an example.


  3. Next select the application server, and set the Context Path. I renamed my context to /drupal


  4. Next select the Web Pages folder. This should be the top directory of the Drupal directory you extracted. This is the directory which contains index.php.


  5. Click Finish

  6. Open the project and navigate to the Web Pages folder. Navigate to the sites --> default directory. Right click on the default.settings.php file and copy. Paste the file back into the directory. Right click on the file it should be named something like default.settings_1.php, rename the file to settings.

    Note: NetBeans will append the .php to the end of the file.


  7. Right click on the project and select Properties. This will bring up the project properties. Select the Libraries Category. Here you will see the files that were included from Quercus 3.1.2 which were in the WEB-INF/lib directory.

  8. Click on Add Library and select MySQL JDBC Driver. Click OK.


  9. Finally Run Main Project (F6).


Drupal Configuration:

If you were successful, you should see the Drupal Configuration page.



  1. Select Install Drupal in English (You may choose differently based on your requirements).


  2. Fill in the database with the information we created earlier.

    • Check mysqli
    • Database Name: drupal
    • Database Username : drupal
    • Database Password: drupal


    Click Save and Continue.


  3. That will complete the database installation and bring up the Site Configuration Screen. Fill in the values and click Save and Continue.


  4. Finished. You should get an Installation Complete screen. Click on your new site.

    Note: My installation has an error message because I don't have SMTP configured on my Mac.



Congratulations! You have Drupal 6.9 running on Quercus 3.1.2 on GlassFish 2.1.

Sunday, February 01, 2009

Quercus PHP 3.2.1 on GlassFish 2.1

I am trying to consolidate a number of applications running on various platforms to GlassFish, if possible. So far I have been incredibly successful with Ruby using JRuby. Our project tracking software (bugs/news/wiki/forums/repository browser) are running on Redmine using JRuby.

Based on the success of using Ruby (RoR), I decided to trying moving some PHP applications over to GlassFish.

I read a great blog article by Ludovic Champenois called 100% Java Quercus PHP engine running in GlassFish Java EE 5 Application Server It describes how to use an open source engine called Quercus from Caucho. I tried to follow the directions, but could not get it to work. I imagine because the versions of GlassFish application server and Quercus may have been different. I was not deterred.

I came across a follow-up article by Arun Gupta called PHP in GlassFish using Caucho Quercus. This article was the missing link. The major difference being the placement of the jar files in the domain/domainXX/lib directory.

Here are the application versions I used to get a functional Caucho Quercus PHP implementation running on GlassFish v 2.1

Mac OS X 10.5.6 (Intel x86)

  • GlassFish v 2.1 Build 60e ( 2.1 FCS)
  • Quercus 3.2.1
  • Java(TM) SE Runtime Environment (build 1.6.0_07-b06-146) Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_07-b06-56, mixed mode)

Mac OS X 10.5.6 (PowerPC)

  • GlassFish v 2.1 Build 60e ( 2.1 FCS)
  • Quercus 3.2.1
  • jsr223-api.jar (Project Phobos) Required for Java SE 5.
  • Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b06-284) Java HotSpot(TM) Client VM (build 1.5.0_16-133, mixed mode, sharing)
When I created my projects I used the following web.xml It is based on the example web.xml in the Quercus 3.2.1 war file.

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<session-config>
   <session-timeout>
       30
   </session-timeout>
</session-config>

<description>Caucho Technology's PHP Implementation</description>
<servlet>
   <servlet-name>Quercus Servlet</servlet-name>
   <servlet-class>com.caucho.quercus.servlet.QuercusServlet</servlet-class>
<!-- Specifies the encoding Quercus should use to read in PHP scripts.
    -->
<!--
    <init-param>
      <param-name>script-encoding</param-name>
      <param-value>UTF-8</param-value>
    </init-param>
    -->

<!-- Tells Quercus to use the following JDBC database and to ignore the
         arguments of mysql_connect().
    -->
<!--
    <init-param>
      <param-name>database</param-name>
      <param-value>jdbc/test</param-value>
    </init-param>
    -->

<!--
    <init-param>
      <param-name>ini-file</param-name>
      <param-value>WEB-INF/php.ini</param-value>
    </init-param>
    -->
</servlet>

<servlet-mapping>
   <servlet-name>Quercus Servlet</servlet-name>
   <url-pattern>*.php</url-pattern>
</servlet-mapping>
<welcome-file-list>
   <welcome-file>index.php</welcome-file>
</welcome-file-list>
</web-app>


This arrangement will allow you run a large number of applications including XWiki, and Drupal. Unfortunately for me, it can not run phpLDAPadmin which I needed.

Thursday, May 22, 2008

Using PHP Add-On (Plugin) on Sun Java System Web Server 7.0

Sun has a great product in its Web Server, but the PHP plugin (Web Server 7.0 PHP Add-On 1.0) is almost completely useless. It will do PHP perfectly well, but who simply uses just PHP.

There are a number of extensions that are available for PHP which are available. The plugin is a very vanilla compilation of PHP 5. Sun should have compiled the plugin with most, or all of the available extensions. This would have made the plugin a complete drop-in replacement for using PHP on Apache.

There is hope... The plugin is based on PHP 5.2.0. I have a simple set of instructions on how to use the binary from the PHP archive site for Windows to replace the missing functionality.

  1. Go to PHP Releases page and download the Windows binary.
  2. Unzip the binary files.
  3. Shutdown the Web Server administration site, and any instances.
  4. Go to the plugin directory and zip up the php plugin just in case... My directory is located in C:\Program Files\Sun\WebServer7\plugins.
  5. Copy the extensions directory from the unzipped files to the plugin directory.
  6. Copy the php.exe and php-cgi.exe to the plugin directory
  7. Copy the .dll files from the unzipped files in the root directory to the plugin directory.
  8. From a command line run php -v from the plugin directory. If it is missing any files that it needs, it should report them. Copy the missing files to the directory.
  9. Restart the instances and make sure the logs are clear.
The list below represents the .dll files which I have in my php plugin directory.
  • gds32.dll
  • libeay32.dll
  • libmcrypt.dll
  • libmhash.dll
  • libmysql.dll
  • libswish-e.dll
  • msql.dll
  • ntwdblib.dll
  • php5ts.dll
  • php_bz2.dll
  • php_curl.dll
  • php_dba.dll
  • php_dbase.dll
  • php_exif.dll
  • php_fdf.dll
  • php_gd2.dll
  • php_gettext.dll
  • php_gmp.dll
  • php_ifx.dll
  • php_imap.dll
  • php_interbase.dll
  • php_ldap.dll
  • php_mbstring.dll
  • php_mcrypt.dll
  • php_mhash.dll
  • php_mime_magic.dll
  • php_ming.dll
  • php_msql.dll
  • php_mssql.dll
  • php_mysql.dll
  • php_mysqli.dll
  • php_oci8.dll
  • php_openssl.dll
  • php_pdo.dll
  • php_pdo_firebird.dll
  • php_pdo_mssql.dll
  • php_pdo_mysql.dll
  • php_pdo_oci.dll
  • php_pdo_oci8.dll
  • php_pdo_odbc.dll
  • php_pdo_pgsql.dll
  • php_pdo_sqlite.dll
  • php_pgsql.dll
  • php_pspell.dll
  • php_shmop.dll
  • php_snmp.dll
  • php_soap.dll
  • php_sockets.dll
  • php_sqlite.dll
  • php_sybase_ct.dll
  • php_tidy.dll
  • php_xmlrpc.dll
  • php_xsl.dll
  • php_zip.dll
  • ssleay32.dll

Good luck and let me know how it works for you. I will see about posting an enhancement request to Sun to incorporate all of the extensions on version 2.0 of the add-on.

Popular Posts