Sabtu, 31 Maret 2012

Cara Install apache, php5, and mysql on FreeBSD

Apache web server one of the most widely used. Apache can also be installed on freebsd. following way to install apache, PHP5, mysql the most easy to use ports.

1. Install Apache:
1# cd /usr/ports/www/apache22
2# make install clean
to start just type
1# /usr/local/sbin/apachectl start
to enable apache on boot add apache22_enable=”YES” following file /etc/rc.conf
check apache on your browser type localhost
2. Install PHP 5
1# /usr/ports/lang/php5
2# make install clean
make sure to build Apache module is checked
add these option on file /usr/local/etc/apache22/httpd.conf
1AddType application/x-httpd-php .php
2AddType application/x-httpd-php-source .phps
Add Index.php to load auto index
1
2    DirectoryIndex index.html index.php
3</IfModule>
create file php.ini by copy php.ini-dist
1# cd /usr/local/etc/
2# cp php.ini-dist php.ini
and then restart apache
1# /usr/local/sbin/apachectl restart
create file php on /usr/local/www/apache22/data/
save as test.php
now test on your browser http://127.0.0.1/test.php
Install Mysql 5
1# cd /usr/ports/databases/mysql51-server
2# make install clean
create database
1# /usr/local/bin/mysql_install_db
change owner and group as mysql
1# chown -R mysql /var/db/mysql/
2# chgrp -R mysql /var/db/mysql/
run mysql daemon
1/usr/local/bin/mysqld_safe –user=mysql &
change mysql password
1/usr/local/bin/mysqladmin -u root password newpass
to automatic msyql enable when boot add /etc/rc.conf:
1mysql_enable="YES"
Install php5-mysql module
1cd /usr/ports/databases/php5-mysql
2make install clean
create file php to check mysql
01
02$test=mysql_connect("localhost","mysql","");
03if(!$test)
04{
05print "cant connect";
06}
07else
08{
09print "connected";
10}
11?>
save as test-db.php on /usr/local/www/apache22/data/ and go to your browser http://localhost/test-db.php

Tidak ada komentar:

Posting Komentar