设为首页 收藏本站
查看: 983|回复: 0

[经验分享] [转]在mac os lion 里配置mysql与php

[复制链接]
累计签到:6 天
连续签到:1 天
发表于 2015-12-30 14:56:45 | 显示全部楼层 |阅读模式
http://akrabat.com/php/setting-up-php-mysql-on-os-x-10-7-lion/

Setting up PHP & MySQL on OS X 10.7 Lion


  With OS X 10.7, Apple continues to ship PHP 5.3 with PEAR, GD and PDO_MYSQL out of the box. This is how to set it up from a clean install of 10.7.

/usr/local
  Ensure that the following directories exist:

sudo mkdir /usr/local/include
sudo mkdir /usr/local/bin
sudo mkdir /usr/local/lib
sudo mkdir -p /usr/local/man/man1

MySQL


  • Download the 64bit DMG version of MySQL 5.1.x (or 5.5.x) for OS X 10.6 from mysql.com and install the pkg, the startup item and the pref pane.
  • Add /usr/local/mysql/bin to the path: vim ~/.bash_profile and add:
    export PATH=~/bin:/usr/local/bin:/usr/local/mysql/bin:$PATH
    export EDITOR=vim

      at top of file. (Note that we set EDITOR whilst we are here so that svn is happy!)

  • Set up MySQL root password:
    mysqladmin -u root password {new-password}
    mysqladmin -u root -p{new-password} -h localhost password {new-password}
    mysqladmin -u root -p{new-password} reload

      Clear the history file by typing history -c so that {new-password} isn't in plain text on the disk.

  • Now ensure that the mysql.sock file can be found by PHP:

    • Ensure that MySQL is running
    • sudo mkdir /var/mysql
    • sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock


Apache


  • cd /etc/apache2
  • Give write permission the config file to root: sudo chmod u+w httpd.conf
  • sudo vim httpd.conf
  • Find #LoadModule php5_module libexec/apache2/libphp5.so and remove the leading #
  • Find AllowOverride None within the <Directory "/Library/WebServer/Documents">section and change toAllowOverride All so that .htaccess files will work.
  • Change permissions back: sudo chmod u-w httpd.conf
  • Restart Apache by unticking and then ticking again the Web Sharing checkbox in System Preferences -> Sharing
  • Open Finder and navigate to /Library/WebServer/Documents/ using shift+cmd+g
  • Create a new folder called "orig" and place all files currently in the Documents folder into it. (note that it will ask for your password as the Documents folder is only writable by root.
  • Create a new file called info.php with <?php phpinfo(); inside it.
  • Use Safari to navigate to http://localhost/info.php and check that the PHP version is displayed (5.3.6 at the time of writing).

php.ini


  • cd /etc
  • sudo cp php.ini.default php.ini
  • sudo chmod ug+w php.ini
  • sudo chgrp admin php.ini
  • vim php.ini (assuming your user is a member of the admin group) and change settings appropriately. Change:
    error_reporting  =  E_ALL | E_STRICT
    display_errors = On
    html_errors = On
    extension_dir = "/usr/lib/php/extensions/no-debug-non-zts-20090626"
      (I like to see my xdebug errors in bright orange!)
    Also, change all instances of /var/mysql/mysql.sock to /tmp/mysql.sock


Xdebug
  Can't have a PHP development environment without xdebug! Apple appears to agree as Lion ships with it.


  • vim /etc/php.ini
  • Find the line:
    ;zend_extension="/usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so"
    and remove the semicolon at the start
  • If you want to configure your xdebug settings, then scroll to the end of the file and look for the [xdebug] section. I like these settings:
    xdebug.var_display_max_children = 999
    xdebug.var_display_max_data = 99999
    xdebug.var_display_max_depth = 100

      (use with caution…)

  • Restart apache: sudo apachectl restart and check in the phpinfo that xdebug is now loaded.

PEAR
  We need PEAR! For some reason, it's not set up ready to on Lion, but the install phar file is here, so we just need to run it.


  • cd /usr/lib/php
  • sudo php install-pear-nozlib.phar
  • Edit/etc/php.ini and find the line: ;include_path = ".:/php/includes" and change it to:
    include_path = ".:/usr/lib/php/pear"
  • sudo pear channel-update pear.php.net
  • sudo pecl channel-update pecl.php.net
  • sudo pear upgrade-all

PHPUnit and friends
  I assume that everyone needs these…


  • sudo pear channel-discover pear.phpunit.de
  • sudo pear channel-discover components.ez.no
  • sudo pear channel-discover pear.symfony-project.com
  • sudo pear install phpunit/PHPUnit
  • sudo pear install phpunit/phpcpd
  • sudo pear install PHP_CodeSniffer

PECL OAuth
  A couple of projects I work on use the PECL OAuth component:


  • Ensure you have installed Xcode from the Mac App Store
  • Download the latest PCRE source code from http://sourceforge.net/projects/pcre/files/pcre/ and unzip to a folder on your desktop
  • cd ~/Desktop/pcre-8.12
  • ./configure
  • sudo cp pcre.h /usr/include/
  • Remove the pcre folder on your desktop as you don't need it any more
  • sudo pecl install oauth
  • Edit/etc/php.ini add these lines to the end of the file:
    [oauth]
    extension="/usr/lib/php/extensions/no-debug-non-zts-20090626/oauth.so"
  • Restart apache: sudo apachectl restart and check in the phpinfo that OAuth is now loaded.

mcrypt
  This is useful! Follow the installation details by Michale Gracie here: http://michaelgracie.com/2011/07/21/plugging-mcrypt-into-php-on-mac-os-x-lion-10-7/)
  It all works on this machine, anyway :)

Other options
  If you'd rather use a packaged version, then these are two alternatives:


  • PHP 5.3 for OS X as binary package
  • Zend Server CE

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-158511-1-1.html 上篇帖子: Using Notifications(Chapter 14 of Cocoa Programming for Mac OS X) 下篇帖子: win下vm10+mac os 10.9安装遇到问题
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表