Tag : macport

Membuat Virtual Host di Mac

Apaan sih virtual Host??

The term Virtual Host refers to the practice of running more than one web site (such as company1.example.com andcompany2.example.com) on a single machine. Virtual hosts can be “IP-based“, meaning that you have a different IP address for every web site, or “name-based“, meaning that you have multiple names running on each IP address. The fact that they are running on the same physical server is not apparent to the end user.

Apache was one of the first servers to support IP-based virtual hosts right out of the box. Versions 1.1 and later of Apache support both IP-based and name-based virtual hosts (vhosts). The latter variant of virtual hosts is sometimes also called host-based or non-IP virtual hosts.

 

sumber

 

Kenapa harus pake Virtual Host??

biar mac kita serasa server beneran. dan kangen aja sama linux.

Langkah 1

Karena saya telah membuat settingan apache yang mungin berbeda dari versi yang ada (disini).

seluruh setting apache milik saya berada di /opt/local/apache2/

sehingga saya memerlukan setting yang berbeda pula. namun untuk versi yang asli atau tetap menggunakan milik mac asli file berada di /private/etc/apache2

atau tutorial bisa dilihat disini

Buat alamat domain yang anda inginkan di

/etc/hosts

Lakukan dengan mengedit file tersebut (dengan file editor kesayangan anda)

{code type=shell}sudo vi /etc/hosts{/code}

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1	localhost
127.0.0.1	dewi.cantik
172.16.168.128	bisma
255.255.255.255	broadcasthost
::1             localhost 
fe80::1%lo0	localhost

dalam contoh diatas saya menambahkan domain dewi.cantik dan nantinya akan dijadikan nama domain.

Langkah 2

Buka dan edit file di

/opt/local/apache2/conf/extra/httpd-vhosts.conf

file tersebut adalah dimana anda melakukan penambahan configurasi pada virtual web anda. dan file itu bersinonim dengan file /etc/apache2/site-available/namaVirtualHost
Lakukan dengan mengedit file tersebut (dengan file editor kesayangan anda)
{code type=shell}sudo vi /opt/local/apache2/conf/extra/httpd-vhosts.conf{/code}

dan saya menambahkan baris dibawah ini pada akhir file, dan untuk yang lain bisa di comment. dan silahkan dimodifikasi sesuai kebutuhan anda
{code}
<VirtualHost  *:80>
DocumentRoot “/Users/rahadianbisma/repo_git”
ServerName dewi.cantik
</VirtualHost>
{/code}

DocumentRoot adalah lokasi dari file applikasi yang akan anda tempatkan
ServerName adalah nama domain disesuaikan dengan yang di /etc/hosts
lalu kita harus mengenable kan vhost yang telah kita buat dengan cara edit file /opt/local/apache2/conf/httpd.conf
{code}sudo vi /opt/local/apache2/conf/httpd.conf{/code}

cari bagian

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

dan hilangkan tanda #

Langkah 3

restart Apache using the command below (type it into Terminal):
sudo apache2ctl restart

tergantung setting anda

install phpmyadmin on mac

Use MacPorts to install the latest version of phpMyAdmin.

sudo port install phpmyadmin

Update Apache’s httpd.conf file to find phpmyadmin. First add the following lines to the end of the file:

# Local access to phpmyadmin installation
Include conf/extra/httpd-phpmyadmin.conf

and then create a file /opt/local/apache2/conf/extra/httpd-phpmyadmin.conf containing this text:

AliasMatch ^/phpmyadmin(?:/)?(/.*)?$ "/opt/local/www/phpmyadmin$1"

<Directory "/opt/local/www/phpmyadmin">
  Options -Indexes
  AllowOverride None
  Order allow,deny
  Allow from all

  LanguagePriority en de es fr ja ko pt-br ru 
  ForceLanguagePriority Prefer Fallback
</Directory>

Restart Apache so that your changes take effect

sudo /opt/local/apache2/bin/apachectl -k restart

