To compile a tutorial on Mac OS to install the NGINX+PHP+MARIADB development environment _php Instance

Source: Internet
Author: User
Tags curl gettext install php mcrypt openssl openssl library php and php source code

Because of the urinary nature of oracle bones. MARIADB should be replacing MySQL. So abandon MySQL

1, compile Nginx
Download Nginx,openssl,pcre separately
You will be prompted when compiling the OpenSSL

warning! If you are wish to build 64-bit library, then your have to
invoke './configure darwin64-x86_64-cc ' *manually*.

If you do not stop compiling there will be an error. This problem should be openssl/config script to guess your system is 64 bits, but will be based on $kernel_bits to determine whether to open the x86_64 compiler, the default is not open (very strange settings, although you will give you 5 seconds to stop compiling and manually open), So the OpenSSL library file you generated is 32-bit, and the last static link to Nginx will make an error. There seems to be no good way to upload x86_64 parameters to the OpenSSL configuration file (openssl/config guessing OS architecture, setting the compilation parameters to 32 bits or 64 bits, the default is 32 bits, and then call openssl/ Configure Generation Makefile)

Can export kernel_bits=64 before configure, if it still doesn't work
You're going to have to change your hand.
Enter Nginx Directory

Copy Code code as follows:

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

To manually modify Objs/makefile:

./config–prefix=/users/xxx/downloads/openssl-1.0.1e/.openssl no-shared No-threads

Change into

Copy Code code as follows:

./configure Darwin64-x86_64-cc–prefix=/users/xxx/downloads/openssl-1.0.1e/.openssl no-shared no-threads

Make again
2, compiling PHP
Download the PHP source code and some class libraries
zlib:http://www.zlib.net/
GD Library: https://bitbucket.org/libgd/gd-libgd/downloads/libgd-2.1.0.tar.gz Bad
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/
and bzip2. GetText and Libtool on the GNU website, but the speed is not, the other libraries I used the system itself. Do not bother to toss, then there is nothing to mend.
In addition to libtool directly dumped in/usr, I have been installed in a separate directory of/usr/local. such as JPEG is/usr/local/jpeg easy to modify later

Copy Code code 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

Compiling MARIABD requires installing CMake first. Go to www.cmake.org download Install tar zxf mariadb-5.5.32.tar.gz

CD mariadb-5.5.32
cmake.-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.conf
CP support-files/ Mysql.server/usr/local/mariadb/mysqld

# MY.CF

Copy Code code as follows:

Cat >/etc/my.cnf << EOF [mysqld] Basedir =/usr/local/mariadb DataDir =/data/mariadb Pid-file =/data/mariadb/m Character-set-server = UTF8 Collation-server = Utf8_general_ci user = MySQL Port = 3306 ariadb.pid = InnoDB Innodb_file_per_table = 1 server_id = 1 Log_bin = Mysql-bin Binlog_format = Mixed Expire_logs_days = 7 Bind-addre SS = 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/mar Iadb/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 Opti On; "
/USR/LOCAL/MARIADB/BIN/MYSQL-E "Grant all privileges on *.* to root@ ' localhost ' identified by ' dbrootpwd ' with Grant Opti On; "
/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 extension
PHP provides a phpize tool for us to install the required extensions.

The following describes the use of phpize:

(1). Find your original compiled PHP installation directory, such as my directory is/home/saint/development/php, in the directory, find Bin/phpize. If you do not have this tool, you do not have the tool installed, so you will need to install Php.dev, which is generally available.

(2). To expand, you need to have a version of PHP and the current installation of PHP source package, the current version of PHP can be used phpinfo () view.

(3). Open the source package directory, into the EXT directory, for example, I entered:/home/saint/development/php-5.5.6/ext, ext under the various PHP with the expansion module, into the ext/sockets.

(4). After CD to Ext/sockets, run the Phpize program:

/home/saint/development/php/bin/phpize

After execution, you can see that phpize will help us generate the corresponding configure files.

(5). Configured by configure, execute the following command:

./configure--enable-sockets--with-php-config=/home/saint/development/php/bin/php-config
 
make
 
Install

Note: The Php-config file is in the same directory as the Phpize

(6). Change PHP.ini, add the following statement:

Copy Code code as follows:

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

I feel ugly. You can delete that date folder

(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.