Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build a Nginx1.10.3+MySQL5.7.16+PHP7.1.2 environment in CentOS 7.3.1611

2025-02-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article is about how to build a Nginx1.10.3+MySQL5.7.16+PHP7.1.2 environment in CentOS 7.3.1611. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article.

Preparation article

I. Firewall configuration

CentOS 7.x uses firewall as the firewall by default, which is changed to iptables firewall here.

1. Close firewall:

Systemctl stop firewalld.service # stop firewall

Systemctl disable firewalld.service # prevents firewall from booting

2. Install iptables firewall

Yum install iptables-services # installation

Vi / etc/sysconfig/iptables # Editing Firewall profile

# sample configuration for iptables service

# you can edit this manually or use system-config-firewall

# please do not ask us to add additional ports/services to this default configuration

* filter

: INPUT ACCEPT [0:0]

: FORWARD ACCEPT [0:0]

: OUTPUT ACCEPT [0:0]

-An INPUT-m state-- state RELATED,ESTABLISHED-j ACCEPT

-An INPUT-p icmp-j ACCEPT

-An INPUT-I lo-j ACCEPT

-An INPUT-p tcp-m state-- state NEW-m tcp-- dport 22-j ACCEPT

-An INPUT-p tcp-m state-- state NEW-m tcp-- dport 80-j ACCEPT

-An INPUT-p tcp-m state-- state NEW-m tcp-- dport 3306-j ACCEPT

-An INPUT-j REJECT-- reject-with icmp-host-prohibited

-A FORWARD-j REJECT-- reject-with icmp-host-prohibited

COMMIT

: wq! # Save exit

Systemctl restart iptables.service # finally restart the firewall to make the configuration effective

Systemctl enable iptables.service # set the firewall to boot

/ usr/libexec/iptables/iptables.init restart # restart the firewall

2. Close SELINUX

Vi / etc/selinux/config

# SELINUX=enforcing # comment out

# SELINUXTYPE=targeted # comment out

SELINUX=disabled # increased

: wq! # Save exit

Setenforce 0 # makes the configuration effective immediately

III. System agreement

Software source code package location: / usr/local/src

Source package compilation installation location: / usr/local/ software name

Download the software package

1. Download nginx

Http://nginx.org/download/nginx-1.10.3.tar.gz

2. Download MySQL

Https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.16.tar.gz

3. Download php

Http://cn2.php.net/distributions/php-7.1.2.tar.gz

4. Download cmake (MySQL compilation tool)

Https://cmake.org/files/v3.7/cmake-3.7.2.tar.gz

5. Download pcre (nginx pseudo-static is supported)

Ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz

6. Download openssl (nginx extension)

Https://www.openssl.org/source/openssl-1.1.0e.tar.gz

7. Download zlib (nginx extension)

Http://www.zlib.net/zlib-1.2.11.tar.gz

8. Download libmcrypt (php extension)

Https://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz

9. Download yasm (php extension)

Http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz

10. T1lib (php extension)

Http://download.freenas.org/distfiles/t1lib-5.1.2.tar.gz

11. Download the gd library installation package

Https://github.com/libgd/libgd/releases/download/gd-2.1.1/libgd-2.1.1.tar.gz

12. Libvpx (required for gd library)

Https://codeload.github.com/webmproject/libvpx/tar.gz/v1.3.0

13. Tiff (required for gd library)

Http://download.osgeo.org/libtiff/tiff-4.0.7.tar.gz

14. Libpng (required for gd library)

Ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng16/libpng-1.6.28.tar.gz

15. Freetype (required for gd library)

Http://download.savannah.gnu.org/releases/freetype/freetype-2.7.1.tar.gz

16. Jpegsrc (required for gd library)

Http://www.ijg.org/files/jpegsrc.v9b.tar.gz

17. Boost (required to compile mysql)

Https://ufpr.dl.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz

The above packages are uploaded to the / usr/local/src directory

Install compilation tools and library files (install using yum command)

Yum install-y apr* autoconf automake bison bzip2 bzip2* cloog-ppl compat* cpp curl curl-devel fontconfig fontconfig-devel freetype freetype* freetype-devel gcc gcc-c++ gtk+-devel gd gettext gettext-devel glibc kernel kernel-headers keyutils keyutils-libs-devel krb5-devel libcom_err-devel libpng libpng-devel libjpeg* libsepol-devel libselinux-devel libstdc++-devel libtool* libgomp libxml2 libxml2-devel libXpm* libxml* libXaw-devel libXmu-devel libtiff libtiff* make mpfr ncurses* ntp openssl openssl-devel patch pcre-devel perl php-common php-gd policycoreutils telnet t1lib t1lib * nasm nasm* wget zlib-devel

Installation section

The following is done by using the putty tool to remotely log in to the server and operate under the command line

First, install MySQL

1. Install cmake

Cd / usr/local/src

Tar zxvf cmake-3.7.2.tar.gz

Cd cmake-3.7.2

. / configure

Make

Make install

2. Install MySQL

Cd / usr/local/src

Mkdir-p / usr/local/boost

Cp boost_1_59_0.tar.gz / usr/local/boost

Groupadd mysql # add mysql Group

Useradd-g mysql mysql-s / bin/false # create a user mysql and join the mysql group, and do not allow mysql users to log in directly to the system

Mkdir-p / data/mysql # create MySQL database storage directory

Chown-R mysql:mysql / data/mysql # sets MySQL database storage directory permissions

Mkdir-p / usr/local/mysql # create the MySQL installation directory

Cd / usr/local/src # enters the package storage directory

Tar zxvf mysql-5.7.16.tar.gz # decompression

Cd mysql-5.7.16 # enter the directory

Cmake. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DMYSQL_DATADIR=/data/mysql-DWITH_INNOBASE_STORAGE_ENGINE=1-DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci-DWITH_EMBEDDED_SERVER=OFF-DWITH_BOOST=/usr/local/boost

Note: you can use the-DDOWNLOAD_BOOST=1-DWITH_BOOST=/usr/local/boost parameter to install the boost package online, which requires the server to connect to the network, so it is easy to download and fail.

Cmake. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DMYSQL_DATADIR=/data/mysql-DMYSQL_UNIX_ADDR=/tmp/mysql.sock-DMYSQL_USER=mysql-DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci-DENABLED_LOCAL_INFILE=ON-DWITH_INNOBASE_STORAGE_ENGINE=1-DWITH_FEDERATED_STORAGE_ENGINE=1-DWITH_BLACKHOLE_STORAGE_ENGINE=1-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1-DWITH_EMBEDDED_SERVER=OFF-DDOWNLOAD_BOOST=1-DWITH_BOOST=/usr/local/boost

Make # compilation

Make install # installation

Compilation error, before recompilation to delete the failed file, recompile, need to clear the old object files and cache information.

Make clean

Rm-f CMakeCache.txt

Rm-rf / etc/my.cnf # Delete the default configuration file of the system (do not delete it if there is no default)

Cd / usr/local/mysql # enter the MySQL installation directory

. / bin/mysqld-- user=mysql-- initialize-- basedir=/usr/local/mysql-- datadir=/data/mysql # generate mysql system database

-- initialize means the password is generated by default,-- initialize-insecure means no password is generated, and the password is empty.

See this line [Note] A temporary password is generated for root@localhost: I > X18*=Rav=7

Cp / usr/local/mysql/support-files/my-default.cnf / usr/local/mysql/my.cnf

Ln-s / usr/local/mysql/my.cnf / etc/my.cnf # soft connections added to the / etc directory

Cp / usr/local/mysql/support-files/mysql.server / etc/rc.d/init.d/mysqld # add Mysql to the system startup

Chmod 755 / etc/init.d/mysqld # increased execution permissions

Chkconfig mysqld on # join Boot Boot

Vi / etc/rc.d/init.d/mysqld # editing

Basedir=/usr/local/mysql # MySQL Program installation path

Datadir=/data/mysql # MySQl database storage directory

: wq! # Save exit

Service mysqld start # Startup

Vi / etc/profile # adds the mysql service to the system environment variable: add the following line at the end

Export PATH=$PATH:/usr/local/mysql/bin

: wq! # Save exit

Source / etc/profile # makes the configuration effective immediately

The following two lines link the library files of myslq to the default location of the system, so that you don't have to specify the library file address of mysql when compiling software like PHP.

Ln-s / usr/local/mysql/lib/mysql / usr/lib/mysql

Ln-s / usr/local/mysql/include/mysql / usr/include/mysql

Mkdir / var/lib/mysql # create directory

Ln-s / tmp/mysql.sock / var/lib/mysql/mysql.sock # add soft links

Mysql_secure_installation # modify the Mysql password, enter the previously generated secret CSJlm3DyTG.d enter, and follow the prompts.

Press y | Y for Yes, any other key for No: y # do you want to install password security plug-ins? Select y

There are three levels of password validation policy: # there are several password strength choices

LOW Length > = 8

MEDIUM Length > = 8, numeric, mixed case, and special characters

STRONG Length > = 8, numeric, mixed case, special characters and dictionary file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0 # Select 0, as long as 8 digits, select 1 with uppercase, lowercase, special characters, etc.

UNINSTALL PLUGIN validate_password; # Uninstall the password strength plugin

Use mysql

Update mysql.user set authentication_string=password ('123456') where user='root'; # Log in to the mysql console to modify

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password AS' 123456password; # change password

Second, install Nginx

1. Install pcre

Cd / usr/local/src

Mkdir / usr/local/pcre

Tar zxvf pcre-8.40.tar.gz

Cd pcre-8.40

. / configure-- prefix=/usr/local/pcre

Make

Make install

2. Install openssl

Cd / usr/local/src

Mkdir / usr/local/openssl

Tar zxvf openssl-1.1.0e.tar.gz

Cd openssl-1.1.0e

. / config-- prefix=/usr/local/openssl

Make

Make install

Vi / etc/profile

Export PATH=$PATH:/usr/local/openssl/bin

: wq!

Source / etc/profile

3. Install zlib

Cd / usr/local/src

Mkdir / usr/local/zlib

Tar zxvf zlib-1.2.11.tar.gz

Cd zlib-1.2.11

. / configure-- prefix=/usr/local/zlib

Make

Make install

4. Install Nginx

Groupadd www

Useradd-g www www-s / bin/false

Cd / usr/local/src

Tar zxvf nginx-1.10.3.tar.gz

Cd nginx-1.10.3

/ configure-- prefix=/usr/local/nginx-- without-http_memcached_module-- user=www-- group=www-- with-http_stub_status_module-- with-http_ssl_module-- with-http_gzip_static_module-- with-openssl=/usr/local/src/openssl-1.1.0e-- with-zlib=/usr/local/src/zlib-1.2.11-- with-pcre=/usr/local/src/pcre-8.40

Note:-- with-openssl=/usr/local/src/openssl-1.1.0e-- with-zlib=/usr/local/src/zlib-1.2.11-- with-pcre=/usr/local/src/pcre-8.40 points to the path of decompression of the source package, not the path of installation, otherwise an error will be reported.

Make

Make install

/ usr/local/nginx/sbin/nginx # launch Nginx

Set nginx to boot

Vi / etc/rc.d/init.d/nginx # Edit startup file to add the following

?

one

two

three

four

five

six

seven

eight

nine

ten

eleven

twelve

thirteen

fourteen

fifteen

sixteen

seventeen

eighteen

nineteen

twenty

twenty-one

twenty-two

twenty-three

twenty-four

twenty-five

twenty-six

twenty-seven

twenty-eight

twenty-nine

thirty

thirty-one

thirty-two

thirty-three

thirty-four

thirty-five

thirty-six

thirty-seven

thirty-eight

thirty-nine

forty

forty-one

forty-two

forty-three

forty-four

forty-five

forty-six

forty-seven

forty-eight

forty-nine

fifty

fifty-one

fifty-two

fifty-three

fifty-four

fifty-five

fifty-six

fifty-seven

fifty-eight

fifty-nine

sixty

sixty-one

sixty-two

sixty-three

sixty-four

sixty-five

sixty-six

sixty-seven

sixty-eight

sixty-nine

seventy

seventy-one

seventy-two

seventy-three

seventy-four

seventy-five

seventy-six

seventy-seven

seventy-eight

seventy-nine

eighty

eighty-one

eighty-two

eighty-three

eighty-four

eighty-five

eighty-six

eighty-seven

eighty-eight

eighty-nine

ninety

ninety-one

ninety-two

ninety-three

ninety-four

ninety-five

ninety-six

ninety-seven

ninety-eight

ninety-nine

one hundred

one hundred and one

one hundred and two

one hundred and three

one hundred and four

one hundred and five

one hundred and six

one hundred and seven

one hundred and eight

one hundred and nine

one hundred and ten

one hundred and eleven

one hundred and twelve

one hundred and thirteen

one hundred and fourteen

one hundred and fifteen

one hundred and sixteen

one hundred and seventeen

one hundred and eighteen

one hundred and nineteen

one hundred and twenty

one hundred and twenty one

one hundred and twenty two

one hundred and twenty three

one hundred and twenty four

one hundred and twenty five

one hundred and twenty six

one hundred and twenty seven

one hundred and twenty eight

one hundred and twenty nine

one hundred and thirty

one hundred and thirty one

one hundred and thirty two

one hundred and thirty three

one hundred and thirty four

one hundred and thirty five

one hundred and thirty six

one hundred and thirty seven

one hundred and thirty eight

one hundred and thirty nine

one hundred and forty

one hundred and forty one

one hundred and forty two

one hundred and forty three

one hundred and forty four

one hundred and forty five

one hundred and forty six

one hundred and forty seven

one hundred and forty eight

one hundred and forty nine

one hundred and fifty

one hundred and fifty one

one hundred and fifty two

one hundred and fifty three

one hundred and fifty four

one hundred and fifty five

one hundred and fifty six

one hundred and fifty seven

one hundred and fifty eight

one hundred and fifty nine

one hundred and sixty

one hundred and sixty one

one hundred and sixty two

one hundred and sixty three

one hundred and sixty four

one hundred and sixty five

one hundred and sixty six

one hundred and sixty seven

one hundred and sixty eight

one hundred and sixty nine

one hundred and seventy

one hundred and seventy one

one hundred and seventy two

one hundred and seventy three

one hundred and seventy four

one hundred and seventy five

one hundred and seventy six

one hundred and seventy seven

one hundred and seventy eight

one hundred and seventy nine

one hundred and eighty

one hundred and eighty one

one hundred and eighty two

one hundred and eighty three

one hundred and eighty four

one hundred and eighty five

one hundred and eighty six

one hundred and eighty seven

one hundred and eighty eight

one hundred and eighty nine

one hundred and ninety

one hundred and ninety one

one hundred and ninety two

one hundred and ninety three

one hundred and ninety four

one hundred and ninety five

one hundred and ninety six

one hundred and ninety seven

one hundred and ninety eight

one hundred and ninety nine

two hundred

two hundred and one

two hundred and two

two hundred and three

two hundred and four

two hundred and five

two hundred and six

two hundred and seven

two hundred and eight

two hundred and nine

two hundred and ten

two hundred and eleven

two hundred and twelve

two hundred and thirteen

two hundred and fourteen

two hundred and fifteen

two hundred and sixteen

two hundred and seventeen

two hundred and eighteen

two hundred and nineteen

two hundred and twenty

two hundred and twenty one

two hundred and twenty two

two hundred and twenty three

two hundred and twenty four

two hundred and twenty five

two hundred and twenty six

two hundred and twenty seven

# # #

#! / bin/sh

#

# nginx-this script starts and stops the nginx daemon

#

# chkconfig:-85 15

# description: Nginx is an HTTP (S) server, HTTP (S) reverse\

# proxy and IMAP/POP3 proxy server

# processname: nginx

# config: / etc/nginx/nginx.conf

# config: / usr/local/nginx/conf/nginx.conf

# pidfile: / usr/local/nginx/logs/nginx.pid

# Source function library.

. / etc/rc.d/init.d/functions

# Source networking configuration.

. / etc/sysconfig/network

# Check that networking is up.

["$NETWORKING" = "no"] & & exit 0

Nginx= "/ usr/local/nginx/sbin/nginx"

Prog=$ (basename $nginx)

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

[- f / etc/sysconfig/nginx] & &. / etc/sysconfig/nginx

Lockfile=/var/lock/subsys/nginx

Make_dirs () {

# make required directories

User= `$ nginx-V 2 > & 1 | grep "configure arguments:" | sed's / [^ *] *-- user=\ ([^] *\). * /\ 1Uniple g'- `

If [- z "`grep $user / etc/ passwd`]; then

Useradd-M-s / bin/nologin $user

Fi

Options= `$ nginx-V 2 > & 1 | grep 'configure arguments:' `

For opt in $options; do

If [`echo $opt | grep'. *-temp-path' `]; then

Value= `echo $opt | cut-d "="-f 2`

If [!-d "$value"]; then

# echo "creating" $value

Mkdir-p $value & & chown-R $user $value

Fi

Fi

Done

}

Start () {

[- x $nginx] | | exit 5

[- f $NGINX_CONF_FILE] | | exit 6

Make_dirs

Echo-n $"Starting $prog:"

Daemon $nginx-c $NGINX_CONF_FILE

Retval=$?

Echo

[$retval-eq 0] & & touch $lockfile

Return $retval

}

Stop () {

Echo-n $"Stopping $prog:"

Killproc $prog-QUIT

Retval=$?

Echo

[$retval-eq 0] & & rm-f $lockfile

Return $retval

}

Restart () {

# configtest | | return $?

Stop

Sleep 1

Start

}

Reload () {

# configtest | | return $?

Echo-n $"Reloading $prog:"

Killproc $nginx-HUP

RETVAL=$?

Echo

}

Force_reload () {

Restart

}

Configtest () {

$nginx-t-c $NGINX_CONF_FILE

}

Rh_status () {

Status $prog

}

Rh_status_q () {

Rh_status > / dev/null 2 > & 1

}

Case "$1" in

Start)

Rh_status_q & & exit 0

, 1

Stop)

Rh_status_q | | exit 0

, 1

Restart | configtest)

, 1

Reload)

Rh_status_q | | exit 7

, 1

Force-reload)

Force_reload

Status)

Rh_status

Condrestart | try-restart)

Rh_status_q | | exit 0

*)

Echo $"Usage: $0 {start | stop | status | restart | condrestart | try-restart | reload | force-reload | configtest}"

Exit 2

Esac

# # #

: wq! # Save exit

Chmod 775 / etc/rc.d/init.d/nginx # gives file execution permissions

Chkconfig nginx on # set boot up

/ etc/rc.d/init.d/nginx restart # restart

Open the server IP address in the browser and you will see the following interface, indicating that Nginx has been installed successfully.

Third, install php

1. Install yasm

Cd / usr/local/src

Tar zxvf yasm-1.3.0.tar.gz

Cd yasm-1.3.0

. / configure

Make

Make install

2. Install libmcrypt

Cd / usr/local/src

Tar zxvf libmcrypt-2.5.8.tar.gz

Cd libmcrypt-2.5.8

. / configure

Make

Make install

3. Install libvpx

Cd / usr/local/src

Tar zxvf libvpx-1.3.0.tar.gz

Cd libvpx-1.3.0

. / configure-- prefix=/usr/local/libvpx-- enable-shared-- enable-vp9

Make

Make install

4. Install tiff

Cd / usr/local/src

Tar zxvf tiff-4.0.7.tar.gz

Cd tiff-4.0.7

. / configure-prefix=/usr/local/tiff-enable-shared

Make

Make install

5. Install libpng

Cd / usr/local/src

Tar zxvf libpng-1.6.28.tar.gz

Cd libpng-1.6.28

. / configure-prefix=/usr/local/libpng-enable-shared

Make

Make install

6. Install freetype

Cd / usr/local/src

Tar zxvf freetype-2.7.1.tar.gz

Cd freetype-2.7.1

. / configure-prefix=/usr/local/freetype-enable-shared

Make

Make install

7. Install jpeg

Cd / usr/local/src

Tar zxvf jpegsrc.v9b.tar.gz

Cd jpeg-9b

. / configure-prefix=/usr/local/jpeg-enable-shared

Make

Make install

8. Install libgd

Cd / usr/local/src

Tar zxvf libgd-2.1.1.tar.gz

Cd libgd-2.1.1

. / configure-- prefix=/usr/local/libgd-- enable-shared-- with-jpeg=/usr/local/jpeg-- with-png=/usr/local/libpng-- with-freetype=/usr/local/freetype-- with-fontconfig=/usr/local/freetype-- with-xpm=/usr/lib64-- with-tiff=/usr/local/tiff-- with-vpx=/usr/local/libvpx

Make

Make install

Note: if libgd compilation fails, you can skip it and directly use the default version 2.1.0 of the system. When compiling php, change the parameter-- with-gd=/usr/local/libgd to-- with-gd.

9. Install t1lib

Cd / usr/local/src

Tar zxvf t1lib-5.1.2.tar.gz

Cd t1lib-5.1.2

. / configure-prefix=/usr/local/t1lib-enable-shared

Make without_doc

Make install

10. Install php

Note: if the system is 64-bit, execute the following two commands, otherwise there will be an error in installing php.

\ cp-frp / usr/lib64/libltdl.so* / usr/lib/

\ cp-frp / usr/lib64/libXpm.so* / usr/lib/

Cd / usr/local/src

Tar-zvxf php-7.1.2.tar.gz

Cd php-7.1.2

Export LD_LIBRARY_PATH=/usr/local/libgd/lib

. / configure-- prefix=/usr/local/php-- with-config-file-path=/usr/local/php/etc-- with-mysqli=/usr/local/mysql/bin/mysql_config-- with-mysql-sock=/tmp/mysql.sock-- with-pdo-mysql=/usr/local/mysql-- with-gd=/usr/local/libgd-- with-png-dir=/usr/local/libpng-- with-jpeg-dir=/usr/local/jpeg-- with-freetype-dir=/usr/local / freetype-- with-xpm-dir=/usr/lib64-- with-zlib-dir=/usr/local/zlib-- with-iconv-- enable-libxml-- enable-xml-- enable-shmop-- enable-sysvsem-- enable-inline-optimization-- enable-opcache-- enable-mbregex-- enable-fpm-- enable-mbstring-- enable-ftp-- enable-gd-native-ttf-with-openssl-enable-pcntl-- enable-sockets-- with-xmlrpc-- enable -zip-enable-soap-- without-pear-- with-gettext-- enable-session-- with-mcrypt-- with-curl-- enable-ctype-- enable-mysqlnd

Make # compilation

Make install # installation

Note: if prompted by the wrong version of libgd, change the php compilation parameter-- with-gd=/usr/local/libgd to-- with-gd.

Cp php.ini-production / usr/local/php/etc/php.ini # copy the php configuration file to the installation directory

Rm-rf / etc/php.ini # Delete the configuration file that comes with the system

Ln-s / usr/local/php/etc/php.ini / etc/php.ini # add soft link to / etc directory

Cp / usr/local/php/etc/php-fpm.conf.default / usr/local/php/etc/php-fpm.conf # copy template file as php-fpm configuration file

Ln-s / usr/local/php/etc/php-fpm.conf / etc/php-fpm.conf # add a soft connection to the / etc directory

Vi / usr/local/php/etc/php-fpm.conf # editing

Pid = run/php-fpm.pid # cancel the previous semicolon

: wq! # Save exit

Cp / usr/local/php/etc/php-fpm.d/www.conf.default / usr/local/php/etc/php-fpm.d/www.conf

Vi / usr/local/php/etc/php-fpm.d/www.conf # editing

User = www # set the php-fpm running account to www

Group = www # set the php-fpm running group to www

Set php-fpm to boot

Cp / usr/local/src/php-7.1.2/sapi/fpm/init.d.php-fpm / etc/rc.d/init.d/php-fpm # copy php-fpm to the startup directory

Chmod + x / etc/rc.d/init.d/php-fpm # add execute permission

Chkconfig php-fpm on # set boot up

Vi / usr/local/php/etc/php.ini # Edit configuration file

Find: disable_functions =

Modified to: disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups Posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname

# list the functions that can be disabled by PHP. If some programs need to use this function, you can delete it and undisable it.

Find:; date.timezone =

Change it to: date.timezone = PRC # set time zone

Find: expose_php = On

Modified to: expose_php = Off # suppresses the display of php version information

Find: short_open_tag = Off

Modified to: short_open_tag = ON # supports php short tags

Find opcache.enable=0.

Modified to support opcode caching for opcache.enable=1 # php

Found:; opcache.enable_cli=1 # php supports opcode caching

Modified to: opcache.enable_cli=0

On the last line, add: zend_extension=opcache.so # to enable opcode caching

: wq! # Save exit

Configure nginx to support php

Vi / usr/local/nginx/conf/nginx.conf

To modify the / usr/local/nginx/conf/nginx.conf configuration file, the following modifications are required

The first line of user www www; # user is uncommented, and the Nginx running group is changed to www www;. It must be the same as the user,group configuration in / usr/local/php/etc/php-fpm.conf, otherwise there will be errors in php operation.

Index index.html index.htm index.php; # add index.php

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

#

Location ~\ .php$ {

Root html

Fastcgi_pass 127.0.0.1:9000

Fastcgi_index index.php

Fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name

Include fastcgi_params

}

# Uncomment part of FastCGI server location, note the parameter of fastcgi_param line, change it to $document_root$fastcgi_script_name, or use absolute path

/ etc/init.d/nginx restart # restart nginx

Service php-fpm start # launch php-fpm

Test piece

Cd / usr/local/nginx/html/ # enter the nginx default website root directory

Rm-rf / usr/local/nginx/html/* # Delete the default test page

Vi index.php # create a new index.php file

: wq! # Save exit

Chown www.www / usr/local/nginx/html/-R # sets the directory owner

Chmod 700 / usr/local/nginx/html/-R # set directory permissions

Open the server IP address in the browser and you will see the following interface

At this point, the CentOS 7.3.1611 compilation and installation Nginx1.10.3+MySQL5.7.16+PHP7.1.2 tutorial is complete.

The above is how to build a Nginx1.10.3+MySQL5.7.16+PHP7.1.2 environment in CentOS 7.3.1611. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Original link: http://www.osyunwei.com/archives/10046.html

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report