Mostrando entradas con la etiqueta apache. Mostrar todas las entradas
Mostrando entradas con la etiqueta apache. Mostrar todas las entradas

jueves, 25 de agosto de 2011

configurar servidor web apache + php con soporte para mysql en servidor independiente

sudo apt-get install apache2 (sudo apt-get install apache2-mpm-worker libapache2-mod-fcgid)

sudo apt-get install php5

sudo apt-get install libapache2-mod-php5

sudo /etc/init.d/apache2 restart

Note que si apache esta bien instalado usted puede omitir la primera linea. Sus archivos web podrá encontrarlos en /var/www/

donde se debe guardar el archivo info.php con



soporte para mysql

para ver que está disponible para php5
apt-cache search php5

Edit PHP Configuration to Work With MYSQL (Ubuntu Dapper)

In Dapper Drake, "extension=mysql.so" and "extension=mysqli.so" are enabled in the php.ini file out-of-the-box. However, sometimes php is not looking for those files in the right directory. You have then to move your files or modify the php.ini configuration.:

First solution

locate the directory where the extension files are placed:

locate mysql.so

(change mysql.so in mysqli.so if you want to install the mysqli functions)

-then modify the php.ini file to indicate the right place for the extension directory:

$ gksudo "gedit /etc/php4/apache2/php.ini"

or if you are using php5

$ gksudo "gedit /etc/php5/apache2/php.ini"

Look for the 'extension_dir' property, and set it to the directory where you found the mysql(i).so file:

extension_dir= "/usr/lib/php5/20051025/"

Restart apache, and test if your mysql(i) functions are working.

apt-get install php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl

/etc/init.d/apache2 restart

Como parte final, es recomendable editar el archivo /etc/php5/apache2/php.ini y verificar las recomendaciones sobre un servidor de producción y uno de desarrollo ej.

; Default Value: On
; Development Value: On
; Production Value: Off
; http://php.net/display-errors
display_errors = off

jueves, 8 de abril de 2010

Error Warning: move_uploaded_file al subir archivos al servidor localhost+apache+php mediante un formulario

Bueno, el tema es como subir archivos a un servidor, mediante un formulario, sin embargo, luego de hacerlo todo, el servodor me arrojaba lo sigiente aviso:

"Warning: move_uploaded_file(C:/Apache/htdocs/miweb/tmp) [function.move-uploaded-file]: failed to open stream: Permission denied in C:\Apache\htdocs\miweb\formEdit.php on line 49

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\tmp\phpA5B6.tmp' to 'C:/Apache/htdocs/miweb/tmp' in C:\Apache\htdocs\miweb\formEdit.php on line 49"

jejeeje lo peor de todo es que he revisado y en ningun lado aprece nada definitivo para solucionarlo, así que aquí les dejo mi aporte por si les sirve...
antes mi configuración: tengo windows 7, apache, php y mysql y he aquí lo que encontré...

1) no es indispensable pero ayuda, revisar en el php.ini que register_globals = on y no off,
2) sobre los permisos de las carpetas en win.. no son problema.
3) en caso de querer modificar o agregar permisos específicos para carpetas en apache, usar


AllowOverride None
Options None
Order deny,allow
Allow from all


ver mas configuraciones...

aunque este tampoco es el problema.
4) ahora retomo el script original...
< ? $destino = "C:/Apache/htdocs/miweb/tmp";
$origen = $_FILES['imagen']['tmp_name'];
move_uploaded_file( $origen, $destino );
? >

existen 2 problemas, por lo menos en windows, no lo he probado en linux, y es que falta agregar "/" al final de la ruta absoluta $destino = ‘C:/Apache/htdocs/miweb/tmp/’;
y además, falta agregar el nombre al archivo, sin esto simpre apareceran los Warnings pues el script intenta escribir en un archivo sin nombre. La linea pues quedará así:
$name=$_FILES['imagen']['name'];
move_uploaded_file( $origen, $destino.$name );
en total,
< ? $destino = 'C:/Apache/htdocs/miweb/tmp/';
$origen = $_FILES['imagen']['tmp_name'];
$name=$_FILES['imagen']['name'];
move_uploaded_file( $origen, $destino.$name );
? >
... así conservamos el nombre original del archivo... Saludos