Note: Make sure to use the full path as shown here, as apachectl in your PATH refers to the system provided Apache!

Finally, you need to set up the phpMyAdmin configuration to access mySQL. First, set up the config file:

cd /opt/local/www/phpmyadmin/
sudo cp config.sample.inc.php config.inc.php

This will create a file config.inc.php in the phpMyAdmin folder. Edit that file, and locate the lines:

$cfg['Servers'][$i]['auth_type']     = 'config';    // Authentication method (config, http or cookie based)?
$cfg['Servers'][$i]['user']          = 'root';      // MySQL user
$cfg['Servers'][$i]['password']      = '';          // MySQL password (only needed
                                                    // with 'config' auth_type)

Where ‘ ‘ is an empty password; fill it with your MySQL root password. You can either change the ‘auth_type’ from ‘config’ to ‘cookie’ or ‘httpd’, or alternatively provide the password you selected for the root user in the ‘password’ option.

if you have error in php socket try this

Setup the MySQL default socket to use the MacPorts configuration (/opt/local/var/run/mysql5/mysqld.sock)

$ sudo -i
# cd /opt/local/etc/php5
# cp php.ini php.ini.bak
# defSock=`/opt/local/bin/mysql_config5 --socket`
# cat php.ini | sed \
  -e "s#pdo_mysql\.default_socket.*#pdo_mysql\.default_socket=${defSock}#" \
  -e "s#mysql\.default_socket.*#mysql\.default_socket=${defSock}#" \
  -e "s#mysqli\.default_socket.*#mysqli\.default_socket=${defSock}#" > tmp.ini
# grep default_socket tmp.ini  # Check it!
# mv tmp.ini php.ini
# exit # OR rm php.ini.bak && exit

If you installed php5 with the +pear variant you should also:

cd /opt/local/etc/php5
sudo cp pear.conf.sample pear.conf

Restart Apache so that your changes take effect

sudo /opt/local/apache2/bin/apachectl -k restart

Note: Make sure to use the full path as shown here, as apachectl in your PATH refers to the system provided Apache!

Create a file named phpinfo.php that contains the following three lines

<?php
phpinfo();
?>

sumber

 

Install Mysql On macbook with macports

First off we’ll need to install MySQL from Macports. Lets use following command in Terminal to do that:

{code}sudo port install mysql5 mysql5-server{/code}

The installation process can take a while and you’ll see something like that on your Terminal:

Looks like we were lucky and didn’t catch any errors on this one.

Add MySQL as a startup item

If you are like me then you want that MySQL would be always running. For me it’s just easier that way since I’ll use it on daily basis.

{code}sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist{/code}

Done. MySQL now starts every time you start your Mac.

Create initial MySQL databases

MySQL requires that you create the initial databases. On our case the MySQL databases are kept under /opt/local/var/db/mysql5/. If you take a look you’ll notice that this folder is empty.

---> Computing dependencies for mysql5
---> Fetching mysql5
---> Attempting to fetch mysql-5.0.85.tar.gz from http://ftp.plusline.de/mysql/Downloads/MySQL-5.0/
---> Verifying checksum(s) for mysql5
---> Extracting mysql5
---> Applying patches to mysql5
---> Configuring mysql5
---> Building mysql5
---> Staging mysql5 into destroot
---> Installing mysql5 @5.0.85_0+server
---> Activating mysql5 @5.0.85_0+server
---> Cleaning mysql5
---> Computing dependencies for mysql5-server
---> Fetching mysql5-server
---> Verifying checksum(s) for mysql5-server
---> Extracting mysql5-server
---> Configuring mysql5-server
---> Building mysql5-server
---> Staging mysql5-server into destroot
---> Creating launchd control script
###########################################################
# A startup item has been generated that will aid in
# starting mysql5-server with launchd. It is disabled
# by default. Execute the following command to start it,
# and to cause it to launch at startup:
#
# sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist
###########################################################
---> Installing mysql5-server @5.0.85_0
******************************************************
* In order to setup the database, you might want to run
* sudo -u mysql mysql_install_db5
* if this is a new install
******************************************************
---> Activating mysql5-server @5.0.85_0
---> Cleaning mysql5-server

