<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>DevelopArts &#187; PHP</title>
	<atom:link href="http://www.developarts.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.developarts.com</link>
	<description></description>
	<lastBuildDate>Sun, 25 Jul 2010 04:14:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Cargar una Extensión de PHP Dinámicamente</title>
		<link>http://www.developarts.com/cargar-una-extension-de-php-dinamicamente/</link>
		<comments>http://www.developarts.com/cargar-una-extension-de-php-dinamicamente/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 04:24:24 +0000</pubDate>
		<dc:creator>neXus</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[mssql]]></category>

		<guid isPermaLink="false">http://www.developarts.com/?p=64</guid>
		<description><![CDATA[Complementando un art&#237;culo que escrib&#237; anteriormente (<a href="http://www.developarts.com/2010/02/compilar-extension-mssql-so-para-php-5//">Compilar Extensi&#243;n "mssql.so" para PHP 5</a>)]]></description>
			<content:encoded><![CDATA[<p><img src='http://www.developarts.com/wp-content/plugins/simple-post-thumbnails/timthumb.php?src=/wp-content/thumbnails/64.png&amp;w=150&amp;h=150&amp;zc=1&amp;ft=jpg' alt='post thumbnail' /></p>
<p>Complementando un artículo que escribí anteriormente <a href="http://www.developarts.com/2010/02/compilar-extension-mssql-so-para-php-5/" onclick="return TrackClick('http%3A%2F%2Fwww.developarts.com%2F2010%2F02%2Fcompilar-extension-mssql-so-para-php-5%2F','art%C3%ADculo+anterior')" onclick="return TrackClick('http%3A%2F%2Fwww.developarts.com%2F2010%2F02%2Fcompilar-extension-mssql-so-para-php-5%2F','Compilar+Extensi%C3%B3n+%22mssql.so%22+para+PHP+5')">Compilar Extensión &#8220;mssql.so&#8221; para PHP 5</a>, vamos a ver como se cargan las extensiones de forma dinámica.<span id="more-64"></span></p>
<p>Una vez que compilamos la extensión de PHP podemos realizar dos<br />
acciones:</p>
<ol>
<li>Estáticamente: Incluir la Extensión en el archivo &#8220;php.ini&#8221; para que esta se cargue automáticamente y sea accesible para todos los usuarios que usen el mismo servidor. Este procedimiento esta explicado en el <a href="http://www.developarts.com/2010/02/compilar-extension-mssql-so-para-php-5/" onclick="return TrackClick('http%3A%2F%2Fwww.developarts.com%2F2010%2F02%2Fcompilar-extension-mssql-so-para-php-5%2F','art%C3%ADculo+anterior')" onclick="return TrackClick('http%3A%2F%2Fwww.developarts.com%2F2010%2F02%2Fcompilar-extension-mssql-so-para-php-5%2F','Compilar+Extensi%C3%B3n+%22mssql.so%22+para+PHP+5')">artículo anterior</a>.</li>
<li>Dinámicamente: Incluir la extensión en tiempo de ejecución en nuestra aplicación, esto quiere decir que solo estará accesible para quien esté programando la aplicación y no para los demás usuarios, lo cual es bastante interesante, sobre todo si no queremos que otros usuarios tengan tantas extensiones a su disposición.</li>
</ol>
<p>Para lograr cargar la extensión en tiempo de ejecución solo es necesario que después de haber compilado la extensión, se copia a algún directorio accesible para nuestra aplicación por ejemplo &#8220;extensiones&#8221;.</p>
<p>Ya desde el desarrollo de nuestra aplicación solo es necesario llamar su carga con el siguiente código:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">extension_loaded</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mssql'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$prefix</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>PHP_SHLIB_SUFFIX <span style="color: #339933;">===</span> <span style="color: #0000ff;">'dll'</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">'php_'</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
  <span style="color: #990000;">dl</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;extensiones/&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$prefix</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'mssql.'</span> <span style="color: #339933;">.</span> PHP_SHLIB_SUFFIX<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>La segunda linea revisa si ya se encuentra cargada la extensión, si es negativo pasa a la tercera linea, donde se revisa el sufijo del sistema, esto quiere decir que si esta en Linux, la extensión es &#8220;.so&#8221; y si esta sobre Windows, la extensión es &#8220;.dll&#8221; y además en Windows las exenciones tienen un prefijo &#8220;<code>php_</code>&#8221; por lo que se debe agregar al nombre de la extensión. Por ejemplo:</p>
<p><code><strong>Linux:</strong> mssql.so<br />
<strong>Windows:</strong> php_mssql.dll</code></p>
<p>Ya en la cuarta linea se realiza la carga con la función &#8220;<a href="http://www.php.net/manual/es/function.dl.php" onclick="return TrackClick('http%3A%2F%2Fwww.php.net%2Fmanual%2Fes%2Ffunction.dl.php','dl')" target="_blank"><strong>dl</strong></a>&#8220;, en la cual se debe de ubicar la dirección de la extensión.</p>
<p>Podemos intentar realizar la conexión a la base de datos de la siguiente forma:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$conn</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mssql_connect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;192.168.0.1:1433&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;user&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;pass&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">mssql_select_db</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;tabla&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$conn</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>En la parte del Host,  se puede usar &#8220;IP:1433&#8243; o &#8220;midominio.com:1433&#8243;.</p>
<p>Otra cosa a notar es la separación del puerto, en windows será necesario separarlo por &#8220;coma&#8221; (&#8220;<code>192.168.0.1,1433</code>&#8220;), y si es un PHP en linux será necesario que se separe por &#8220;dos puntos&#8221; (&#8220;<code>192.168.0.1:1433</code>&#8220;).</p>
<p>Para poder conectar correctamente a MS SQL Server dejo algunas recomendaciones que considero pertienetes y que me ayudaron a conectar remotamente.</p>
<ul>
<li>Que SQL Server soporte autenticación por nombre de usuario y contraseña, el cual se puede verificar en &#8220;Propiedades&#8221; del servicio, pestaña &#8220;Seguridad&#8221; y en autenticación debe estar activada &#8220;SQL y Windows&#8221;</li>
<li>Revisar que esté activado el servicio por red, el cual se puede verificar en &#8220;Propiedades&#8221; del servicio, en la pestaña &#8220;General&#8221;, botón &#8220;Configuración de Red&#8221;. En protocolos autorizados debería estar &#8220;TCP/IP&#8221;, con el puerto &#8220;1433&#8243;</li>
<li>Si el Servidor de la DB tiene algun tipo de firewall interno por software, se deberá habilitar que acepte conexiones al puerto 1433</li>
<li>Si existe un ruteador en la red del servidor, se deberá dirigir las conexiones TCP del puerto 1433 desde quien tiene la IP homologada de internet hacia la IP interna del servidor.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.developarts.com/cargar-una-extension-de-php-dinamicamente/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compilar Extensión &#8220;mssql.so&#8221; para PHP 4</title>
		<link>http://www.developarts.com/compilar-extension-mssql-so-para-php-4/</link>
		<comments>http://www.developarts.com/compilar-extension-mssql-so-para-php-4/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 04:06:40 +0000</pubDate>
		<dc:creator>neXus</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[mssql]]></category>

		<guid isPermaLink="false">http://www.developarts.com/?p=47</guid>
		<description><![CDATA[Extendiendo el artículo que escribí anteriormente sobre como <a href="http://www.developarts.com/2010/02/compilar-extension-mssql-so-para-php-5/">Compilar la Extensión "mssql.so" para PHP 5</a>, esta vez trate de hacerlo en un PHP 4 más o menos con el mismo procedimiento, pero ahora en un servidor de producción con <a href="http://www.redhat.com/" target="_blank">RedHat</a> Enterprise 3, donde me encontré varios problemas que no me permitían realizar de forma correcta la compilación.

Debido a lo anterior, documento en este artículo como logré compilar la extensión]]></description>
			<content:encoded><![CDATA[<p><img src='http://www.developarts.com/wp-content/plugins/simple-post-thumbnails/timthumb.php?src=/wp-content/thumbnails/47.png&amp;w=150&amp;h=150&amp;zc=1&amp;ft=jpg' alt='post thumbnail' /></p>
<p>Extendiendo el artículo que escribí anteriormente sobre como <a href="http://www.developarts.com/2010/02/compilar-extension-mssql-so-para-php-5/" onclick="return TrackClick('http%3A%2F%2Fwww.developarts.com%2F2010%2F02%2Fcompilar-extension-mssql-so-para-php-5%2F','Compilar+la+Extensi%C3%B3n+%22mssql.so%22+para+PHP+5')">Compilar la Extensión &#8220;mssql.so&#8221; para PHP 5</a>, esta vez trate de hacerlo en un PHP 4 más o menos con el mismo procedimiento<span id="more-47"></span>, pero ahora en un servidor de producción con <a href="http://www.redhat.com/" onclick="return TrackClick('http%3A%2F%2Fwww.redhat.com%2F','RedHat')" target="_blank">RedHat</a> Enterprise 3, donde me encontré varios problemas que no me permitían realizar de forma correcta la compilación.</p>
<p>Debido a lo anterior, documento en este artículo como logré compilar la extensión.</p>
<p>Después de terminar mi aplicación era necesario ejecutarla ya en un servidor de producción, sin embargo me tope con un RedHat con PHP 4.3.2, donde encontré algunos problemas, los cuales describo a continuación.</p>
<p>Primero me percate que existiera el paquete &#8220;<code>php-dev</code>&#8221; el cual en RedHat se llama &#8220;<code>php-devel</code>&#8220;, el cual no me fue difícil encontrar para la versión en la que quería compilar. Lo siguiente fue descargar el RPM de las fuentes de PHP, que tampoco me dio ningún problema, salvo que la instalación del paquete me lo dejó en: &#8220;<code>/usr/src/redhat/SOURCES/php-4.3.2.tar.bz2</code>&#8220;. Por lo que lo descomprimí con:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> xvfj php-4.3.2.tar.bz2</pre></div></div>

<p>Como estamos tratando con PHP 4 y no con mi cómodo PHP 5 de mi máquina, hay que cambiar algunas cosas en las variables de shell. Hay que recordar que es necesario estar dentro de el directorio de la extensión y ejecutar lo siguiente:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PHP_PREFIX</span>=<span style="color: #ff0000;">&quot;/usr&quot;</span>
<span style="color: #007800;">$PHP_PREFIX</span><span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>phpize</pre></div></div>

<p>Traté de seguir los mismos pasos que describo en mi <a href="http://www.developarts.com/2006/11/compilar-extension-mssqlso-para-php-5" onclick="return TrackClick('http%3A%2F%2Fwww.developarts.com%2F2006%2F11%2Fcompilar-extension-mssqlso-para-php-5','Art%C3%ADculo+anterior')">Artículo anterior</a>, sin embargo mi primer problema salió en el &#8220;<code>configure</code>&#8221; de PHP, donde me arrojó el siguiente error:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Cannot <span style="color: #c20cb9; font-weight: bold;">find</span> FreeTDS <span style="color: #000000; font-weight: bold;">in</span> known installation directories</pre></div></div>

<p>Por lo que se puede deducir de forma lógica que el problema esta en la instalación de FreeTDS. Por alguna causa los paquete precompilados no funcionaban, así que después de varios intentos fallidos me arme de valor y me baje las fuentes para compilarlo yo mismo siguiendo las indicaciones de la página de <a href="http://www.freetds.org" onclick="return TrackClick('http%3A%2F%2Fwww.freetds.org','FreeTDS')" target="_blank">FreeTDS</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">wge http:<span style="color: #000000; font-weight: bold;">//</span>ibiblio.org<span style="color: #000000; font-weight: bold;">/</span>pub<span style="color: #000000; font-weight: bold;">/</span>Linux<span style="color: #000000; font-weight: bold;">/</span>ALPHA<span style="color: #000000; font-weight: bold;">/</span>freetds<span style="color: #000000; font-weight: bold;">/</span>stable<span style="color: #000000; font-weight: bold;">/</span>freetds-stable.tgz
<span style="color: #c20cb9; font-weight: bold;">tar</span> xvfz freetds-stable.tgz
<span style="color: #7a0874; font-weight: bold;">cd</span> freetds-<span style="color: #000000;">0.64</span><span style="color: #000000; font-weight: bold;">/</span>
.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--prefix</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>freetds
<span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p>Después de terminar la compilación e instalación traté de continuar con el &#8220;<code>configure</code>&#8221; de la extensión &#8220;<code>mssql</code>&#8221; sin embargo fue necesario cambiar la línea un poco, ya que es necesario indicarle a la extensión donde esta el FreeTDS para así continuar con el &#8220;<code>make</code>&#8221;</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--with-mssql</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>freetds<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">--with-php-config</span>=<span style="color: #007800;">$PHP_PREFIX</span><span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>php-config
<span style="color: #c20cb9; font-weight: bold;">make</span></pre></div></div>

<p>Para mi mala suerte, el &#8220;make&#8221; me dió las siguientes lineas de<br />
error.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">xt<span style="color: #000000; font-weight: bold;">/</span>standard<span style="color: #000000; font-weight: bold;">/</span>php_standard.h:<span style="color: #000000;">44</span>,
 from <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>redhat<span style="color: #000000; font-weight: bold;">/</span>SOURCES<span style="color: #000000; font-weight: bold;">/</span>php-4.3.2<span style="color: #000000; font-weight: bold;">/</span>ext<span style="color: #000000; font-weight: bold;">/</span>mssql<span style="color: #000000; font-weight: bold;">/</span>php_mssql.c:<span style="color: #000000;">31</span>:
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>openssl<span style="color: #000000; font-weight: bold;">/</span>kssl.h:<span style="color: #000000;">72</span>:<span style="color: #000000;">18</span>: krb5.h: No such <span style="color: #c20cb9; font-weight: bold;">file</span> or directory
In <span style="color: #c20cb9; font-weight: bold;">file</span> included from <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>openssl<span style="color: #000000; font-weight: bold;">/</span>ssl.h:<span style="color: #000000;">179</span>,
 from <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>php<span style="color: #000000; font-weight: bold;">/</span>main<span style="color: #000000; font-weight: bold;">/</span>php_network.h:<span style="color: #000000;">78</span>,
 from <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>php<span style="color: #000000; font-weight: bold;">/</span>ext<span style="color: #000000; font-weight: bold;">/</span>standard<span style="color: #000000; font-weight: bold;">/</span>fsock.h:<span style="color: #000000;">38</span>,
 from <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>php<span style="color: #000000; font-weight: bold;">/</span>ext<span style="color: #000000; font-weight: bold;">/</span>standard<span style="color: #000000; font-weight: bold;">/</span>php_standard.h:<span style="color: #000000;">44</span>,
 from <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>redhat<span style="color: #000000; font-weight: bold;">/</span>SOURCES<span style="color: #000000; font-weight: bold;">/</span>php-4.3.2<span style="color: #000000; font-weight: bold;">/</span>ext<span style="color: #000000; font-weight: bold;">/</span>mssql<span style="color: #000000; font-weight: bold;">/</span>php_mssql.c:<span style="color: #000000;">31</span>:
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>openssl<span style="color: #000000; font-weight: bold;">/</span>kssl.h:<span style="color: #000000;">134</span>: syntax error before <span style="color: #ff0000;">&quot;krb5_enctype&quot;</span>
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>openssl<span style="color: #000000; font-weight: bold;">/</span>kssl.h:<span style="color: #000000;">136</span>: syntax error before <span style="color: #ff0000;">'*'</span> token
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>openssl<span style="color: #000000; font-weight: bold;">/</span>kssl.h:<span style="color: #000000;">137</span>: syntax error before <span style="color: #ff0000;">'}'</span> token
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>openssl<span style="color: #000000; font-weight: bold;">/</span>kssl.h:<span style="color: #000000;">149</span>: syntax error before <span style="color: #ff0000;">&quot;kssl_ctx_setstring&quot;</span>
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>openssl<span style="color: #000000; font-weight: bold;">/</span>kssl.h:<span style="color: #000000;">149</span>: syntax error before <span style="color: #ff0000;">'*'</span> token
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>openssl<span style="color: #000000; font-weight: bold;">/</span>kssl.h:<span style="color: #000000;">150</span>: syntax error before <span style="color: #ff0000;">'*'</span> token
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>openssl<span style="color: #000000; font-weight: bold;">/</span>kssl.h:<span style="color: #000000;">151</span>: syntax error before <span style="color: #ff0000;">'*'</span> token
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>openssl<span style="color: #000000; font-weight: bold;">/</span>kssl.h:<span style="color: #000000;">151</span>: syntax error before <span style="color: #ff0000;">'*'</span> token
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>openssl<span style="color: #000000; font-weight: bold;">/</span>kssl.h:<span style="color: #000000;">152</span>: syntax error before <span style="color: #ff0000;">'*'</span> token
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>openssl<span style="color: #000000; font-weight: bold;">/</span>kssl.h:<span style="color: #000000;">153</span>: syntax error before <span style="color: #ff0000;">&quot;kssl_ctx_setprinc&quot;</span>
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>openssl<span style="color: #000000; font-weight: bold;">/</span>kssl.h:<span style="color: #000000;">153</span>: syntax error before <span style="color: #ff0000;">'*'</span> token
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>openssl<span style="color: #000000; font-weight: bold;">/</span>kssl.h:<span style="color: #000000;">155</span>: syntax error before <span style="color: #ff0000;">&quot;kssl_cget_tkt&quot;</span>
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>openssl<span style="color: #000000; font-weight: bold;">/</span>kssl.h:<span style="color: #000000;">155</span>: syntax error before <span style="color: #ff0000;">'*'</span> token
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>openssl<span style="color: #000000; font-weight: bold;">/</span>kssl.h:<span style="color: #000000;">157</span>: syntax error before <span style="color: #ff0000;">&quot;kssl_sget_tkt&quot;</span>
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>openssl<span style="color: #000000; font-weight: bold;">/</span>kssl.h:<span style="color: #000000;">157</span>: syntax error before <span style="color: #ff0000;">'*'</span> token
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>openssl<span style="color: #000000; font-weight: bold;">/</span>kssl.h:<span style="color: #000000;">159</span>: syntax error before <span style="color: #ff0000;">&quot;kssl_ctx_setkey&quot;</span>
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>openssl<span style="color: #000000; font-weight: bold;">/</span>kssl.h:<span style="color: #000000;">159</span>: syntax error before <span style="color: #ff0000;">'*'</span> token
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>openssl<span style="color: #000000; font-weight: bold;">/</span>kssl.h:<span style="color: #000000;">161</span>: syntax error before <span style="color: #ff0000;">&quot;context&quot;</span>
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>openssl<span style="color: #000000; font-weight: bold;">/</span>kssl.h:<span style="color: #000000;">162</span>: syntax error before <span style="color: #ff0000;">&quot;kssl_build_principal_2&quot;</span>
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>openssl<span style="color: #000000; font-weight: bold;">/</span>kssl.h:<span style="color: #000000;">162</span>: syntax error before <span style="color: #ff0000;">&quot;context&quot;</span>
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>openssl<span style="color: #000000; font-weight: bold;">/</span>kssl.h:<span style="color: #000000;">165</span>: syntax error before <span style="color: #ff0000;">&quot;kssl_validate_times&quot;</span>
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>openssl<span style="color: #000000; font-weight: bold;">/</span>kssl.h:<span style="color: #000000;">165</span>: syntax error before <span style="color: #ff0000;">&quot;atime&quot;</span>
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>openssl<span style="color: #000000; font-weight: bold;">/</span>kssl.h:<span style="color: #000000;">167</span>: syntax error before <span style="color: #ff0000;">&quot;kssl_check_authent&quot;</span>
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>openssl<span style="color: #000000; font-weight: bold;">/</span>kssl.h:<span style="color: #000000;">167</span>: syntax error before <span style="color: #ff0000;">'*'</span> token
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>openssl<span style="color: #000000; font-weight: bold;">/</span>kssl.h:<span style="color: #000000;">169</span>: syntax error before <span style="color: #ff0000;">&quot;enctype&quot;</span>
In <span style="color: #c20cb9; font-weight: bold;">file</span> included from <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>php<span style="color: #000000; font-weight: bold;">/</span>main<span style="color: #000000; font-weight: bold;">/</span>php_network.h:<span style="color: #000000;">78</span>,
 from <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>php<span style="color: #000000; font-weight: bold;">/</span>ext<span style="color: #000000; font-weight: bold;">/</span>standard<span style="color: #000000; font-weight: bold;">/</span>fsock.h:<span style="color: #000000;">38</span>,
 from <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>php<span style="color: #000000; font-weight: bold;">/</span>ext<span style="color: #000000; font-weight: bold;">/</span>standard<span style="color: #000000; font-weight: bold;">/</span>php_standard.h:<span style="color: #000000;">44</span>,
 from <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>redhat<span style="color: #000000; font-weight: bold;">/</span>SOURCES<span style="color: #000000; font-weight: bold;">/</span>php-4.3.2<span style="color: #000000; font-weight: bold;">/</span>ext<span style="color: #000000; font-weight: bold;">/</span>mssql<span style="color: #000000; font-weight: bold;">/</span>php_mssql.c:<span style="color: #000000;">31</span>:
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>openssl<span style="color: #000000; font-weight: bold;">/</span>ssl.h:<span style="color: #000000;">909</span>: syntax error before <span style="color: #ff0000;">&quot;KSSL_CTX&quot;</span>
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>openssl<span style="color: #000000; font-weight: bold;">/</span>ssl.h:<span style="color: #000000;">931</span>: syntax error before <span style="color: #ff0000;">'}'</span> token
<span style="color: #c20cb9; font-weight: bold;">make</span>: <span style="color: #000000; font-weight: bold;">***</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>php_mssql.lo<span style="color: #7a0874; font-weight: bold;">&#93;</span> Error <span style="color: #000000;">1</span></pre></div></div>

<p>Despues de preguntarle a <a href="http://www.google.com.mx/linux" onclick="return TrackClick('http%3A%2F%2Fwww.google.com.mx%2Flinux','Google')" target="_blank">Google</a>, no tardé en encontrar la solución.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">CPPFLAGS</span>=<span style="color: #ff0000;">'-I/usr/kerberos/include/'</span>
.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--with-mssql</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>freetds<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">--with-php-config</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>php-config
<span style="color: #c20cb9; font-weight: bold;">make</span></pre></div></div>

<p>Y listo, eso fue todo, compiló y ejecutó correctamente, aunque eso sí, en el transcurso de la compilación de la extensión &#8220;<code>mssql</code>&#8221; para PHP4 se dijeron muchas maldiciones.</p>
<p>Espero que este artículo sea de ayuda si te esta pasando lo mismo.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.developarts.com/compilar-extension-mssql-so-para-php-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compilar Extensión &#8220;mssql.so&#8221; para PHP 5</title>
		<link>http://www.developarts.com/compilar-extension-mssql-so-para-php-5/</link>
		<comments>http://www.developarts.com/compilar-extension-mssql-so-para-php-5/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 03:27:43 +0000</pubDate>
		<dc:creator>neXus</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[mssql]]></category>

		<guid isPermaLink="false">http://www.developarts.com/?p=33</guid>
		<description><![CDATA[Este artículo detalla la forma en la que se debe compilar la extensión "mssql.so" para PHP versión 5.x, necesaria para lograr conectar a una base de datos Microsoft SQL Server sobre un sistema controlado GNU/Linux Debian Inestable (puede aplicarse a casi cualquier otra distribución ajustando las rutas y paquetes).]]></description>
			<content:encoded><![CDATA[<p><img src='http://www.developarts.com/wp-content/plugins/simple-post-thumbnails/timthumb.php?src=/wp-content/thumbnails/33.png&amp;w=150&amp;h=150&amp;zc=1&amp;ft=jpg' alt='post thumbnail' /></p>
<p>Este artículo detalla la forma en la que se debe compilar la extensión &#8220;mssql.so&#8221; para <a title="PHP" href="http://www.php.net/" onclick="return TrackClick('http%3A%2F%2Fwww.php.net%2F','PHP')" target="_blank">PHP</a> versión 5.x, necesaria para lograr conectar a una base de datos Microsoft SQL Server<span id="more-33"></span> sobre un sistema controlado <a title="Debian" href="http://www.debian.org/" onclick="return TrackClick('http%3A%2F%2Fwww.debian.org%2F','Debian')" target="_blank">GNU/Linux Debian Inestable</a> (puede aplicarse a casi cualquier otra distribución ajustando las rutas y paquetes).</p>
<p>Hace poco me vi en la necesidad de usar bases de datos Microsoft SQL Server para una aplicación PHP. Realizar esta conectividad sobre Windows no representa ningún problema, ya que los binarios de PHP para esta plataforma vienen con la extensión necesaria (&#8220;php_mysql.dll&#8221;) lista para ser usada, sin embargo, en Linux la historia es muy diferente.</p>
<p>Tengo un Debian Sid con PHP5, pero en pero en los repositorios del &#8220;apt&#8221; no se encuentra la extensión de &#8220;mssql.so&#8221; así que puse manos a la obra para compilar la extensión.</p>
<p>A continuación describo los pasos que realice para la compilación, que de seguro puede ser aplicada para otras extensiones de PHP. Espero que sea de ayuda.</p>
<p>Primero deberemos de revisar que nuestro <a href="http://www.debian.org" onclick="return TrackClick('http%3A%2F%2Fwww.debian.org','Debian')" target="_new">Debian</a> tenga las lineas necesarias para el acceso a los repositorios.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#/etc/apt/sources.list</span>
<span style="color: #666666; font-style: italic;"># Debian unstable Primary repository</span>
deb http:<span style="color: #000000; font-weight: bold;">//</span>ftp.debian.org<span style="color: #000000; font-weight: bold;">/</span>debian<span style="color: #000000; font-weight: bold;">/</span> unstable main non-free contrib
deb-src http:<span style="color: #000000; font-weight: bold;">//</span>ftp.debian.org<span style="color: #000000; font-weight: bold;">/</span>debian<span style="color: #000000; font-weight: bold;">/</span> unstable main non-free contrib</pre></div></div>

<p>A continuación debemos bajar tanto el paquete de desarrollo de módulos como las fuentes de PHP5</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> php5-dev
<span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #7a0874; font-weight: bold;">source</span> php5</pre></div></div>

<p>La primera línea descarga e instala un conjunto de archivos, entre los cuales destacan: el binario &#8220;phpize5&#8243;, y el archivo &#8220;php-config5&#8243;, los cuales nos serán de utilidad mas adelante</p>
<p>La última línea descarga tres archivos, en mi caso &#8220;php5_5.1.4.orig.tar.gz&#8221;, &#8220;php5_5.1.4-0.1.diff.gz&#8221; y &#8220;php5_5.1.4-0.1.dsc&#8221;, además que descomprime el primero en un directorio llamado &#8220;php5-5.1.4&#8243; dentro de &#8220;/usr/src/&#8221;.</p>
<p>La intención de todo esto es compilar únicamente la extensión que queremos usar, sin tener que compilar todo el PHP, así que a continuación entramos en el directorio de las fuentes y directamente en la extensión que queremos compilar, para realizar algunas acciones:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>php5-5.1.4<span style="color: #000000; font-weight: bold;">/</span>ext<span style="color: #000000; font-weight: bold;">/</span>mssql<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PHP_PREFIX</span>=<span style="color: #ff0000;">&quot;/usr&quot;</span>
<span style="color: #007800;">$PHP_PREFIX</span><span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>phpize5</pre></div></div>

<p>En la primera línea entramos al directorio de la extensión, en la segunda, exportamos una variable de entorno llamada &#8220;PHP_PREFIX&#8221;, y en la tercera línea, realizamos la configuración de &#8220;phpize5&#8243;, teniendo en cuenta que este archivo se encuentra en &#8220;/usr/bin/phpize5&#8243;, lo cual nos devolverá algo parecido a lo siguiente:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Configuring <span style="color: #000000; font-weight: bold;">for</span>:
PHP Api Version: <span style="color: #000000;">20041225</span>
Zend Module Api No: <span style="color: #000000;">20050922</span>
Zend Extension Api No: <span style="color: #000000;">220051025</span></pre></div></div>

<p>Después debemos realizar la configuración adecuada. Cada extensión tiene sus propias reglas de compilación que podemos verificar con:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--help</span></pre></div></div>

<p>En mi caso pongo lo que use para la compilación de la extensión &#8220;mssql&#8221;</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--with-mssql</span> <span style="color: #660033;">--with-php-config</span>=<span style="color: #007800;">$PHP_PREFIX</span><span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>php-config5
<span style="color: #c20cb9; font-weight: bold;">make</span></pre></div></div>

<p>La extensión se compila y se guarda en un directorio llamado &#8220;modules&#8221;. Con esto, lo único que falta es copiar la extensión al lugar adecuado y cambiarle sus permisos.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>php5-5.1.4<span style="color: #000000; font-weight: bold;">/</span>ext<span style="color: #000000; font-weight: bold;">/</span>mssql<span style="color: #000000; font-weight: bold;">/</span>modules<span style="color: #000000; font-weight: bold;">/</span>mssql.so <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>php5<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">20051025</span><span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #660033;">-x</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>php5<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">20051025</span><span style="color: #000000; font-weight: bold;">/</span>mssql.so</pre></div></div>

<p>Y agregar o descomentar la linea correspondiente en &#8220;/etc/php5/apache2/php.ini&#8221;</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">extension</span>=mssql.so</pre></div></div>

<p>Ya solo es necesario reiniciar apache si es que PHP corre como módulo, para terminar podemos verificar que este funcionando correctamente, creando un archivo, por ejemplo &#8220;info.php&#8221; con el siguiente contenido:</p>
<p>El cual a la hora de ejecutarlo podremos verificar su correcta carga en PHP5.</p>
<p style="text-align: center;"><a href="http://www.developarts.com/wp-content/uploads/2010/02/img_01_php_01.png" onclick="return TrackClick('http%3A%2F%2Fwww.developarts.com%2Fwp-content%2Fuploads%2F2010%2F02%2Fimg_01_php_01.png','PHP+Info')" rel="lightbox[33]"><img class="size-medium wp-image-40 aligncenter" style="border: 0pt none; margin-top: 0px; margin-bottom: 0px;" title="PHP Info" src="http://www.developarts.com/wp-content/uploads/2010/02/img_01_php_01-300x247.png" alt="" width="300" height="247" /></a></p>
<div class="warn">Es importante verificar que tengamos deshabilitada la extensión &#8220;SyBase&#8221; ya que de lo contrario podría interferir con el módulo &#8220;MSSQL&#8221;.</p>
<p>Desinstalar el paquete &#8220;php5-sybase&#8221; es preferible.</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.developarts.com/compilar-extension-mssql-so-para-php-5/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
