在Mac OS上編譯安裝Nginx+PHP+MariaDB開發環境的教程,nginxmariadb_PHP教程

來源:互聯網
上載者:User

在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 << EOF [mysqld] basedir = /usr/local/mariadb datadir = /data/mariadb pid-file = /data/mariadb/mariadb.pid character-set-server = utf8 collation-server = utf8_general_ci user = mysql port = 3306 default_storage_engine = InnoDB innodb_file_per_table = 1 server_id = 1 log_bin = mysql-bin binlog_format = mixed expire_logs_days = 7 bind-address = 0.0.0.0 # name-resolve skip-name-resolve skip-host-cache #lower_case_table_names = 1 ft_min_word_len = 1 query_cache_size = 64M query_cache_type = 1 skip-external-locking key_buffer_size = 16M max_allowed_packet = 1M table_open_cache = 64 sort_buffer_size = 512K net_buffer_length = 8K read_buffer_size = 256K read_rnd_buffer_size = 512K myisam_sort_buffer_size = 8M # LOG log_error = /data/mariadb/mariadb-error.log long_query_time = 1 slow_query_log slow_query_log_file = /data/mariadb/mariadb-slow.log # Oher #max_connections = 1000 open_files_limit = 65535 [client] port = 3306 EOF /usr/local/mariadb/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mariadb --datadir=/data/mariadb chown mysql.mysql -R /data/mariadb export PATH=$PATH:/usr/local/mariadb/bin echo 'export PATH=$PATH:/usr/local/mariadb/bin' >> /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的圖片裁剪擴充Tclip
  • Mac系統下使用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 分別下載...

  • 相關文章

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.