Lets create the default databases by executing this command:

{code}sudo -u mysql mysql_install_db5{/code}

You should see something like that:

 Installing MySQL system tables...
091023 22:11:11 [Warning] Setting lower_case_table_names=2 because file system for /opt/local/var/db/mysql5/ is case insensitive
OK
Filling help tables...
091023 22:11:11 [Warning] Setting lower_case_table_names=2 because file system for /opt/local/var/db/mysql5/ is case insensitive
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/opt/local/lib/mysql5/bin/mysqladmin -u root password 'new-password'
/opt/local/lib/mysql5/bin/mysqladmin -u root -h MacBook-Pro.local password 'new-password'

Alternatively you can run:
/opt/local/lib/mysql5/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /opt/local ; /opt/local/lib/mysql5/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl

Please report any problems with the /opt/local/lib/mysql5/bin/mysqlbug script!

The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com

Start MySQL for the first time

We have the default databases created and it’s time to start MySQL server for the first time.

{code}sudo /opt/local/lib/mysql5/bin/mysqld_safe &{/code}

You’ll get a response like this

Starting mysqld daemon with databases from /opt/local/var/db/mysql5

Once the server has started just press ctrl + c on your keyboard to exit.

Run MySQL from command line easily

I always tend to forget that I need to use mysql5 on command line instead of just typing in mysql.

Fortunately there’s an easy fix for that, just create symlinks for MySQL and MySQLDump

{code}
 sudo ln -s /opt/local/bin/mysql5 /opt/local/bin/mysql
 sudo ln -s /opt/local/bin/mysqldump5 /opt/local/bin/mysqldump
{/code}

Done. Now you can run MySQL with just typing mysql instead of mysql5.

Secure your MySQL server

It’s always a good idea to have password for your system services. To do that on MySQL just type in the following command.

{code}
/opt/local/lib/mysql5/bin/mysqladmin -u root password [your password goes here]
{/code}

That’s it. MySQL should be up and running for you now with no problems.

Tips and tricks

Some tips and tricks that I used to forget myself quite often.

Shut down MySQL server manually

{code}mysqladmin5 -u root -p shutdown{/code}

Remove MySQL from system start up.

{code}sudo launchctl unload -w /Library/LaunchDaemons/com.mysql.mysqld.plist{/code}

If you cant change password

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/opt/local/lib/mysql5/bin/mysqladmin -u root password 'new-password'
/opt/local/lib/mysql5/bin/mysqladmin -u root -h MacBook-Pro.local password 'new-password'Alternatively you can run:
/opt/local/lib/mysql5/bin/mysql_secure_installation

Sumber

 

Postgresql 90 and macport

several day i try to install postgresql on my macbook, i find in google some  tutorial i always fail whet i practice. then I tried to understand what was really needed when the installation process, and finally I managed to install postgrest90-server

okey lets me start.

Prerequisites

This guide assumes the following:

  • OS X Mountain Lion
  • The latest XCode
  • XCode Command Line Tools
  • The latest MacPorts

Installation

Make sure MacPorts is up to date, then install the postgresql90-server port:
{code}$ sudo port -v selfupdate
$ sudo port -v install postgresql90-server{/code}

Setup the Initial Database

Once the server has been installed, you will need to create the initial database:

{code}
$ sudo mkdir -p /opt/local/var/db/postgresql90/defaultdb
$ sudo chown postgres:postgres /opt/local/var/db/postgresql90/defaultdb
$sudo su postgres -c ‘/opt/local/lib/postgresql90/bin/initdb -D /opt/local/var/db/postgresql92/defaultdb’
{/code}

i thins installation was complete but.. lets continue

Starting the Server

Once the initial database has been created, you can start the server.

