在mac os上编译安装nginx+php+mariadb开发环境的教程,nginxmariadb因为甲骨文的尿性。mariadb应该要顶替mysql了。所以抛弃mysql
1,编译nginx
分别下载nginx,openssl,pcre
编译openssl的时候会提示
warning! if you wish to build 64-bit library, then you have toinvoke ‘./configure darwin64-x86_64-cc' *manually*.
如果你不停止编译就会出错。这个问题应该是 openssl/config脚本猜对你的系统是64位,但是 会根据$kernel_bits来判断是否开启x86_64编译,默认 是不开启的(很奇怪的设置,虽然会给你5秒时间停止编译并手动开启),所以你生成的openssl库文件是32位的,最后静态链接到nginx会出错。目前看来没有很好的方法把x86_64的参数传到openssl配置文件中 (openssl/config 猜测os架构,设置编译的参数是32位还是64位,默认是32位,然后调用openssl/configure生成makefile)
可以在configure之前export kernel_bits=64,如果还是不起作用
就要手到修改了
进入nginx目录
复制代码 代码如下:
$ ./configure ./configure –prefix=/usr/locale/nginx –with-openssl=../openssl-1.0.1i –with-pcre=../pcre-8.33
手动修改 objs/makefile:
./config –prefix=/users/xxx/downloads/openssl-1.0.1e/.openssl no-shared no-threads
改成
复制代码 代码如下:
./configure darwin64-x86_64-cc –prefix=/users/xxx/downloads/openssl-1.0.1e/.openssl no-shared no-threads
再make
2,编译php
下载php源码和一些类库
zlib:http://www.zlib.net/
gd库:https://bitbucket.org/libgd/gd-libgd/downloads/libgd-2.1.0.tar.gz 不好下
freetype:http://sourceforge.net/projects/freetype/
libpng:http://www.libpng.org/pub/png/libpng.html
libjpeg:http://www.ijg.org/
curl: http://curl.haxx.se/download.html
mhash: http://sourceforge.net/projects/mhash/
mcrypt: http://mcrypt.hellug.gr/
还有bzip2。 gettext 和libtool 在gnu官网,不过速度不行,其他的库我用了系统自带。懒得再折腾,到时候没啥补啥。
除了libtool直接扔在了/usr,其他我都装在了/usr/local的一个个单独目录里面。比如jpeg就是/usr/local/jpeg方便以后修改
复制代码 代码如下:
./configure –prefix=/users/saint/bin/php –enable-inline-optimization –enable-fpm –with-mcrypt=/usr/local/libmcrypt –with-zlib –enable-mbstring –with-openssl –with-mysql –with-mysqli –with-mysql-sock –with-gd –with-jpeg-dir=/usr/local/jpeg –enable-gd-native-ttf –enable-pdo –with-gettext –with-curl –with-pdo-mysql –enable-sockets –enable-bcmath –enable-xml –with-bz2=/usr –enable-zip –enable-freetype –with-png-dir=/usr/local/libpng –with-pcre-regex –with-iconv-dir=/usr –with-gettext=/usr/local/gettext
3.编译mariadb
编译mariabd需要先安装cmake。去www.cmake.org下载安装tar zxf mariadb-5.5.32.tar.gz
cd mariadb-5.5.32cmake . -dcmake_install_prefix=/usr/local/mariadb \
-dmysql_unix_addr=/tmp/mysql.sock \-dmysql_datadir=/data/mariadb \-dsysconfdir=/usr/local/mariadb \-dmysql_user=mysql \-dmysql_tcp_port=3306 \-dwith_xtradb_storage_engine=1 \-dwith_innobase_storage_engine=1 \-dwith_partition_storage_engine=1 \-dwith_blackhole_storage_engine=1 \-dwith_myisam_storage_engine=1 \-dwith_readline=1 \-denabled_local_infile=1 \-dwith_extra_charsets=1 \-ddefault_charset=utf8 \-ddefault_collation=utf8_general_ci \-dextra_charsets=all \-dwith_big_tables=1 \-dwith_debug=0
make && make install/bin/cp support-files/my-small.cnf /usr/local/mariadb/my.confcp support-files/mysql.server /usr/local/mariadb/mysqld# my.cf
复制代码 代码如下:
cat > /etc/my.cnf /etc/profile
source /etc/profile
/usr/local/mariadb/bin/mysql -e “grant all privileges on *.* to root@'127.0.0.1′ identified by “dbrootpwd” with grant option;”/usr/local/mariadb/bin/mysql -e “grant all privileges on *.* to root@'localhost' identified by “dbrootpwd” with grant option;”/usr/local/mariadb/bin/mysql -uroot -pdbrootpwd -e “delete from mysql.user where password=”;”/usr/local/mariadb/bin/mysql -uroot -pdbrootpwd -e “delete from mysql.db where user=”;”/usr/local/mariadb/bin/mysql -uroot -pdbrootpwd -e “drop database test;”
4.后续安装扩展
php提供了一个phpize工具供我们安装需要的扩展。
下面介绍phpize的使用:
(1).找到自己原来编译的php安装目录,例如我的目录是/home/saint/development/php,在该目录下,找到bin/phpize。如果没有这个工具,则说明没有安装该工具,那么需要安装php.dev,一般都会有这个工具。
(2).要扩展的话,就需要有一个和当前已安装的php的版本一样的php的源包,当前php版本可以用过phpinfo()查看。
(3).打开源包目录,进入到ext目录,例如我就进入到:/home/saint/development/php-5.5.6/ext下,ext下有各个php带有的扩展模块,进入到ext/sockets中。
(4).cd到ext/sockets后,运行phpize程序:
/home/saint/development/php/bin/phpize
执行后,可以看到phpize会帮我们生成了对应的configure文件
(5).通过configure来配置,执行下面的命令:
./configure --enable-sockets --with-php-config=/home/saint/development/php/bin/php-config make make install
注: php-config文件与phpize是同一个目录下的
(6).更改php.ini,增加下面的语句:
复制代码 代码如下:
extension=”/home/saint/development/php/lib/php/extensions/no-debug-non-zts-20121226/sockets.so”
觉得难看可以将那个日期文件夹删除
(7).重启nginx
您可能感兴趣的文章:在mac os的php环境下安装配置memcache的全过程解析在mac os上搭建php的yii框架及相关测试环境全新mac配置php开发环境教程mac os上搭建apache+php+mysql开发环境的详细教程在mac os上自行编译安装apache服务器和php解释器在mac os上搭建nginx+php+mysql开发环境的教程在mac下如何安装phpredis扩展php中使用memache作为进程锁的操作类分享macos 安装 php的图片裁剪扩展tclipmac系统下使用brew搭建php(lnmp/lamp)开发环境mac os下配置php+mysql环境
http://www.bkjia.com/phpjc/1102459.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/1102459.htmltecharticle在mac os上编译安装nginx+php+mariadb开发环境的教程,nginxmariadb 因为甲骨文的尿性。mariadb应该要顶替mysql了。所以抛弃mysql 1,编译nginx 分别下载...