[OpenWRT] Web Server

===== Instalasi PHP5 =====

root@WebServer: opkg update
root@WebServer: opkg install php5
root@WebServer: opkg install php-cgi

===== Konfigurasi uHTTPD =====

-- uncomment pada >> list interpreter        “.php=/usr/bin/php-cgi”

root@WebServer: /etc/config# nano uhttpd
———-potong
#List of extension->interpreter mappings.
#Files with an associated interpreter can
#be called outside of the CGI prefix and do
#not need to be executable.
list interpreter        “.php=/usr/bin/php-cgi”
#       list interpreter        “.cgi=/usr/bin/perl”
———–potong

-- save dan restart uhttpd

root@g-wrt:/etc/init.d# ./uhttpd stop
root@g-wrt:/etc/init.d# ./uhttpd start

===== Test PHP5 ===== 

buat file (misalnya) tes-php.php
isinya:
<?php
phpinfo();
?>

save dan simpan di /www
Buka browser, http://ipaddress-router/tes-php.php

===== Enable MySQL Pada PHP5 =====  

Install php-mod-mysql
opkg update
opkg install php-mod-mysql
Edit file /etc/php.ini pada bagian:
edit/tambahkan “short_open_tag = On” (tanpa tanda petik)
dan uncomment “extension=mysql.so” (tanpa tanda petik) pada bagian ; Dynamic Extensions
————potong
; Language Options
engine = On
;short_open_tag = Off
short_open_tag = On
precision    =  12
y2k_compliance = On
————–potong
;extension=json.so
;extension=ldap.so
;extension=mbstring.so
;extension=mcrypt.so
extension=mysql.so
————–potong
===== PHP Script to Test MySQL ===== 

<?php

$host = "localhost"; 
$user = "user12"; 
$pass = "34klq*"; 

$r = mysql_connect($host, $user, $pass);

if (!$r) {
    echo "Could not connect to server\n";
    trigger_error(mysql_error(), E_USER_ERROR);
} else {
    echo "Connection established\n"; 
}

echo mysql_get_server_info() . "\n"; 

mysql_close();

?>
Share:

No comments:

Post a Comment

Visitor

Popular Posts

Labels

Recent Posts

sponsor

MitraTIK menangani perbaikan Komputer, Printer, Installasi Jaringan, Installasi CCTV dan Pembuatan Aplikasi Berbasis Web. Untuk jasa perbaikan dan installasi panggilan, kami melayani panggilan ke rumah, kantor, dan sekolah anda yang berada di area Banjarbaru, Martapura dan sekitarnya.

Popular Post