01.22.2010

PHP 5 + Apache 2 + MySQL 5 on OS X via MacPorts

Filed under: note to self,server @ 14:28
# Displays all files in Finder.  Optional: personal preference.
$ defaults write com.apple.Finder AppleShowAllFiles YES
# Relaunch Finder

# Update MacPorts
$ sudo port selfupdate
$ sudo port -u upgrade outdated

# Install MySQL
$ sudo port install mysql5-server
$ sudo port load mysql5-server
$ sudo -u _mysql mysql_install_db5
$ sudo mysqld_safe5 &
$ sudo /opt/local/lib/mysql5/bin/mysql_secure_installation

# Install Apache, PHP (with PEAR), PHP MySQL bindings
$ sudo port install apache2
$ sudo port install php5 +apache2 +pear
$ sudo port install php5-mysql

# Configure Apache
# The following line may not be necessary
? sudo cp /opt/local/apache2/conf/httpd.conf.sample  /opt/local/apache2/conf/httpd.conf
$ cd /opt/local/apache2/modules
$ sudo /opt/local/apache2/bin/apxs -a -e -n "php5" libphp5.so
$ sudo nano /opt/local/apache2/conf/httpd.conf
# Set DirectoryIndex to:
# DirectoryIndex index.html index.php
#
# Change DocumentRoot to whatever (e.g. /Users/michael/Sites
#
# Change <directory "{old DocumentRoot}"> to <directory "{new DocumentRoot}">
#
# In that <directory "{new DocumentRoot}"> section change to the following.
# Options Indexes FollowSymLinks MultiViews
# AllowOverride All
#
# In <ifmodule mime_module> section, add the following two lines
# AddType application/x-httpd-php .php
# AddType application/x-httpd-php-source .phps
#
$ sudo port load apache2

# Configure PHP
$ sudo cp /opt/local/etc/php5/php.ini-development /opt/local/etc/php5/php.ini
$ sudo nano /opt/local/etc/php5/php.ini
# set mysql.default_socket, mysqli.default_socket and pdo_mysql.default_socket to
# /opt/local/var/run/mysql5/mysqld.sock

# Start Apache
# Make sure System Preferences → Sharing → Web Sharing is turned off. 
$ sudo /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper start
# You may get a window asking if httpd can accept incoming requests.  Approve it.

# Add DB and tables to MySQL for easy WordPress install
$ mysql5 -u root -p
> CREATE DATABASE database_name_here;
> GRANT ALL PRIVILEGES ON database_name_here.* TO "username_here"@"localhost" IDENTIFIED BY "password_here";
> FLUSH PRIVILEGES;
> EXIT

# Install and Configure phpMyAdmin (will need to restart Apache when done)
$ sudo port install phpmyadmin
$ sudo nano /opt/local/apache2/conf/httpd.conf
# Add section
# <Directory "/opt/local/www/phpmyadmin/">
#     Options Indexes MultiViews
#     AllowOverride None
#     Order allow,deny                                                                 
#     Allow from all
# </Directory>
#
# In <IfModule alias_module> section add the following
# Alias /phpMyAdmin "/opt/local/www/phpmyadmin"

$ sudo nano /opt/local/www/phpmyadmin/config.inc.php
# See http://www.phpmyadmin.net/documentation/Documentation.html#config
# Fill in $cfg['blowfish_secret']
# Set $cfg['Servers'][$i]['auth_type'] = 'config';
# Add $cfg['Servers'][$i]['user'] = 'root';
# Add $cfg['Servers'][$i]['password'] = '{root password}';


$ sudo /opt/local/apache2/bin/apachectl {start|restart|graceful|graceful-stop|stop}
$ sudo /opt/local/share/mysql5/mysql/mysql.server {start|stop|restart|reload|force-reload|status}