To run the server manually, execute the following command:

{code}$ sudo su postgres -c ‘/opt/local/lib/postgresql90/bin/postgres -D /opt/local/var/db/postgresql90/defaultdb'{/code}

If you want the server to automatically start at boot time, execute the following command:

{code}$ sudo launchctl load -w /Library/LaunchDaemons/org.macports.postgresql90-server.plist{/code}

Setup your PATH

The executable files for PostgreSQL are in a non-standard location, so you you’ll want to update your PATH to make things easier. Most likely, you’ll want to edit your ~/.bashrc or ~/.zshrc (or similar) profile, though you can set apply the changes for all users system-wide by editing /etc/profile.

Make sure you set the new path before /usr/bin to ensure that you are using the latest versions and not the default apple-supplied tools:
{code}export PATH=/opt/local/lib/postgresql90/bin:$PATH{/code}
You can verify this works by running which psql and you should see/opt/local/lib/postgresql90/bin/psql as the output.

Create a New User

You will be setup with a postgres user by default, but it is good practice to create a different user account.

To make things easy, create a new database user to match your OS X username:
{code}$ createuser –superuser <my username> -U postgres {/code}
You should now be able to create a new database:
{code}$ createdb my_app{/code}
Do please consider setting a password for your newly-created user 😉

reference : https://coderwall.com/p/xezzaa

Install PHP under macport

Lanjutan tutorial apache under macport

untuk selanjutnya kurang lengkap jika apache tanpa php, bagai sayur tanpa garam. jadi sekarang kita install php dengan menggunakan mac port

{code}sudo port instal php5{/code}

kalau sudah.. aktivkan php pada apache

{code}
cd /opt/local/apache2/modules
sudo /opt/local/apache2/bin/apxs -a -e -n “php5” libphp5.so
{/code}

lalu buat file php.ini dengan cara

{code}

sudo cp /opt/local/etc/php5/php.ini-development /opt/local/etc/php5/php.ini

{/code}

 

lalu restart apache2 anda dengan perintah
{code}sudo /opt/local/apache2/bin/apachectl restart{/code}

dan coba buat file phpinfo

tutorial : http://2tbsp.com/content/install_apache_2_and_php_5_macports

Install apache2 under macport

Dokumentasi ini sepertinya akan saya butuhkan suatu saat nanti. entah kapan itu dan semoga dapat membantu saya besok-besok

Pertanyaan : “Kenapa harus pakai Apache2, kenapa ga pake Instan webserver?”
1. Karena saya terbiasa menggunakan linux sehingga sudah sangat lama saya familiar dengan apache dan ada greget untuk mainan terminal. biar mac serasa linux.
2. Kebutuhan framework yang saya gunakan mengharuskan mengcustom beberapa bagian dari webserver yang tidak dapat ditemukan di instan webserver
3. pengen beda.
4. penasaran.

Alat dan Bahan

1. Siapkan Mac anda posisikan dengan upgrade atau OS terbaru (biar mudah cari software pendukung lain)

2.  Macport dapat di unduh disini usahakan yang terbaru

3. XCODE Usahakan juga yang terbaru. saya terkendala lama dengan xcode karena besarnya file yang di download dan kecilnya bandwith mendownload. usahakan juga menggunakan xcode dari penyedia resmi.

4. Componen XCODE >> command line tools

Cara

1. Install XCODE dengan baik dan benar

2. Install Command Line Tools dengan baik dan benar

3. Install Macport dengan baik dan benar

Jreng.. jreng…
sudah tahap ini selesai waktunya install apache2

{code}sudo port install apache2{/code}

tunggu hingga selesai, kalau sudah waktunya config

buka /opt/local/apache2/conf/httpd.conf dengan text editor favorit anda

{code}sudo vi  /opt/local/apache2/conf/httpd.conf{/code}

  • Lalu ubah DocumentRoot bila anda menginginkan document rootnya diganti

