Home > apache, autoposting, freebsd, install, installasi, mysql, php, server > Install apache, php5, and mysql on FreeBSD 7.2 using ports

Install apache, php5, and mysql on FreeBSD 7.2 using ports


Update: 12/09/2009

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:

# cd /usr/ports/www/apache22
# make install clean

to start just type

# /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

# /usr/ports/lang/php5
# make install clean

make sure to build Apache module is checked

add these option on file /usr/local/etc/apache22/httpd.conf

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

Add Index.php to load auto index

<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>

create file php.ini by copy php.ini-dist

# cd /usr/local/etc/
# cp php.ini-dist php.ini

and then restart apache

# /usr/local/sbin/apachectl restart

create file php on /usr/local/www/apache22/data/

<?php phpinfo();?>

save as test.php

now test on your browser http://127.0.0.1/test.php

Install Mysql 5

# cd /usr/ports/databases/mysql51-server
# make install clean

create database

# /usr/local/bin/mysql_install_db

change owner and group as mysql

# chown -R mysql /var/db/mysql/
# chgrp -R mysql /var/db/mysql/

run mysql daemon

/usr/local/bin/mysqld_safe –user=mysql &

change mysql password

/usr/local/bin/mysqladmin -u root password newpass

to automatic msyql enable when boot add /etc/rc.conf:

mysql_enable="YES"

Install php5-mysql module

cd /usr/ports/databases/php5-mysql
make install clean

create file php to check mysql

<?php
$test=mysql_connect("localhost","mysql","");
if(!$test)
{
print "cant connect";
}
else
{
print "connected";
}
?>

save as test-db.php on /usr/local/www/apache22/data/ and go to your browser http://localhost/test-db.php

Reference:

1. install mysql on www.marksanborn.net
2. install apache on www.marksanborn.net
3. faruqafif.student.fkip.uns.ac.id
4. daemonforums.org

Advertisements
  1. opik
    January 3, 2010 at 9:35 am

    saya sudah install apache22 tp port 80 nya tidak kebuka dan apache tidak jalan. bagaimana membuka port 80 agar apache bisa jalan ?
    trimakasih

    • January 3, 2010 at 9:58 am

      bisa kasih detail tidak jalannya gimna ??

      sedikit clue:

      cari path httpd

      whereis httpd
      

      misal output:
      /usr/local/bin/httpd

      jalankan manual httpd:

      /usr/local/bin/httpd &
      

      atau bisa juga

      /usr/local/etc/rc.d/apache22 start
      

      cara terakhir dg catatan:
      1. apache22_enable=”YES” sudah d tmbhkan di rc.conf
      2. system sudah meload /etc/rc.conf

      smg mmbantu 🙂

  2. Dadan
    January 10, 2010 at 6:34 am

    mas, saya udah coba install mysql di freebsd,
    terus pas saya mau ngubah password root nya, setelah saya tekan enter muncul tulisan seperti ini :
    connect to server at ‘localhost’ failed
    error : ‘Access denied for user ‘root@localhost'(using password : NO)’

    itu kira kira kenapa ya mas ? mohon bantuannya

    • January 10, 2010 at 6:01 pm

      bisa jadi password nya salah.. atau passwordnya sudah d set (jika password sudah d set).

      jika dirasa susah untuk mengganti password bisa direset dengan cara lain:

      1. Stop dulu daemon mysql nya
      2. Jalankan dengan perintah:

      /path/daemon/mysqld --skip-grant-tables
      

      3. lalu update passwordnya

      UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
      FLUSH PRIVILEGES;
      

      ngomong2.. itu waktu sampe d langkah nomor berapa ?? mungkin ada langkah yg terlewati ..

      smg membantu 🙂

      • dadan
        January 14, 2010 at 10:45 am

        sip sip mas, sekarang mysql nya udah jalan , makasih ya … 😀

        terus itu mas, saya ini lagi belajar freebsd, sekarang lagi nginstall php 5 tapi yang apache modul nya itu lupa ga di pilih ..

        jadi gimana ya ?

        saya udah nyoba nge de-install php 5 nya tapi pas di install lagi tampilan buat milih modul apache nya ga muncul ..
        maaf mas banyak nanya, newbie soalnya .. makasih 😀

      • January 14, 2010 at 10:05 pm

        wew.. ok sep…
        untuk menghilangkan konfigurasi package port bisa pake make rmconfig ..

  3. wahyu
    May 12, 2010 at 10:44 am

    mas, saya install php5 lewat source, setelah diekstark lalu kan perlu dikonfigurasi..lha pas diconfigurasi ada pesan file xml2-config not found. kan biasanya pas dikonfigurasi sudah otomasis kan…kira2 apanya yang salah ya salah ya mas…

    • May 13, 2010 at 2:23 pm

      mungkin perlu paket php-xml2 atau xml2 dulu … jadi semacam dependencies… klo install dari source anda akan banyak menemui error karena dependencies nya cukup banyak…

      semoga membantu 🙂

  4. hafidh al afif
    July 29, 2010 at 2:58 am

    terimakasih caca agan, sangat membantu, bagian php-mysqlnya.. di tutorial banyak yang missing euy

  5. January 14, 2011 at 11:52 am

    enak yah kalau punya internet kencang , tapi gimana kalau install offlinenya ??

    • January 16, 2011 at 8:49 pm

      bisa unduh dulu paket nya.. terus simpan di cache port source na.. *lupa letak direktorina* .. baru install sperti biasa..

  6. March 21, 2012 at 2:20 am

    Terima kasih buat sharing ilmunya

  7. May 10, 2012 at 9:54 pm

    izin sedot ya..
    makasih udah mau shear.

  1. June 20, 2009 at 10:11 pm
  2. August 21, 2009 at 4:33 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s