11 Comments

  1.  
    Daniel Howard 02.14.2010 @ 15:28

    If you’re going to do much dev work, this is a lot easier to pull off on Linux within a Virtual Machine.

    -danny

  2.  
    westi 02.18.2010 @ 13:27

    Some updated needed it seems:

    The +mysqlnd variant is obsolete. Please install the php5-mysql port instead.

    •  
      MDA 02.18.2010 @ 13:49

      Thanks – I wrote up these notes after doing things out of order.

      I edited the post to reflect my guess at what should work :)

  3.  
    Lenin 08.15.2010 @ 10:54

    Great post. Saved my day. I also recommend everyone to try this.

  4.  
    Mike 09.30.2010 @ 09:45

    Working like a charm so far, thanks. The phpmyadmin documentation link is broken. Here’s the new one:
    http://www.phpmyadmin.net/documentation/Documentation.html#config

    •  
      MDA 12.12.2010 @ 19:28

      Thanks! Updated.

  5.  

    [...] PHP 5 + Apache 2 + MySQL 5 on OS X via MacPorts | blogwaffe [...]

  6.  
    崔另其究 11.06.2012 @ 19:14

    (网站打不开请点百度快照}手机号码任意显示|号码任意显示|去电号码任意显示|来电号码任意显示|号码随意显|电话号码任意显示|手机号码随意显|电话号码随意显|
    手机号码任意显示 (可以免费测试一次)
    鹏诚通讯科技有限公司
    24小时客服QQ:13417527

    24小时免费咨询电话:18268787444

    公司网址:http://www.pcwltx.com/
    朋友,想不想让你的手机很有个性? 明明你在深圳,而你跟朋友聊天的时候,你朋友的电话上显示你在广州(上 海/天津/武汉/兰州等)以至香港. 明明你在跟朋友玩,而你打电话给你家人,让家人以为你在外地出差. 明天你不是刘德华,而你总是你用刘德华的电话号在打电话 明明你现在在内地,而你非要在你朋友面前说你在香港. 想不想拥有了?

    专业手机,座机,小灵通等打电话发短信可以任意显示电话号码的, 此产品不需要下载任何软件,只需要绑定您的号码即可实现显示.您要对方显示什么号码!我这里免费给您测试,让您亲眼所见!不想让别人知道自己在哪里的时候,被人追踪讨债不接您电话的时候很有用出的!您只需花上几百元钱就能买到您想要的任何靓号,吉祥号!以及港澳台和国际号码,任意显示您的电话号码,随时隐藏您的号码!
    本业务不会影响你本手机的使用,想使用改号业务时就拨一下我们系统的预约号码,不想使用时就直接用你手机打出还是原来的号,不会改变你手机原来的实际号码,互不干扰.

    为防止各种违法乱纪,本软件特定设置号码规范如下:
    1、出于安全考虑国家特殊号码 110 120 119等号码,不可以随意设置,
    一经发现删除该帐户!
    2、不可以设置各种银行,移动的客服号码(95599 10086等)一经发现删除该帐户!

    交易方式:支持各大银行和淘宝交易.

    1, 无须在电话(手机,小灵通,座机)上下载任何软件
    2, 无月租,无长途漫游费,全国号码任意设置,任意拨打,任意显示。0.2元/分钟
    3, 绑定号码无次数限制,设置显示号码无次数限制。自行操作,自己做主,
    4, 开通后没有时效限制,有话费即可使用。
    5, 话费没了,续费继续使用。
    6, 不影响你本机号码的话费,和正常使用,两者互不干扰。
    7, 双方都为接电话型式,不扣通话双方的电话(手机,小灵通,座机)话费。
    8,不想使用时就直接用你手机打出还是原来的号,不会改变你手机原来的实际号码,互不干扰.
    显示号码自己设置,操作方法可以手机直接操作也可以网页上操作最后都是通过自己的手机打出,
    让对方显示你要的号码,本机是接回拨所以免费,显示号码自由设置
    可以让你亲自测试,自己打出一个任意显示的电话。
    交易方式:支持各大银行和淘宝交易.

    24小时客服QQ:13417527

    24小时免费咨询电话:18268781444

    公司网址:http://www.pcwltx.com/
    骗子各种手法介绍:不允许测试,让你直接汇款,汇款后开通。

  7.  

    results are handsome …

  8.  
    Anonymous 02.06.2013 @ 11:46

    6kv5nfw5w

© mdawaffe (Michael D Adams) - Powered by WordPress - Full Credits