揭示:如果不习惯使用vi编辑器,可以将sudo vi替换成系统默认的文本编辑工具,例如sudo vi /etc/hosts替换成sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /etc/hosts1.安装XcodeXcode可以去apple上去下载,默认系统不包含gcc等编译器,安装完Xcode就会有相应的开发编译环境。2.删除默认的PHP如果要删除系统默认安装的Apache与PHP,可以将如下列表的文件删除,这个步骤可以不用执行。/usr/bin/php/usr/bin/php-config/usr/bin/phpize/usr/include/php/usr/lib/php/usr/share/man/man1//usr/share/man/man1//usr/share/man/man1//etc/apache2/usr/libexec/apache23.安装libjpeg, mcrypt,libmcrypt,mhash,autoconf 2.13,cmake安装jpegv8ctar xvzf jpegsrc.d jpeg-8c./configure --prefix=/usrmakesudo make install安装mhashtar zxvf mhash-0.9.9.d mhash-0.9.9.9/./configure --prefix=/usrmakesudo make install安装libmcrypttar zxvf libmcrypt-2.5.d libmcrypt-2.5.8/./configure --prefix=/usr --disable-posix-threads --enable-static如果出现如下错误checking host system type… configure: error: can not guess host type; you must specify one执行如下复制命令,将系统中的文件复制到当前目录下cp /usr/share/libtool/config/config.* .makesudo make install安装mcrypttar zxvf mcrypt-2.6.d mcrypt-2.6.8/./configure --prefix=/usrmakesudo make i
nstallrfc2440.c:26:20: error: malloc.h: No such file ake[1]: *** [rfc2440.o] Error 1make: *** [install-recursive] Error 1如果出现如上错误,修改文件src/rfc2440.c,修改26行#include <malloc.h>修改为:#include <sys/malloc.h>安装autoconf 2.13由于安装php-fpm需要重新创建编译文件,系统默认的autoconf版本过高,导致重建通不过。tar xvzf autoconf-2.d autoconf-2.13./configure --prefix=/usr/local/autoconf213makesudo make install安装cmake由于编译安装mysql 5.5以上版本,需要使用cmake编译工具tar xvzf cmake-2.8.d cmake-2.8.4./configure --prefix=/usr/local/cmakemakesudo make install4.安装mysqlmysql需要下载源代码版本,去mysql网站sql/downloads/mysql/Select Platform选择Source Code下载Generic Linux (Architecture Independent), Compressed TAR Archivetar xvzf mysql.5.5.d mysql.5.5.10CFLAGS="-O3 -fno-omit-frame-pointer"CXXFLAGS="-O3 -fno-omit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti"/usr/local/cmake/bin/cmake . \-DCMAKE_INSTALL_PREFIX=/usr/local/mysql5.5.10 \-DMYSQL_DATADIR=/usr/local/mysql5.5.10/data \-DDEFAULT_CHARSET=utf8 \-DDEFAULT_COLLATION=utf8_general_ci \-DEXTRA_CHARSETS=all \-DMYSQL_UNIX
_ADDR=/usr/local/mysql5.5.10/data/mysql.socket \-DWITH_SSL=system \-DWITH_ZLIB=system \-DWITH_READLINE=1makesudo make install设置配置文件,可以不做,会载入默认设置在类unix操作系统下,配置文件myf搜索顺序为:/etc/myfmysq_install_dir/etc/myf~/.myf为了让系统可以支持多版本的mysql,建议将myf放置在mysq_install_dir下sudo mkdir /usr/local/mysql5.5.10/etcsudo cp support-files/my-mediumf /usr/local/mysql5.5.10/etc/myf修改目录权限cd /usr/local/sudo chgrp -R _mysql mysql5.5.10sudo chmod 775 mysql5.5.10生成 mysql 系统数据库cd mysql5.5.10sudo ./scripts/mysql_install_db --user=_mysql --datadir=/usr/local/mysql5.5.10/datasudo chown -R _mysql data启动mysqlsudo ./bin/mysqld_safe &修改 mysql 的 root 密码./bin/mysqladmin -u root password "123456"将mysql下bin加入环境变量cd ~# 如果不存在文件.profile,创建touch .profile# 编辑文件vi .profile# 加入mysql的bin目录到PATH变量export PATH=$PATH:/usr/local/mysql5.5.10/bin用如下命令不用重启系统就可以激活新的配置. .profile将mysql加入系统启动sudo vi /Library/sqld5.5.10.plist文件内容<?xml version="1.0" enc
oding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "www.apple/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict> <key>Label</key> <string&sqld5.5.10</string> <key>Program</key> <string>/usr/local/mysql5.5.10/bin/mysqld_safe</string> <key>UserName</key> <string>_mysql</string> <key>WorkingDirectory</key> <string>/usr/local/mysql5.5.10</string> <key>KeepAlive</key> <true/> <key>RunAtLoad</key> <true/></dict></plist>通过launchd人工启动和停止MySQL服务装载服务:mysql下载下来是一个文件夹sudo launchctl load /Library/sqld5.5.10.plist卸载服务:sudo launchctl unload /Library/sqld5.5.10.plist在Mac上安装了MySQL 5.5,在php编译支持mysql的时候会出现如下错误。dyld: Library not loaded: libmysqlclient.18.dylib Referenced from: /usr/local/bin/sysbench Reason: image not foundTrace/BPT trap原因是由于libmysqlclient.dylib的id路径是相对路径而不是绝对路径,这应该是MySQL打包的时出的问题。运行如下命令otool -DX /usr/local/mysql5.5.10/lib/libmysqlclient.dylib显示libmysqlclient.18.dylib则表示有问题需要修复正常情况应该是下面这样:otool -DX /usr/local/mysql5.5.10/lib/libmysqlclient.dylib显
示/usr/local/mysql5.5.10/lib/libmysqlclient.18.dylib则表示正常如何修复:sudo install_name_tool -id \/usr/local/mysql5.5.10/lib/libmysqlclient.18.dylib \/usr/local/mysql5.5.10/lib/libmysqlclient.dylib运行完上面的命令时,再用上面的命令otool检查一下。删除MySQL进入源代码文件夹:cd ~/src/mysql-5.5.10卸载:sudo make uninstall卸载MySQL服务:sudo launchctl unload -w /Library/sqld.plist删除sqld5.5.10.plist文件:sudo rm /Library/sqld5.5.10.plist注意,如果你在安装完MySQL后,删除了~/src文件夹和里面的所有文件,想要卸载MySQL时,你需要重新建立src文件夹,下载同样的源代码,解压缩,配置,编译,最后才能使用make uninstall命令卸载MySQL,所以,没有必要删除src文件夹。5.安装php安装PHP 5.2由于php5.2不包含php-fpm,需要通过补丁包tar zxvf php-5.2.ip -cd php-5.2.17-fpm-0.5. | patch -d php-5.2.17 -p1gzip -cd suhosin-patch-5.2.17-0.9. | patch -d php-5.2.17 -p1cd php-5.2.17/export PHP_AUTOCONF=/usr/local/autoconf213/bin/autoconfexport PHP_AUTOHEADER=/usr/local/autoconf213/bin/autoheader./buildconf --force //一定要执
行这一步./configure --prefix=/usr/local/php5.2.17 \--with-config-file-path=/usr/local/php5.2.17/etc \--with-mysql=/usr/local/mysql5.5.10 \--with-pdo-mysql=/usr/local/mysql5.5.10 \--with-mysqli=/usr/local/mysql5.5.10/bin/mysql_config \--with-iconv-dir \--with-freetype-dir=/usr/X11R6 \--with-jpeg-dir \--with-png-dir=/usr/X11R6 \--with-xpm-dir=/usr/X11R6 \--with-zlib \--with-libxml-dir \--enable-xml \--enable-discard-path \--enable-safe-mode \--enable-bcmath \--enable-shmop \--enable-sysvsem \--enable-inline-optimization \--with-curl \--with-curlwrappers \--enable-mbregex \--enable-fastcgi \--enable-fpm \--enable-force-cgi-redirect \--enable-mbstring \--with-mcrypt \--with-gd \--enable-gd-native-ttf \--with-openssl \--with-mhash \--enable-pcntl \--enable-sockets \--with-ldap \--with-ldap-sasl \--with-xmlrpc \--enable-zip \--enable-soap \--enable-ftp \--disable-debug \--disable-ipv6makesudo make installsudo cp php.ini-dist /usr/local/php5.2.17/etc/php.ini设置php配置文件sudo vi /usr/local/php5.2.17/etc/php.inidate.timezone = "Asia/Shanghai"post_max_size = 50Mupload_max_filesize = 50Mmax_execution_time = 300max_input_time = 600修改php-fpm配置文件sudo vi /usr/local/php5.2.17/f设置端口<value name="list
en_address">127.0.0.1:5217</value>设置组和用户Unix user of processes<value name="user">_www</value> Unix group of processes<value name="group">_www</value>提示:--enable-fastcgi 需要在--enable-fpm 的前面,否则,fpm 不能编译上。php-fpm加入系统启动sudo vi /Library/LaunchDaemons/net.php.php5.2.17.fpm.plist<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "www.apple/DTDs/PropertyList-1.0.dtd"><plist version="1.0"> <dict> <key>Label</key> <string>net.php.php5.2.17.fpm</string> <key>ProgramArguments</key> <array> <string>/usr/local/php5.2.17/sbin/php-fpm</string> <string>start</string> </array> <key>RunAtLoad</key> <true/> </dict></plist>Stop:sudo /usr/local/php5.2.17/sbin/php-fpm stopStart:sudo launchctl load /Library/LaunchDaemons/net.php.php5.2.17.fpm.plist安装PHP 5.3php5.3版本已经内置支持php-fpm,所以不需要打补丁tar zxvf php-5.3.d php-5.3.6/./configure --prefix=/usr/local/php5.3.6 \--with-config-file-path=/usr/local/php5.3.6/etc \--with-mysql=/usr/local/mysql5.5.10 \--with-pdo-mysql=/usr/local/mysql5.5.10 \--with-mysqli=/usr/
local/mysql5.5.10/bin/mysql_config \--with-iconv-dir \--with-freetype-dir=/usr/X11R6 \--with-jpeg-dir \--with-png-dir=/usr/X11R6 \--with-xpm-dir=/usr/X11R6 \--with-zlib \--with-libxml-dir \--enable-xml \--enable-discard-path \--enable-safe-mode \--enable-bcmath \--enable-shmop \--enable-sysvsem \--enable-inline-optimization \--with-curl \--with-curlwrappers \--enable-mbregex \--enable-fastcgi \--enable-fpm \--with-fpm-user=_www \--with-fpm-group=_www \--enable-force-cgi-redirect \--enable-mbstring \--with-mcrypt \--with-gd \--enable-gd-native-ttf \--with-openssl \--with-mhash \--enable-pcntl \--enable-sockets \--with-ldap \--with-ldap-sasl \--with-xmlrpc \--enable-zip \--enable-soap \--enable-ftp \--disable-debug \--disable-ipv6makesudo make installsudo cp php.ini-dist /usr/local/php5.3.6/etc/php.ini设置php配置文件sudo vi /usr/local/php5.3.6/etc/php.inidate.timezone = "Asia/Shanghai"post_max_size = 50Mupload_max_filesize = 50Mmax_execution_time = 300max_input_time = 600修改php-fpm配置文件sudp cp /usr/local/php5.3.6/f.default /usr/local/php5.3.6/fsudo vi /usr/local/php5.3.6/fpid = run/php-fpm.pidlisten = 127.0.0.1:5306pm.max_children = 50pm.start_servers = 20pm.mi
n_spare_servers = 5pm.max_spare_servers = 35注意去掉开头的分号注释php-fpm加入系统启动sudo vi /Library/LaunchDaemons/net.php.php5.3.6.fpm.plist<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "www.apple/DTDs/PropertyList-1.0.dtd"><plist version="1.0"> <dict> <key>Label</key> <string>net.php.php5.3.6.fpm</string> <key>Program</key> <string>/usr/local/php5.3.6/sbin/php-fpm</string> <key>RunAtLoad</key> <true/> </dict></plist>停止与重启sudo cp ~/Downloads/Applications/PHP/php-5.3.6/sapi/fpm/init.d.php-fpm /usr/local/php5.3.6/sbin/php-fpm-binsudo /usr/local/php5.3.6/sbin/php-fpm-bin start|stop昨天在Mac上安装了MySQL 5.5,准备用sysbench做个测试时,发现sysbench无法运行。$ sysbench dyld: Library not loaded: libmysqlclient.16.dylib Referenced from: /usr/local/bin/sysbench Reason: image not foundTrace/BPT trap原因是由于libmysqlclient.dylib的id路径是相对路径而不是绝对路径,这应该是MySQL打包的时出的问题。$ otool -DX ./libmysqlclient.dylib libmysqlclient.16.dylib正常情况应该是下面这样:$ otool -DX ./libmysqlclient.dylib /usr/local/mysql/lib/libmysqlclient.16.dylib如何修复:$ sudo install_name_tool -id \/usr/loc
al/mysql/lib/libmysqlclient.16.dylib \/usr/local/mysql/lib/libmysqlclient.dylib6.安装nginx安装nginx需要pcre源码包,所以先解压tar zxvf pcre-8.解压即可,不需要安装tar zxvf nginx-0.8.d nginx-0.8.54./configure --user=www --group=www --prefix=/usr/local/nginx0.8.54 --with-http_stub_status_module --with-http_ssl_module --with-pcre=../pcre-8.12makesudo make install
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论