- FreeBSD 10.1 amd64
- Apache 24
- PHP v5.6
- MySQL v5.6
1 | root@KotakRusak: # portsnap fetch update |
Install Apache 24
1 | root@KotakRusak: # cd /usr/ports/www/apache24 && make install clean |
Bila terjadi error LDAP support maka yang harus kita lakukan adalah rebuild APR dengan LDAP Support seperti gambar berikut.
![]() | |||||||
Reinstall APR dengan LDAP Support |
Running Apache24 service saat boot
Tambahkan atau running saja command berikut :
1 | echo 'apache24_enable="YES"' >> /etc/rc.conf |
Menjalankan/mematikan/restart Apache server
1 | root@KotakRusak: # service apache24 start|stop|status|restart |
Jika kamu mendapatkan pesan error seperti ini "Could not reliably determine the server's fully qualified domain name, using 127.0.0.1." Set the 'ServerName' directive globally to suppress this message:"
Tambahkan pada file /usr/local/etc/apache24/httpd.conf seperti berikut
Servername localhost
Adapun localhost digantikan dengan server domain name yang bisa didapatkan dengan menggunakan command
1 | root@KotakRusak: # hostname -f |
Install MySQL Server
Instalasi MySQL Server lewat port :
1 | root@KotakRusak:/ # cd /usr/ports/databases/mysql56-server/ && make install clean |
Install MySQL client
Instalasi MySQL client lewat port :
1 | root@KotakRusak:/ # cd /usr/ports/databases/mysql56-client/ && make install clean |
Running MySQL service saat boot
Tambahkan atau running saja command berikut :
1 | echo 'mysql_enable="YES"' >> /etc/rc.conf |
Menjalankan/mematikan/restart MySQL Server
1 | root@KotakRusak: # service mysql-server start|stop|status|restart |
Konfigurasi MySQL server
Setelah berhasil instalasi MySQL adalah konfigurasi password untuk mysql itu sendiri karena default passwordnya adalah kosong.
1 | root@KotakRusak: # mysql -u root |
Jalankan sql query berikut setelah masuk kedalam mysql, ganti host_name menjadi server domain name yang bisa didapatkan melalui command hostname -f :
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('passwordnya');
mysql> SET PASSWORD FOR 'root'@'host_name' = PASSWORD('passwordnya');
mysql> quit
Bye
Setelah berhasil melakukan query maka selanjutnya adalah shutdown mysql server :
1 | root@KotakRusak: # mysqladmin -u root -p shutdown |
Masukkan password yang sudah dibuat melalaui query tadi bila ada prompt untuk memasukkan password.
Menjalankan kembali MySQL server
1 | root@KotakRusak: # service mysql-server start |
1 | root@KotakRusak: # mysql -u root -p |
Masukkan password yang sudah dibuat sebelumnya melalui query.
Untuk lebih lanjut tentang akses user mysql bisa dibaca disini :
https://dev.mysql.com/doc/refman/5.1/en/grant.html
https://dev.mysql.com/doc/refman/5.1/en/adding-users.html
Install PHP
Instalasi melalui port :
1 2 | root@KotakRusak: # cd /usr/ports/lang/php56 root@KotakRusak: # make config |
1 | root@KotakRusak: # make install clean |
Install mod_php untuk Apache
Instalasi melalui port :
1 2 | root@KotakRusak: # cd /usr/ports/www/mod_php56 root@KotakRusak: # make install clean |
Output :
![]() |
Config mod_php |
Install PHP extensions
Agar PHP support untuk komunikasi MySQL atau MySQLi dengan MySQL server maka kita perlu melakukan instalasi php extension yang diperlukan
1 2 | root@KotakRusak: # cd /usr/ports/lang/php56-extensions/ root@KotakRusak: # make config |
![]() |
MySQL dan MySQLi php extension |
Sesuaikan dengan kebutuhan masing-masing tapi karena disini kita menggunakan MySQL sebagai database server maka kita hanya menambahkan pilihan mysql dan mysqli dalam config. Bila sudah selesai konfigurasi maka tahap selanjutnya adalah instalasi extension phpnya.
1 | root@KotakRusak: # make install clean |
Konfigurasi mod_php
Untuk melakukan konfigurasi cukup melakukan command sebagai berikut :
1 | root@KotakRusak: # cp /usr/local/etc/php.ini-development /usr/local/etc/php.ini |
Konfigurasi apachenya
1 | root@KotakRusak: # nano /usr/local/etc/apache24/httpd.conf |
Cari baris ini :
DirectoryIndex index.html
Ganti menjadi seperti ini:
DirectoryIndex index.html index.htm index.phpBuat sebuah file /usr/local/etc/apache24/modules.d/001_mod_php.conf dengan isi sebagai berikut :
<FilesMatch "\.php$">Selanjutnya, restart Apache server
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
1 | service apache24 restart |
Test instalasi PHP dan Apache
Sekarang saatnya kita melakukan testing terhadap php dan apachenya apakah sudah berjalan ataukah tidak. Maka, untuk melakukan testing cukup buat sebuah file di /usr/local/www/apache24/data/test.php
// Isi file test.phpSimpan dan kemudian test melalui browser http://localhost/test.php
<?php
phpinfo();
?>
Maka akan tampil seperti berikut :
![]() |
PHP Info |
Referensi :
- http://www.cyberciti.biz/faq/how-to-install-apache-mysql-php-stack-on-freebsd-unix-server/
Salam
Me a.k.a death voice
0 comments:
Posting Komentar