Build lnmp environment

Operating system: linux Mint 18.2

Compile and install php7.2


1.Install the compiler first
    sudo apt install gcc  automake autoconf libtool g++ 
    #Under centos, it is yum install gcc automake autoconf libtool gcc-c++.
2.Installation of Foundation Library
    sudo apt install libxml2-dev openssl libssl-dev curl libcurl4-gnutls-dev libjpeg-dev libpng12-dev libfreetype6 libfreetype6-dev libmcrypt4 libmcrypt-dev
    #Under centos: Yum install GD zlib zlib-devel OpenSSL openssl-devel libxml 2 libxml 2-devel libjpeg libjpeg-devel libpng-devel free type-devel libmcrypt libmcrypt-devel
2.download php7.2.tar.gz Source code
3.decompression tar -xzvf php7.2.tar.gz

4. Compile and Install

   ./configure --prefix=/usr/local/php7/ \
--with-pcre-regex=/opt/pcre-8.39/ \
--with-pcre-dir=/opt/pcre-8.39/ \
--with-openssl-dir=/opt/openssl-1.0.2h/ \
--with-openssl=/opt/openssl-1.0.2h/ \
--with-zlib-dir=/opt/zlib-1.2.8/ \
--with-zlib=/opt/zlib-1.2.8/ \
--with-curl=/opt/curl-7.50.1/ \
--with-mcrypt=/opt/libmcrypt-2.5.7/ \
--with-bz2 \
--with-ldap=/opt/openldap-2.4.30/ \
--with-gd \
--with-pdo-mysql=shared,mysqlnd \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-gettext \
--with-iconv-dir \
--with-kerberos \
--with-libxml-dir \
--with-mhash \
--with-zlib-dir \
--without-pdo-sqlite \
--with-pear \
--with-xmlrpc \
--with-xsl \
--enable-opcache \
--enable-soap \
--enable-sockets \
--enable-sysvsem \
--enable-xml \
--enable-bcmath \
--enable-libxml \
--enable-inline-optimization \
--enable-mbregex \
--enable-zip \
--enable-ftp \
--enable-fpm \
--enable-mbstring \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--enable-calendar \
--enable-fpm \
--enable-pcntl \
--enable-shmop \
--enable-exif \
--enable-pcntl \
--enable-wddx \
--enable-intl \
--enable-libgcc
./buildconf
./configure --prefix=/usr/local/php7 --exec-prefix=/usr/local/php7 --bindir=/usr/local/php7/bin --sbindir=/usr/local/php7/sbin --includedir=/usr/local/php7/include --libdir=/usr/local/php7/lib/php --mandir=/usr/local/php7/php/man --with-config-file-path=/usr/local/php7/etc --with-mysql-sock=/var/lib/mysql/mysql.sock --with-mcrypt=/usr/include --with-mhash--with-openssl --with-mysqli=shared,mysqlnd --with-pdo-mysql=shared,mysqlnd --with-gd --with-iconv --with-zlib --enable-zip --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-xml --enable-bcmath --enable-shmop  --enable-mbregex --enable-mbstring --enable-ftp --enable-gd-native-ttf --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-openssl --with-jpeg-dir --with-freetype-dir --enable-opcache --enable-fpm --with-fpm-user=www --with-fpm-group=www --without-gdbm --enable-fileinfo --enable-sysvsem  --enable-sysvshm  --enable-sysvmsg --enable-pcntl --enable-maintainer-zts --enable-pthreads


configure: WARNING: unrecognized options: --with-mcrypt, --with-mhash--with-openssl, --enable-gd-native-ttf, --enable-pthreads

Then modify the fpm configuration file
cd /usr/local/php7/etc
sudo cp php-fpm.conf.default php-fpm.conf
But the php-fpm execution error:
../sbin/php-fpm
[23-Jul-2017 15:24:07] WARNING: Nothing matches the include pattern '/usr/local/php7/etc/php-fpm.d/*.conf' from /usr/local/php7/etc/php-fpm.conf at line 125.
[23-Jul-2017 15:24:07] ERROR: failed to open error_log (/usr/local/php7/var/log/php-fpm.log): Permission denied (13)
[23-Jul-2017 15:24:07] ERROR: failed to post process the configuration
[23-Jul-2017 15:24:07] ERROR: FPM initialization failed

