Tutorial _ PHP instance for compiling and installing Nginx + php + MariaDB Development Environment on MacOS

Source: Internet
Author: User
Tags mcrypt openssl library
This article describes how to compile and install the Nginx + PHP + MariaDB Development Environment on MacOS, including using phpize to install PHP extensions. For more information, see Oracle's urine. Mariadb should replace mysql. So discard mysql

1. Compile nginx
Download nginx, openssl, and pcre
When compiling openssl, a prompt is displayed.

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

An error occurs if you do not stop compilation. This problem should be caused by the openssl/config script guessing that your system is 64-bit, but it will judge whether to enable x86_64 compilation based on $ KERNEL_BITS, Which is disabled by default (very strange setting, although it will give you 5 seconds to stop compilation and manually enable it), the openssl library file you generated is 32-bit, and the static link to nginx will fail. At present, it seems that there is no good way to upload the x86_64 parameter to the openssl configuration file (openssl/config guesses the OS architecture and sets whether the compiled parameter is 32-bit or 64-bit. The default value is 32-bit, then call openssl/Configure to generate Makefile)

It can be export KERNEL_BITS = 64 before configure, if it still does not work
You have to modify it.
Enter the nginx directory

The Code is as follows:


$./Configure./configure-prefix =/usr/locale/nginx-with-openssl = ../openssl-1.0.1i-with-pcre = ../pcre-8.33

Manually modify objs/Makefile:

./config –prefix=/Users/xxx/Downloads/openssl-1.0.1e/.openssl no-shared no-threads

Change

The Code is as follows:


../Configure darwin64-x86_64-cc-prefix =/Users/xxx/Downloads/openssl-1.0.1e/. openssl no-shared no-threads

Make again
2. Compile php
Download php source code and some class libraries
Zlib: http://www.zlib.net/
GD Database: Poor 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: The http://www.ijg.org/

Curl: http://curl.haxx.se/download.html

Mhash: http://sourceforge.net/projects/mhash/
Mcrypt: http://mcrypt.hellug.gr/
And bzip2. Gettext and libtool are available on the gnu official website, but the speed is not good. I use the built-in system for other libraries. Don't bother to make up for it.
Besides libtool, it is directly thrown into/usr, And I have installed it in separate directories of/usr/local. For example, jpeg is/usr/local/jpeg for later modification.

The Code is as follows:

. /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. Compile mariadb

To compile mariabd, install cmake first. Download and install tar zxf mariadb-5.5.32.tar.gz at www.cmake.org

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

The Code is as follows:

Cat>/etc/my. cnf <EOF [mysqld] basedir =/usr/local/mariadb datadir =/data/mariadb pid-file =/data/mariadb. pid character-set-server = utf8 collation-server = Login user = mysql port = 3306 default_storage_engine = InnoDB login = 1 server_id = 1 log_bin = mysql-bin binlog_format = mixed expire_logs_days = 7 bind -address = 0.0.0.0 # name-resolve skip-host-cache # protocol = 1 Protocol = 1 query_cache_size = 64 M query_cache_type = 1 skip-external-locking key_buffer_size = 16 M bytes = 1 M table_open_cache = 64 sort_buffer_size = 512 K net_buffer_length = 8 K read_buffer_size = 256 K Bytes = 512 K Bytes = 8 M # LOG log_error =/data/mariadb/mariadb-error.log long_query_time = 1 slow_query_log records =/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. Subsequent installation and extension
Php provides a phpize tool for us to install the required extensions.

The following describes how to use phpize:

(1) Find your original php installation directory. For example, if my directory is/home/saint/Development/php, find bin/phpize. If you do not have this tool, it indicates that the tool is not installed. You need to install php. dev, which is usually available.

(2) If you want to scale it out, you need a php source package that is the same as that of the currently installed php version. You can use phpinfo () to view the current php version.

(3 ). open source package directory, enter the ext directory, for example, I will enter:/home/saint/Development/php-5.5.6/ext, ext has various php extension modules, go to ext/sockets.

(4) run the phpize program after cd to ext/sockets:

/home/saint/Development/php/bin/phpize

After execution, we can see that phpize will generate the corresponding configure file

(5). Use configure to configure and execute the following command:

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

Note: The php-config file and phpize file are in the same directory.

(6) Change php. ini and add the following statement:

The Code is as follows:

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

The date folder can be deleted.

(7) Restart Nginx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.