dalam hal ini kita terserah mau ubah kemana pun lokasi DocumentRoot
DocumentRoot “/opt/local/apache2/htdocs”
menjadi
DocumentRoot “/Library/WebServer/Documents”

bila anda merubah document root anda juga harus merubah seluruh path yang mengarah ke /opt/local/apache2/htdocs menjadi tujuan document root anda
{code}
<Directory “/opt/local/apache2/htdocs”>
menjadi
<Directory “/Library/WebServer/Documents”>
{/code}

  • Tambahkan index.php pada dir_module:

{code}
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>{/code}lalu tambahkan pada <IfModule mime_module>{code}

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
{/code}

lalu buka comment
{code}Include conf/extra/httpd-userdir.conf{/code}
Simpan dan tutup httpd.conf
buat file baru di document root anda dan simpan.
lalu restart apache2 anda dengan perintah
{code}sudo /opt/local/apache2/bin/apachectl restart{/code}

Agar lebih mudah dalam melakukan start dan stop kita dapat menambahkan profil atau alias pada system kita dengan menambahkan

{code}alias apache2ctl=’sudo /opt/local/apache2/bin/apachectl'{/code}

di file .profile sehingga kita hanya tinggal memanggil dengan apache2ctl start atau apache2ctl stop. bila sudah lakukan reload profile dengan

{code}source ~/.profile{/code}

dan kita juga bisa mengatur agar apache dapat berjalan otomatis ketika system booting dengan

{code}sudo launchctl load -w /Library/LaunchDaemons/org.macports.apache2.plist{/code}

bila sampai saat ini, anda sudah bisa membuka localhost seperti :
apache sukses
berarti anda sudah berhasil..
mari kita lanjutkan ke  installasi php.sampai jumpa link berikutnya

MacPort apaan ya?

mungkin bisa disebut nuebie kurang ajar yang ga ngerti istilah ini. akhirnya bertanya ke yang pintar.

djiebrats : macport apaan sich?

Mbah Google : http://lmgtfy.com/?q=macport+apaan+sih%3F

dan akhirnya baca-baca di sini

jadi kalo sudah pernah pake linux pasti sering pakai sudo apt-get  atau yum dll lha macport ini kaya begonoan nya di mac.

MacPorts, sebelumnya dikenal sebagai DarwinPorts merupakan sebuah manajeman perangkat lunak yang memudahkan instalasi aplikasi pada sistem operasi mac. Umumnya perangkat lunak yang diinstalasikan melalui macport merupakan aplikasi open source. Manajemen perangkat lunak ini memiliki kesamaan tujuan dan fungsi seperti yang terdapat pada keluarga port BSD, apt-get pada Debian dan turunannya, yaitu untuk memudahkan instalasi paket instalasi dengan memenuhi setiap depedensi yang dibutuhkan oleh setiap paket aplikasi yang diinstal secara otomatis. Perintah sederhana yang digunakan untuk menggunakan macports adalah #port install <nama aplikasi>.

MacPort saat ini dihost pada Mac OS Forge, sebuah repository perangkat lunak pihak ketiga yang dibuat dan dikelola oleh perusahaan Apple. Pada Agustus 2011, MacPorts telah mencapai versi 2.0.1 dengan koleksi port sekitar 8300 buah. Kabar baiknya, mirror lokal macports kini tersedia di Indonesia, berita selengkapnya bisa di lihat di sini.

Instalasi MacPorts.

Download dan install macports yang sesuai dengan sistem operasi anda di sini, dengan catatan aplikasi X Code developer tool telah terinstal sebelumnya, bagi pengguna Mac OS X Lion, instalasi X Code dapat dilakukan melalui App Store. Setelah X Code dan MacPorts terinstall, instalasikan komponen command line tool pada X Code dengan membuka menu X Code – preference – Download. Setelah itu buka terminal dan pastikan macports yang terintal merupakan versi terupdate dengan mengetik perintah sudo port -v selfupdate.

dan lagi-lagi saya ngopi dari link yang tadi: