LNMP Environment Construction (centos6.9+mysql5.7+php7.1+nginx1.9)

Source: Internet
Author: User

First, install MySQL

For MySQL installation please refer to

Lamp Environment Construction (centos6.9+apache2.4+mysql5.7+php7.1),

Same as the installation method inside.


Second, PHP installation

Cd/usr/local/src
wget http://mirrors.sohu.com/php/php-7.1.3.tar.gz
Tar zxvf php-7.1.3.tar.gz
CD php-7.1.3

./configure \
--prefix=/usr/local/php \
--WITH-APXS2=/USR/LOCAL/APACHE2/BIN/APXS \
--WITH-CONFIG-FILE-PATH=/USR/LOCAL/PHP/ETC \
--ENABLE-FPM \
--with-fpm-user=nobody \
--with-fpm-group=nobody \
--with-mysql-sock=/tmp/mysql.sock \
--ENABLE-MYSQLND \
--WITH-MYSQLI=MYSQLND \
--WITH-PDO-MYSQL=MYSQLND \
--with-libxml-dir \
--WITH-GD \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-iconv-dir \
--with-zlib-dir \
--WITH-BZ2 \
--WITH-OPENSSL \
--with-mcrypt \
--ENABLE-SOAP \
--ENABLE-GD-NATIVE-TTF \
--enable-mbstring \
--enable-sockets \
--ENABLE-EXIF \
--disable-ipv6

Make && make install

CP Php.ini-production/usr/local/php/etc/php.ini

cp/usr/local/src/php-7.1.3/sapi/fpm/init.d.php-fpm/etc/init.d/php-fpm
Cp-v/usr/local/php/etc/{php-fpm.conf.default,php-fpm.conf}

Cp-v/usr/local/php/etc/php-fpm.d/{www.conf.default,www.conf}
Vi/usr/local/php/etc/php-fpm.d/www.conf

Modify (if the user and group are set in the compilation parameters, there is no need to modify it here)
user = Nobody
Group = Nobody

Modify PHP.ini
Vi/usr/local/php/etc/php.ini
Date.timezone = asia/chongqing

chmod 755/etc/init.d/php-fpm
Chkconfig--add PHP-FPM
Chkconfig PHP-FPM on
Service PHP-FPM Start


Third, install Nginx
Cd/usr/local/src
Yum Install-y pcre-devel
wget http://mirrors.sohu.com/nginx/nginx-1.9.15.tar.gz
Tar zxvf nginx-1.9.15.tar.gz
CD nginx-1.9.15
./configure--prefix=/usr/local/nginx--with-pcre
Make && make install

Vi/etc/init.d/nginx

Save the Nginx script (copy nginx startup script from here) to/etc/init.d/nginx and find the following three lines

nginx= "/usr/sbin/nginx"
Pidfile= "/var/run/${prog}.pid"

Nginx_conf_file= "/etc/nginx/nginx.conf"


Modified to:

nginx= "/usr/local/nginx/sbin/nginx"
Pidfile= "/usr/local/nginx/logs/${prog}.pid"

Nginx_conf_file= "/usr/local/nginx/conf/nginx.conf"


After saving, execute
chmod +x/etc/init.d/nginx
Chkconfig--add Nginx
Chkconfig Nginx on
/etc/init.d/nginx start


V. Configuration parsing PHP

Vi/usr/local/nginx/conf/nginx.conf
Found it

Location/{root HTML;        Index index.html index.htm; }

Change into

Location/{root HTML;        Index index.html index.htm index.php; }

Found it

#location ~ \.php$ {# root HTML;        # Fastcgi_pass 127.0.0.1:9000;        # Fastcgi_index index.php;        # Fastcgi_param Script_filename/scripts$fastcgi_script_name;        # include Fastcgi_params; #}

Change into

Location ~ \.php$ {root html;            Fastcgi_pass 127.0.0.1:9000;            Fastcgi_index index.php;            Fastcgi_param Script_filename/usr/local/nginx/html$fastcgi_script_name;        Include Fastcgi_params; }

Test nginx configuration file is correct

/usr/local/nginx/sbin/nginx-t

Reload the configuration file

/etc/init.d/nginx Reload
Test parsing PHP

vi/usr/local/nginx/html/1.php

Write:

<?php echo "PHP parsing normal"; Echo phpinfo ();? >

After saving, continue testing:

Curl localhost/1.php

View results can be resolved successfully.

LNMP Environment Construction (centos6.9+mysql5.7+php7.1+nginx1.9)

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.