Home Backend Development PHP Tutorial 在Mac OS上编译安装Nginx+PHP+MariaDB开发环境的教程_php实例

在Mac OS上编译安装Nginx+PHP+MariaDB开发环境的教程_php实例

Jun 07, 2016 pm 05:09 PM
mac mariadb nginx php

因为甲骨文的尿性。mariadb应该要顶替mysql了。所以抛弃mysql

1,编译nginx
分别下载nginx,openssl,pcre
编译openssl的时候会提示

WARNING! If you wish to build 64-bit library, then you have to
invoke ‘./Configure darwin64-x86_64-cc' *manually*.
Copy after login

如果你不停止编译就会出错。这个问题应该是 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
Copy after login

改成

复制代码 代码如下:

./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.32
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mariadb \
Copy after login
-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
Copy after login
make && make install

/bin/cp support-files/my-small.cnf /usr/local/mariadb/my.conf
cp support-files/mysql.server /usr/local/mariadb/mysqld

# my.cf

Copy after login

复制代码 代码如下:

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;”

Copy after login

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
Copy after login

执行后,可以看到phpize会帮我们生成了对应的configure文件

(5).通过configure来配置,执行下面的命令:

./configure --enable-sockets --with-php-config=/home/saint/Development/php/bin/php-config
 
make
 
make install
Copy after login

注: php-config文件与phpize是同一个目录下的

(6).更改php.ini,增加下面的语句:

复制代码 代码如下:

extension=”/home/saint/Development/php/lib/php/extensions/no-debug-non-zts-20121226/sockets.so”

觉得难看可以将那个日期文件夹删除

(7).重启Nginx

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

7 PHP Functions I Regret I Didn't Know Before 7 PHP Functions I Regret I Didn't Know Before Nov 13, 2024 am 09:42 AM

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

Top 10 PHP CMS Platforms For Developers in 2024 Top 10 PHP CMS Platforms For Developers in 2024 Dec 05, 2024 am 10:29 AM

CMS stands for Content Management System. It is a software application or platform that enables users to create, manage, and modify digital content without requiring advanced technical knowledge. CMS allows users to easily create and organize content

How to Add Elements to the End of an Array in PHP How to Add Elements to the End of an Array in PHP Feb 07, 2025 am 11:17 AM

Arrays are linear data structures used to process data in programming. Sometimes when we are processing arrays we need to add new elements to the existing array. In this article, we will discuss several ways to add elements to the end of an array in PHP, with code examples, output, and time and space complexity analysis for each method. Here are the different ways to add elements to an array: Use square brackets [] In PHP, the way to add elements to the end of an array is to use square brackets []. This syntax only works in cases where we want to add only a single element. The following is the syntax: $array[] = value; Example

PHP and Social Media: Integrate Your Website with the World PHP and Social Media: Integrate Your Website with the World Oct 11, 2024 am 11:54 AM

PHP provides tools to allow websites to easily integrate social media functions: 1. Dynamically generate social media sharing buttons for users to share content; 2. Integrate with the OAuth library to achieve seamless social media login; 3. Use the HTTP library to capture social media Data, obtain user profile, posts and other information.

See all articles