mysql5.7

php7.2

php5.6

nginx1.12

centOs7.2


#安装扩展

yum install wget gcc gcc-c++ pcre-devel zlib-devel openssl openssl-devel


cd /usr/local/src/


#安装nginx

wget http://nginx.org/download/nginx-1.12.2.tar.gz


tar zxvf nginx-1.12.2.tar.gz


cd nginx-1.12.2


vi auto/cc/gcc


//注释掉这行

#CFLAGS="$CFLAGS -g"


./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_v2_module --with-http_stub_status_module --with-pcre --with-http_gzip_static_module --with-http_dav_module   --with-http_addition_module  --with-http_sub_module --with-http_flv_module  --with-http_mp4_module


#四核编译

make -j 4 && make install

#环境变量

vi /etc/profile

#增加一行

export PATH=/usr/local/nginx/sbin:$PATH

#wq!保存后执行下面命令使生效

source /etc/profile

#设置服务

ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/

#编辑启动脚本

vi /etc/init.d/nginx


#!/bin/bash

# chkconfig: - 99 2

# description: Nginx Service Control Script

PROG="/usr/local/nginx/sbin/nginx"

PIDF="/usr/local/nginx/logs/nginx.pid"

case "$1" in

        start)

        $PROG

        ;;

        stop)

        kill -3 $(cat $PIDF)

        ;;

        restart)

        $0 stop &> /dev/null

        if [ $? -ne 0 ] ; then continue ; fi

        $0 start

        ;;

        reload)

        kill -1 $(cat $PIDF)

        ;;

        *)

        echo "Userage: $0 { start | stop | restart | reload }"

        exit 1

esac

exit 0

#编辑好后wq!保存


chmod +x /etc/init.d/nginx


chkconfig --add nginx


chkconfig nginx on


#安装mysql

cd /usr/local/src/

wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm

rpm -ivh mysql57-community-release-el7-8.noarch.rpm 

yum -y install mysql-server 


yum --installroot=/usr/local/mysql --releasever=/ -y install mysql-server



默认配置文件路径: 

配置文件:/etc/my.cnf 

日志文件:/var/log/var/log/mysqld.log 

服务启动脚本:/usr/lib/systemd/system/mysqld.service 


socket文件:/var/run/mysqld/mysqld.pid


启动mysql服务

service mysqld restart

#找到初始密码

grep "password" /var/log/mysqld.log  

mysql -uroot -p

alter user 'root'@'localhost' identified by 'password'; 


grant all on *.* to 'test'@'%' identified by 'password'  with grant option;


flush privileges;

#安装php5.6

cd /usr/local/src/


wget http://cn2.php.net/distributions/php-5.6.32.tar.gz


tar zxvf php-5.6.32.tar.gz


cd php-5.6.32

#添加php-fpm用户

useradd -s /sbin/nologin php-fpm

#安装扩展

yum -y install gcc gcc-c++ libxml2 libxml2-devel bzip2 bzip2-devel libmcrypt libmcrypt-devel openssl openssl-devel libcurl-devel libjpeg-devel libpng-devel freetype-devel readline readline-devel libxslt-devel perl perl-devel psmisc.x86_64 recode recode-devel libtidy libtidy-devel  epel-release libmcrypt-devel  autoconf epel-release libmcrypt libmcrypt-devel libXpm-devel postgresql-devel


./configure  --prefix=/usr/local/php  --sysconfdir=/usr/local/php/etc  --with-config-file-path=/usr/local/php/etc/     --with-fpm-user=php-fpm   --with-fpm-group=php-fpm   --enable-fpm  --with-mysql=mysqlnd  --with-mysqli=mysqlnd  --with-pdo-mysql=mysqlnd  --with-mhash   --with-openssl  --with-zlib  --with-bz2  --with-curl  --with-libxml-dir  --with-gd  --with-jpeg-dir   --with-png-dir  --with-zlib  --enable-mbstring  --with-mcrypt  --enable-sockets  --with-iconv-dir    --enable-zip  --with-pcre-dir  --with-pear  --enable-session   --enable-gd-native-ttf   --enable-xml  --with-freetype-dir  --enable-gd-jis-conv  --enable-inline-optimization  --enable-shared   --enable-soap  --enable-bcmath  --enable-sysvmsg  --enable-sysvsem  --enable-sysvshm   --enable-mbregex  --enable-pcntl  --with-xmlrpc  --with-gettext  --enable-exif  --with-readline    --enable-ftp   

#开始安装

make -j 4 && make install

#复制配置文件和php-fpm

cp php.ini-production /usr/local/php/etc/php.ini


cp /usr/local/src/php-5.6.32/sapi/fpm/init.d.php-fpm   /etc/init.d/php-fpm


cp  /usr/local/php/etc/php-fpm.conf.default   /usr/local/php/etc/php-fpm.conf

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

chmod 755 /etc/init.d/php-fpm


chkconfig --add php-fpm


service php-fpm start


chkconfig php-fpm on

#设置环境变量

vim /etc/profile


export PATH=/usr/local/php/bin:$PATH


source /etc/profile

#测试是否正常登陆

vi /usr/local/nginx/conf/nginx.conf


 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;

        }



#扩展准备

wget https://sourceforge.net/projects/re2c/files/0.16/re2c-0.16.tar.gz


tar zxf re2c-0.16.tar.gz && cd re2c-0.16


./configure


make -j 4 && make install


#同时安装php7

#添加用户

useradd -s /sbin/nologin php-fpm72


#打开src目录

cd /usr/src

#下载安装包

wget http://cn2.php.net/get/php-7.2.3.tar.gz/from/this/mirror


tar -zxvf mirror


cd php7.2.3


#配置全都改成72,代表7.2

./configure --prefix=/usr/local/php72  --sysconfdir=/usr/local/php72/etc  --with-config-file-path=/usr/local/php72/etc/   --with-fpm-user=php-fpm72   --with-fpm-group=php-fpm72  --enable-fpm  --with-pdo-pgsql  --with-zlib-dir  --with-freetype-dir  --enable-mbstring  --with-libxml-dir=/usr  --enable-soap  --enable-calendar  --with-curl  --with-gd  --with-pgsql  --disable-rpath  --enable-inline-optimization  --with-bz2  --with-zlib  --enable-sockets  --enable-sysvsem  --enable-sysvshm  --enable-pcntl  --enable-mbregex  --enable-exif  --enable-bcmath  --with-mhash  --enable-zip  --with-pcre-regex  --with-pdo-mysql  --with-mysqli  --with-jpeg-dir=/usr  --with-png-dir=/usr  --with-openssl  --with-libdir=/lib/x86_64-linux-gnu/  --enable-ftp  --with-gettext  --with-xmlrpc  --with-xsl  --enable-opcache  --with-iconv  --with-xpm-dir=/usr


#开始安装

make -j 4 && make install

#复制配置文件和php-fpm


cp php.ini-production /usr/local/php72/etc/php.ini


cp /usr/src/php-7.2.3/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm72


#复制配置文件

cp  /usr/local/php72/etc/php-fpm.conf.default  /usr/local/php72/etc/php-fpm.conf


#复制配置文件

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


#授权

chmod 755 /etc/init.d/php-fpm72


chkconfig --add php-fpm72

#因为上面php5已经用了9000端口,需要修改监听的端口

vim /usr/local/php72/etc/php-fpm.d/www.conf


listen 9000 改为 listen 9072

wq!保存

#启动服务

service php-fpm72 start

chkconfig php-fpm72 on

php72做软连接

ln -s  /usr/local/php72/bin/php  /usr/sbin/php72

查看php版本号

php -v

php72 -v