Adding users and user groups
sudo addgroup www
sudo adduser www

Then change the users and user groups of the php directory
sudo chown -R www:www /usr/local/php7/
Copy the php.ini-develop ment file from the source code to / usr/local/php7/etc/php.ini
Then execute php-fpm
sudo ./php-fpm
Successfully executed, ps axu | grep php is as follows:

wm@wm-Lenovo /usr/local/php7/sbin $ ps axu | grep php
root     11492  0.0  0.1 177576 11420 ?        Ss   15:40   0:00 php-fpm: master process (/usr/local/php7/etc/php-fpm.conf)
www      11493  0.0  0.1 177576  8748 ?        S    15:40   0:00 php-fpm: pool www
www      11494  0.0  0.1 177576  8744 ?        S    15:40   0:00 php-fpm: pool www
wm       11496  0.0  0.0  15964  1016 pts/1    S+   15:41   0:00 grep --color=auto php

nginx compilation and installation
1. Download the nginx source code and decompress it
2. Download the zlib and pcre source code and decompress it.
3. The parameters of configure, Refer to nginx Official

./configure
    --sbin-path=/usr/local/nginx/nginx
    --conf-path=/usr/local/nginx/nginx.conf
    --pid-path=/usr/local/nginx/nginx.pid
    --with-http_ssl_module
    --with-pcre=../pcre-8.40
    --with-zlib=../zlib-1.2.11
    --user=www
    --group=www

make && make install
As with php installation, modify the user and user groups for / usr/local/nginx to www:www

mysql compilation and installation

https://dev.mysql.com/downloads/mysql/
https://dev.mysql.com/downloads/file/?id=471659
-- https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.19.tar.gz
//Compile and install as follows:
https://dev.mysql.com/doc/refman/5.7/en/source-installation.html
https://dev.mysql.com/doc/refman/5.7/en/installing-source-distribution.html

http://www.cnblogs.com/goozgk/p/5645041.html
# mkdir -p /usr/local/mysql /mydata/data
# groupadd -r mysql
# useradd -g mysql -r -d /data/mydata mysql
# chown -R mysql.mysql /usr/local/mysql /mydata/data

# wget http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz
# tar xf mysql-boost-5.7.13.tar.gz
# cd mysql-5.7.13
# yum install -y openssl openssl-devel

# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/mydata/data \
-DSYSCONFDIR=/etc \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DWITH_LIBWRAP=0 \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DWITH_SSL=system \
-DWITH_ZLIB=system \
-DWITH_BOOST=/home/alex/Downloads/boost_1_59_0 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci

localhost and 127.0.0.1 issues
There are two ways to connect to MySQL databases: TCP/IP (which is commonly understood as the port) and Unix sockets (commonly called sockets or socks). In most cases, localhost can be used to represent the local machine 127.0.0.1, but when MySQL is connected, the two can not be mixed, and the localhost and 127.0.0.1 in MySQL privilege settings are also set separately. When set to 127.0.0.1, the system connects the database by TCP/IP mode; when set to localhost, the system connects the database by socket mode.
Solution: First of all, we need to see where the socket socket file of native MySQL is. The check command is:
mysqld --verbose --help | grep socket
The output shows the location of the socket file. For example, this server displays
socket /var/run/mysqld/mysqld.sock
Then modify the PHP configuration file php.ini to match it.
Find this item:
mysql.default_socket =
Generally speaking, this item is empty and should be replaced by:
mysql.default_socket = /var/run/mysqld/mysqld.sock
Here should be written a step to query the file, according to your situation settings. So far, the php configuration has been modified. If it is CLI (command line) mode or CGI mode, it will take effect immediately. If it is FASTCGI mode, it needs to restart the fastcgi process.

Keywords: PHP MySQL OpenSSL zlib

Added by phpbeginer on Wed, 12 Jun 2019 01:18:05 +0300