Recently upgraded the system to the UBUNTU16 long-term Support edition and redeployed the LNMP environment
Contract several directory source directory/usr/local/src
Mysql/usr/local/mysql
php/usr/local/php
Nginx/usr/local/nginx
MySQLVersion 5.7.14
Essential Packages and tools
gcc/g++: MySQL 5.6 starts and needs to be compiled with g++.
The BISON:MYSQL syntax parser needs to be compiled with bison.
Libncurses5-dev: A development package for terminal operations. (Note: Debian/ubuntu need to install libncurses5-dev;redhat under the need to install ncurses-devel)
Zlib:mysql using zlib for compression
Package Required for function
LIBXML2: Support for XML input and output methods.
OpenSSL: Use the OpenSSL Secure Sockets method to communicate.
DTrace: Used to diagnose MySQL problems.
Starting with Cmake:mysql 5.5, CMake is used for project management, and CMake requires more than 2.8 versions.
sudo apt-get install gcc
sudo apt-get install LIBXML2
sudo apt-get install Libncurses5-dev bison
Installing CMake https://cmake.org/download/
Create Source Package Directory
Mkdir/usr/local/src
Extract
Tar zxvf cmake-3.6.1.tar.gz
MV Cmake-3.6.1/usr/local/src
CD cmake-3.6.1
Compiling the installation
./configure make && make install
Adding environment variables
Vim ~/.BASHRC
Add to
Export path= "/usr/local/src/cmake-3.6.1/bin/cmake: $PATH"
Starting the boost library from MySQL 5.7.5 is required, download the Boost library http://sourceforge.net/projects/boost/files/boost/
Tar zxvf boost_1_59_0.tar.gz
MV boost_1_59_0/usr/local/
Create a MySQL system user group and user, and a database storage directory:
Mkdir-p/usr/local/mysql/
Mkdir-p/usr/local/mysql/data/
Create a separate MySQL socket file as needed to save the directory, and recompile if you want to reassign the storage location
Groupadd mysql add MySQL user group
Useradd mysql-g mysql add mysql user and specify MySQL user group
Chown-r mysql:mysql/usr/local/mysql/Change the specified directory and its subdirectories under permissions for MySQL user and MySQL user group
MySQL official
http://dev.mysql.com/downloads/mysql/ To select a compiled version
Tar zxvf mysql-5.7.14.tar.gz
CD mysql-5.7.14
Compile
CMake. -dcmake_install_prefix=/usr/local/mysql-dmysql_datadir=/usr/local/mysql/data-dwith_innobase_storage_engine=1- Dwith_archive_storage_engine=1-dwith_blackhole_storage_engine=1-dwith_partition_storage_engine=1-dwith_ Perfschema_storage_engine=1-dwithout_example_storage_engine=1-dwithout_federated_storage_engine=1-ddefault_ Charset=utf8-ddefault_collation=utf8_general_ci-dwith_extra_charsets=all-denabled_local_infile=1-dmysql_unix_ Addr=/usr/local/mysql/data/mysql.sock-dcompilation_comment= "string"-denabled_profiling=1-doptimizer_trace=1- Dwith_debug=1-dwith_boost=/usr/local/boost
Make && make install
Create a database service
In versions 5.5 and 5.6, the MySQL database was initialized with the Mysqld_db_install command, and after 5.7, the database initialization changed, requiring the MYSQLD command to initialize:
/usr/local/mysql/bin/mysqld--initialize--user=mysql--basedir=/usr/local/mysql--datadir=/usr/local/mysql/data/
---to add the--user=mysql parameter when initializing the operation with root, generate a random password (note to save login)
Once the database has been initialized, modify the permissions again:
Chown-r Mysql:mysql/usr/local/mysql/data
Prepare the configuration file and start the MySQL service
Copy the default configuration file to/etc
Cp/usr/local/mysql/support-files/my-default.cnf/etc/my.cnf
Change file permissions for MySQL users and groups
sudo chown mysql:mysql/etc/my.cnf
Simply modify the configuration file
Vim/etc/my.cnf
[Client]
Port = 3306
Socket =/usr/local/mysql/data/mysql.sock
[Mysqld]
Port = 3306
Socket =/usr/local/mysql/data/mysql.sock
Basedir =/usr/local/mysql
DataDir =/usr/local/mysql/data
Background start MySQL
/usr/local/mysql/bin/mysqld_safe--user--defaults-file/etc/my.cnf
View MySQL port or process
Netstat-altn | grep 3306 or Ps-ef|grep MySQL
TCP6 0 0::: 3306:::* LISTEN
Change password after log in with initial random password
/usr/local/mysql/bin/mysql-uroot-p
mysql> Set password for [email protected]=password (' new password ');
Query OK, 0 rows affected, 1 Warning (0.00 sec)
Add service, copy startup script to/ETC/INIT.D directory
cd/usr/local/mysql/
CP Support-files/mysql.server/etc/init.d/mysql
Set permissions
sudo chmod 755/etc/init.d/mysql
Install Ubuntu Start-up service management
sudo apt-get install sysv-rc-conf
sudo sysv-rc-conf MySQL on
Mysql.service becomes available
Systemctl Enable Mysql.service
Turn on or off the MySQL service
Sudo/etc/init.d/mysql {Stop|start} or sudo service mysql start | Stop
Configuring Environment variables
sudo vim ~/.BASHRC
Export path= "/usr/local/mysql/bin/: $PATH"
Export PATH
Nginx version 1.10.1
Preparatory work
Requires Zlib library http://www.zlib.net/
TAR-XVF zlib-1.2.8.tar.gz-c/USR/LOCAL/SRC
Mv/usr/local/src/zlib-1.2.8/usr/local/src/zlib
Build a shared library
Cd/usr/local/src/zlib
./configure--shared && make test && make install
CP Zutil.h/usr/local/include
CP Zutil.c/usr/local/include
Mkdir/usr/local/zlib
./configure--prefix=/usr/local/zlib
Add to Dynamic link library
Add/usr/local/zlib/lib to/etc/ld.so.conf
Ldconfig
Requires Pcre library http://www.pcre.org/
Tar zxvf pcre-8.39.tar.gz-c/usr/local/src
Mv/usr/local/src/pcre-8.39/usr/local/src/prce
Cd/usr/local/prce
./configure && make && make install
SSL feature requires OpenSSL library http://www.openssl.org/source/download 1.0.2g version
Tar zxvf openssl-1.0.2g.tar.gz-c/usr/local/src
cd/usr/local/openssl-1.0.2g
./config--prefix=/usr/local/shared
Make Test && make install
Add to Dynamic link library
Add/usr/local/lib to/etc/ld.so.conf
Ldconfig
Adding Nginx Users and user groups
Groupadd www
Useradd www-g www
Chown-r Www:www/usr/local/nginx
Nginx official website http://nginx.org/
Tar zxvf nginx-1.10.1.tar.gz-c/usr/local/src
cd/usr/local/src/nginx-1.10.1
Compiling the installation
./configure--prefix=/usr/local/nginx--with-openssl=/usr/local/src/openssl-1.0.2g--with-pcre=/usr/local/src/ Pcre--with-zlib=/usr/local/src/zlib--pid-path=/usr/local/nginx/nginx.pid--with-http_ssl_module--with-http_stub _status_module
Make && make install
Start Nginx Service
/usr/local/nginx/sbin/nginx
View Nginx Process
Ps-ef | grep nginx
Shutdown, restart service
/usr/local/nginx/sbin/nginx-s stop, quit, reopen, reload
Cp/usr/local/nginx/sbin/nginx/etc/init.d/nginx
Update permissions
sudo chmod 755/etc/init.d/nginx
sudo sysv-rc-conf nginx on
Configuring Environment variables
sudo ~/.bashrc
Export path= "/usr/local/nginx/sbin/: $PATH"
Configuring Nginx Support PHP
Vim/usr/local/nginx/conf/nginx.conf
Location/{
root/www;
Index index.html index.htm index.php;
}
Location ~ \.php$ {
root/www;
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Fastcgi_param script_filename/www$fastcgi _script_name;
Include Fastcgi_params;
}
Note: the blackbody www is the Web root directory, you can change it to the corresponding directory
Php
Apt-get Installing PHP 7 php5.6
PHP 7
Apt-get Install php7.0-mysql php7.0-curl php7.0-gd php7.0-intl php-pear php-imagick php7.0-imap php7.0-mcrypt Php-memcache Php7.0-pspell php7.0-recode php7.0-sqlite3 php7.0-tidy php7.0-xmlrpc php7.0-xsl php7.0-mbstring Php-gettext
PHP 5.6
sudo apt install Software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php5.6
sudo apt-get install php5.6-mbstring php5.6-mcrypt php5.6-mysql php5.6-xml
5.6.25 compile and install the necessary dependencies
T1lib (php font class extension) version t1lib-5.1.2.tar.gz http://www.t1lib.org/
Extract
Tar zxvf t1lib-5.1.2.tar.gz-c/usr/local/src
CD/USR/LOCAL/SRC t1lib-5.1.2
./configure
Hint Error: X11/xaw/label.h:no such file or directory
Missing Libxaw Library
sudo apt-get install Libxaw7-dev
./configure && make Without_doc && make install
Download php5.6.25 source package on official website
Tar zxvf php-5.6.23.tar.gz-c/usr/local/src
cd/usr/local/src/
Compiling the installation
./configure--prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc--with-mysql-sock=/usr /local/mysql/data/mysql.sock --enable-mbstring --enable-mysqlnd--with-mysql=mysqlnd--with-mysqli=/ Usr/local/mysql/bin/mysql_config--with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd--enable-fpm -- With-fpm-group=www --with-fpm-user=www --enable-bcmath --enable-bcmath --enable-soap-- Enable-calendar --with-pcre-dir=/usr/local/src/pcre --with-mcrypt--enable-xml -- With-xmlrpc --with-xsl--enable-sockets --enable-opcache --with-gd --with-jpeg-dir -- With-png-dir --with-xpm-dir --with-freetype-dir --enable-gd-native-ttf --enable-dtrace --with-openssl--with-kerberos--with-openssl-dir=/usr/local/src/openssl-1.0.2g --enable-zip-- With-zlib-dir=/usr/local/src/zlib--with-t1lib=/usr/local/share/t1lib --with-libxml-dir--with-iconv-dir--wIth-libzip --enable-intl--with-curl=dir --enable-ftp
Tip cannot find sys/sdt.h which is required for DTrace support
According to the official Tip dtrace some development editions need to install the SYSTEMTAP SDT Development Kit
Apt-cache Search SystemTap SDT
Apt-get Install Systemtap-sdt-dev
Tip Curl Compilation failed
Apt-get Install Libcurl4-gnutls-dev
Apt-get Install Curl Php5.6-curl
Prompt to reinstall Libzip
Apt-get Install Libzip-dev
Clean up the previously compiled executables and configuration files and compile them again
Make clean
./configure--prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc--with-mysql-sock=/usr /local/mysql/data/mysql.sock --enable-mbstring --enable-mysqlnd--with-mysql=mysqlnd--with-mysqli=/ Usr/local/mysql/bin/mysql_config--with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd--enable-fpm -- With-fpm-group=www --with-fpm-user=www --enable-bcmath --enable-bcmath --enable-soap-- Enable-calendar --with-pcre-dir=/usr/local/src/pcre --with-mcrypt--enable-xml -- With-xmlrpc --with-xsl--enable-sockets --enable-opcache --with-gd --with-jpeg-dir -- With-png-dir --with-xpm-dir --with-freetype-dir --enable-gd-native-ttf --enable-dtrace --with-openssl--with-kerberos--with-openssl-dir=/usr/local/src/openssl-1.0.2g --enable-zip-- With-zlib-dir=/usr/local/src/zlib--with-t1lib=/usr/local/share/t1lib --with-libxml-dir--with-iconv-dir--wIth-libzip --enable-intl--with-curl=dir --with-imap--with-imap-ssl --enable-ftp
Test
Make && make Test
Testing is done by installing
Make install
Configure PHP to boot with the system
Copy php.ini to directory from source file
CP Php.ini-development/usr/local/php/etc/php.ini
Copy php-fpm.conf
Cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf
PHP-FPM with system self-booting
sudo cp./sapi/fpm/init.d.php-fpm/etc/init.d/php-fpm
sudo sysv-rc-conf php-fpm on
sudo cp./sapi/fpm/init.d.php-fpm/usr/local/php/sbin/init.d.php-fpm
sudo chmod 755/etc/init.d/php-fpm
Increased reading and enforcement rights
cd/usr/local/php/sbin/
chmod 755 INIT.D.PHP-FPM
PHP scripting service on, stop, restart, status command
./init.d.php-fpm {Start|stop|force-quit|restart|reload|status}
adding system Variables
Vim ~/.BASHRC
Export path= "/usr/local/php/bin/: $PATH"
Export path= "/usr/local/php/sbin/: $PATH"
Export PATH
Change PHP user Group to www
Chown-r www:www/usr/local/php
View ports
sudo netstat-tulpn
php-fpm.conf Configuration
Pm.max_children = 5
Pm.start_servers = 2 Number of child processes started at startup
Pm.min_spare_servers = 1 The least-kid process in idle "idle" state, if the number of idle processes is less than this value, then the corresponding child process is created
Pm.max_spare_servers = 3 Maximum number of idle child processes, the number of idle child processes exceeds this value, then the corresponding child process will be killed.
Create a phpinfo () file in the Nginx web directory, the browser output this screen indicates a successful configuration
Ubuntu16 under the Source Configuration LNMP development environment