[OSX] Lion에서 MacPort를 이용하여 Apache2, Mysql5, PHP5 설치 Computer Tip

1) mysql 설치

1.1) 설치
$ sudo port install mysql5-server

1.2) DB 초기화
$ sudo /opt/local/lib/mysql5/bin/mysql_install_db --user=mysql

1.3) 데몬 초기화를 위한 alias
$ vi ~/.profile
alias mysqlstart='sudo /opt/local/bin/mysqld_safe5 &'
alias mysqlstop='/opt/local/bin/mysqladmin5 -u root -p shutdown'

$ mysqlstart

혹은,
sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist

1.4) 암호설정
$ /opt/local/lib/mysql5/bin/mysqladmin -u root password '****'
$ $ /opt/local/lib/mysql5/bin/mysqladmin -u root -h CMC-MB13.local password '****'

$ sudo vi /opt/local/etc/mysql5/my.cnf


2) apache2 + php5 설치 및 설정

2.1) 설치
$ sudo port install apache2
$ sudo port install php5 +apache2 +mysql5 +pear

2.1) php5 모듈 추가
$ cd /opt/local/apache2/modules
$ sudo /opt/local/apache2/bin/apxs -a -e -n "php5" libphp5.so

2.2) PHP를 사용하기 위한, httpd.conf 에 추가될 내용
========================================================================
$ sudo vi /opt/local/apache2/conf/httpd.conf 

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

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

Include conf/extra/httpd-userdir.conf
========================================================================

2.3) php.ini 설정
$ cd /opt/local/etc/php5
$ sudo cp php.ini-development php.ini
$ sudo vi php.ini
mysql.default_socket = /opt/local/var/run/mysql5/mysqld.sock

2.4) 아파치 서버 설정
$ vi ~/.profile
alias apache2ctl='sudo /opt/local/apache2/bin/apachectl'

$ apache2ctl start

혹은,
sudo launchctl load -w /Library/LaunchDaemons/org.macports.apache2.plist

2.5) php 테스트

$ cd /opt/local/apache2/htdocs
$ sudo vi index.php
<?php
phpinfo();
?>

3) 브라우저로 확인
browsing with Safari "http://localhost/index.php"


덧글

  • 블루쥬앙 2011/11/23 20:25 # 삭제 답글

    안녕하세요
    우선 포스팅 잘 봤습니다.
    다름이 아니라 php 설치시 glib2 설치 과정에서 에러가 나는데 혹시 이유를 알수 있을까 해서요..

    에러 구문
    ================================================
    ---> Building glib2-devel
    Error: Target org.macports.build returned: shell command failed (see log for details)
    Log for glib2-devel is at: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_devel_glib2-devel/glib2-devel/main.log
    Error: Status 1 encountered during processing.
    To report a bug, see <http://guide.macports.org/#project.tickets>
    glib2 만 따로 port install 해도 동일한 에러가 나오구요.. 답변좀 부탁드리겠습니다.
댓글 입력 영역

구글애드텍스트