源码编译搭建LNMP环境

LNMP源码编译

1.LNMP介绍

LNMP=Linux Nginx Mysql PHP

Nginx (“engine x”) 是一个高性能的 HTTP 和 反向代理 服务器。Nginx 是由 Igor Sysoev 为俄罗斯访问量第二的 Rambler.ru 站点开发的,第一个公开版本0.1.0发布于2004年10月4日。其将源代码以类BSD许可证的形式发布,因它的稳定性、丰富的功能集、示例配置文件和低系统资源的消耗而闻名。2011年6月1日,nginx 1.0.4发布。

Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,并在一个BSD-like 协议下发行。由俄罗斯的程序设计师Igor Sysoev所开发,供俄国大型的入口网站及搜索引擎Rambler(俄文:Рамблер)使用。其特点是占有内存少,并发能力强,事实上nginx的并发能力确实在同类型的网页服务器中表现较好,中国大陆使用nginx网站用户有:百度BWS、新浪、网易、腾讯等

2.LNMP软件所需要的软件包(准备条件)

MySQL=http://dev.mysql.com/downloads/mysql/ mysql主程序包

PHP=http://php.net/downloads.php php主程序包

Nginx=http://nginx.org/en/download.html Nginx主程序包

libmcrypt=http://mcrypt.hellug.gr/index.html libmcrypt加密算法扩展库,支持3DES等加密

或者:http://mcrypt.sourceforge.net/ MCrypt/Libmcrypt development site (secure access)

pcre=http://pcre.org/ pcre是php的依赖包

Mainline version 主线版本
Stable version 稳定版本
Legacy versions 老版本,历史版本
旧版本下载:http://mirrors.sohu.com/nginx/

3.编译安装NGINX

安装包下载,开源的软件包,选择稳定版本既可

[root@localhost ~]# wget  http://nginx.org/download/nginx-1.16.1.tar.gz

[root@localhost ~]# wget https://ftp.pcre.org/pub/pcre/pcre-8.37.tar.gz

解决依赖-在编译之前,把开发包组安装

[root@localhost ~]# yum -y groupinstall "Development Tools" "Development Libraries"

[root@localhost ~]# yum -y install gcc gcc-c++ autoconf automake zlib zlib-devel openssl openssl-devel pcre* pcre-devel

yum安装的pcre是系统依赖的pcre

Zlib:Nginx提供gzip模块,需要zlib的支持

Openssl:Nginx提供SSL的功能

解压安装包

[root@localhost ~]# tar -xf pcre-8.37.tar.gz -C /usr/local/src/

//解压此安装包即可,不需要安装,Nginx需要指定pcre的源码不是安装后的路径,此包的功能是支持地址重写rewrite功能 pcre的依赖可以yum安装pcre和pcre-devel解决!

[root@localhost ~]# tar -xf nginx-1.16.1.tar.gz -C /usr/local/src/

[root@localhost ~]# cd /usr/local/src/nginx-1.16.1/

[root@localhost nginx-1.16.1]# ./configure --prefix=/usr/local/nginx --with-http_dav_module --with-http_stub_status_module --with-http_addition_module --with-http_sub_module --with-http_flv_module --with-http_mp4_module --with-pcre=/usr/local/src/pcre-8.37

***********************************参数解释***********************************

--with-http_dav_module                  #启用支持(增加PUT,DELETE,MKCOL:创建集合,COPY和MOVE方法)

                                    默认关闭,需要编译开启

--with-http_stub_status_module    #启用支持(获取Nginx上次启动以来的工作状态)

--with-http_addition_module         #启用支持(作为一个输出过滤器,支持不完全缓冲,分部分相应请求)

--with-http_sub_module                 #启用支持(允许一些其他文本替换Nginx相应中的一些文本)

--with-http_flv_module                   #启用支持(提供支持flv视频文件支持)

--with-http_mp4_module                      #启用支持(提供支持mp4视频文件支持,提供伪流媒体服务端支持)

--with-pcre=/usr/local/src/pcre-8.37   #需要注意,这里指的是源码,用#./configure --help |grep pcre查看帮助

安装

[root@localhost nginx-1.16.1]# make -j `grep processor /proc/cpuinfo | wc -l` && make install

创建用于运行的用户nginx

[root@localhost nginx-1.16.1]# useradd -M -s /sbin/nologin -u 1500  nginx

查看nginx的目录结构

[root@localhost nginx-1.16.1]# ll /usr/local/nginx

总用量 4

drwxr-xr-x. 2 root root 4096 11月  1 18:49 conf    #Nginx相关配置文件

drwxr-xr-x. 2 root root   40 11月  1 18:49 html     #网站根目录

drwxr-xr-x. 2 root root    6 11月  1 18:49 logs     #日志文件

drwxr-xr-x. 2 root root   19 11月  1 18:49 sbin     #Nginx启动脚本

配置Nginx支持php文件

[root@localhost conf]# vim nginx.conf         #nginx主配置文件

user  nginx  nginx;  #程序运行的属主与属组

....

....

......

        #access_log  logs/host.access.log  main;

        location / {

            root   html;

            index index.php  index.html index.htm;     添加index.php

        }

.....

....

....

        #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;

        #}

以上的注释全部去掉

如下

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;

        }

改完保存退出

启动nginx

[root@localhost conf]# /usr/local/nginx/sbin/nginx

配置环境变量

[root@localhost conf]# vim /etc/profile

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

[root@localhost conf]# source /etc/profile

Nginx维护命令

[root@localhost conf]# nginx -t    #检查配置文件语法是否有错误

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok

nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

[root@localhost conf]# nginx -s reload   #重新加载配置文而建(平滑重启)

[root@localhost conf]# nginx -s stop   #停止Nginx,注意:启动没有任何参数

[root@localhost conf]# echo "/usr/local/nginx/sbin/nginx &" >> /etc/rc.local  #

开机启动

平滑重启(保持了C-S链接,不断开,服务器只是重新加载了配置文件,没有开启和关闭的服务器的一个动作)

使用浏览器测试

配置nginx开机启动

切换到/lib/systemd/system/目录,创建nginx.service文件vim nginx.service

# cd /lib/systemd/system/

# vim nginx.service

文件内容如下:

[Unit]

Description=nginx

After=network.target

   

[Service]

Type=forking

ExecStart=/usr/local/nginx/sbin/nginx

ExecReload=/usr/local/nginx/sbin/nginx reload

ExecStop=/usr/local/nginx/sbin/nginx quit

PrivateTmp=true

   

[Install]

WantedBy=multi-user.target

退出并保存文件,执行systemctl enable nginx.service使nginx开机启动

# systemctl enable nginx.service

# systemctl start nginx.service    启动nginx

# systemctl stop nginx.service    结束nginx

# systemctl restart nginx.service    重启nginx

启动nginx服务时如果遇到这个错误 Job for nginx.service failed because the control process exited with error code. See “systemctl stat 可能原因如下:

1.nginx配置文件有错误运行下面命令查看修改

# nginx -t

2.已经启动nginx或者配置文件中的端口号被占用

检查端口是否被占用

# netstat -tnlp

如果端口已经被占用,自己权衡一下是换个端口还是把占用端口的进程杀掉

检查nginx是否已经启动

# ps -aux | grep nginx

如果已经启动使用下面命令干掉即可

# pkill -9 nginx

4.编译安装MYSQL

检查是否有安装mysql数据库

[root@localhost ~]# rpm -qa |grep mysql

[root@localhost ~]# rpm -qa | grep mariadb

[root@localhost ~]# yum -y  remove `rpm -qa | grep mariadb`

解决依赖

[root@localhost ~]# yum install -y  gcc-c++ ncurses-devel perl-Data-Dumperpython-devel openssl openssl-devel

[root@localhost ~]#yum -y install perl perl-devel autoconf

[root@localhost ~]#yum -y install zlib zlib-devel cmake ncurses ncurses-devel bison bison-devel

安装boost

如果安装的MySQL5.7及以上的版本,在编译安装之前需要安装boost,因为高版本mysql需要boots库的安装才可以正常运行。否则会报CMake Error at cmake/boost.cmake:81错误

下载boost

[root@localhost~]#wget http://www.sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz

[root@localhost~]#tar -xf boost_1_59_0.tar.gz  -C /usr/local/

[root@localhost~]# mv /usr/local/boost_1_59_0/ /usr/local/boost

在预编译安装MySQL时要加上-DWITH_BOOST=/usr/local/boost

下载mysql

[root@localhost~]#wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.28.tar.gz

解压到指定目录

[root@localhost ~]#tar -xf mysql-5.7.28.tar.gz -C /usr/local && cd /usr/local/mysql-5.7.28

创建mysql运行用户

[root@localhost ~]# useradd -M -s /sbin/nologin mysql    

 **预编译**

[root@localhost mysql-5.7.28]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql  \

> -DWITH_BOOST=/usr/local/boost \

> -DMYSQL_UNIX_ADDR=/usr/local/mysql/tmp/mysql.sock \

> -DMYSQL_DATADIR=/usr/local/mysql/data \

> -DDEFAULT_CHARSET=utf8 \

> -DDEFAULT_COLLATION=utf8_general_ci \

> -DWITH_EXTRA_CHARSETS=all \

> -DWITH_MYISAM_STORAGE_ENGINE=1 \

> -DWITH_INNOBASE_STORAGE_ENGINE=1 \

> -DWITH_MEMORY_STORAGE_ENGINE=1 \

> -DWITH_READLINE=1 \

> -DWITH_INNODB_MEMCACHED=1 \

> -DWITH_DEBUG=OFF \

> -DWITH_ZLIB=bundled \

> -DENABLED_LOCAL_INFILE=1 \

> -DENABLED_PROFILING=ON \

> -DMYSQL_MAINTAINER_MODE=OFF \

> -DMYSQL_TCP_PORT=3306  \

> -DMYSQL-USER=mysql

*************************参数解释*******************************

DCMAKE_INSTALL_PREFIX                                      #制定mysql的安装根目录,目录在安装的时候会自动创建,这个值也可以在服务器启动时,用--basedir来设置

DMYSQL_UNIX_ADDR                                           #服务器与本地客户端进行通信的Unix套接字文件,必须是绝对路径,默认位置/tmp/mysql.sock,可以在服务器启动时,用--socket改变

DDEFAULT_CHARSET                        #mysql默认使用的字符集,不指定将默认使用Latin1西欧字符集

DDEFAULT_COLLATION                           #默认字符校对

DWITH_EXTRA_CHARSETS                  #制定mysql拓展字符集,默认值也是all支持所有的字符集

DWITH_MYISAM_STORAGE_ENGINE

DWITH_INNOBASE_STORAGE_ENGINE

DWITH_MEMORY_STORAGE_ENGINE

#静态编译MYISAM,INNOBASE,MEMORY存储引擎到MYSQL服务 器,这样MYSQL就支持这三种存储引擎

DWITH_READLINE                    #支持readline库

DENABLED_LOCAL_INFILE                    #允许本地倒入数据,启用加载本地数据

DMYSQL_DATADIR                                #mysql数据库存放路径

DMYSQL-USER                                    #运行mysql的用户

编译&安装

[root@localhost mysql-5.7.28]# make -j `grep processor /proc/cpuinfo | wc -l` && make install

配置文件

[root@localhost mysql-5.7.28]# mkdir -p /usr/local/mysql/{data,tmp,run}

[root@localhost mysql-5.7.28]# chown -R mysql.mysql /usr/local/mysql/

[root@localhost ~]#vim /etc/my.cnf

[client]

default-character-set=utf8

socket=/usr/local/mysql/run/mysql.sock

[mysql]

port=3306

socket=/usr/local/mysql/run/mysql.sock

[mysqld]

# skip-name-resolve

# skip-external-locking

max_connections=300

log_timestamps=SYSTEM

# GENERAL #

user=mysql

port=3306

character_set_server=utf8

collation-server=utf8_general_ci

default_storage_engine=InnoDB

basedir=/usr/local/mysql/

datadir=/usr/local/mysql/data

pid-file=/usr/local/mysql/run/mysqld.pid

socket=/usr/local/mysql/run/mysql.sock

sql_mode='NO_ENGINE_SUBSTITUTION'

修改启动脚本

[root@localhost mysql-5.7.28]#cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

[root@localhost mysql-5.7.28]# vim /etc/init.d/mysqld

 //更改启动脚本中指定mysql位置

 basedir=

datadir=

#修改为

basedir=/usr/local/mysql

datadir=/usr/local/mysql/data

初始化数据库

[root@localhost mysql-5.7.28]# /usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql --initialize-insecure

 

配置mysql服务

[root@localhost mysql-5.7.28]# chkconfig --add mysqld         #添加到系统服务

[root@localhost mysql-5.7.28]# chkconfig mysqld on             #设置开机自启

启动服务

[root@localhost mysql-5.7.28]# service mysqld start   #启动

Starting MySQL.Logging to '/usr/local/mysql/data/localhost.localdomain.err'.

........... SUCCESS!

[root@localhost mysql-5.7.28]#service mysqld  restart    #重启

[root@localhost mysql-5.7.28]#service mysqld  stop       #停止

设置环境变量

[root@localhost mysql-5.7.28]# vim /etc/profile

添加下面的内容到最后

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

保存退出

[root@localhost mysql-5.7.28]# source /etc/profile

登录服务,设置密码

[root@localhost mysql-5.7.28]# mysql

mysql> set password for root@localhost =password('Admin123!@#');

mysql> flush privileges;

退出用新密码登录

mysql> exit

5.编译安装PHP

Nginx中,我们使用的是php-fpm来对php页面解析,PHP-FPM其实是PHP源代码的一个补丁,指在将FastCGI进程管理整合进PHP包中。必须将它patch到你的PHP源代码中,再编译安装PHP后才可以使用

PHP5.3.3开始,PHP中直接整合了PHP-FPM,所以从PHP5.3.3版本以后,不需要下载PHP-FPM补丁包了,下面是PHP-FPM官方发出来的通知:

http://php-fpm.org/download

https://www.php.net/releases/index.php

解决依赖

 [root@localhost ~]# yum -y install php-pear

PHP添加libmcrypt拓展

[root@localhost~]# wget https://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz

安装加密算法扩展库

[root@localhost ~]# tar -xf libmcrypt-2.5.8.tar.gz -C /usr/local/src/ && cd /usr/local/src/libmcrypt-2.5.8

[root@localhost libmcrypt-2.5.8]# ./configure --prefix=/usr/local/libmcrypt && make && make install && cd /root

 

除开上面的依赖解决之外,还需要安装图片,xml,字体支持基本库,使用yum去安装,安装的时候,这些软件包自
身也有依赖!

[root@localhost ~]# yum -y install libxml2-devel libcurl-devel libjpeg-devel libpng-devel freetype freetype-devel libzip libzip-devel

需要添加到库文件路径
由于系统默认规定只在/lib、/lib64、/lib/lib64下面找库文件,所以我们需要手动添加进去。

[root@localhost ~]# vim /etc/ld.so.conf

include ld.so.conf.d/*.conf                          #此行原有

/usr/local/libmcrypt/lib                       #此行添加

/usr/local/mysql/lib                           #此行添加

 [root@localhost ~]# ldconfig

[root@localhost ~]# echo 'ldconfig' >> /etc/rc.local

[root@localhost ~]# wget https://www.php.net/distributions/php-7.3.4.tar.gz

[root@localhost ~]# tar -xf php-7.3.4.tar.gz -C /usr/local/src/

[root@localhost ~]# cd /usr/local/src/php-7.3.4/

[root@localhost php-7.3.4]# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --with-gd --enable-mysqlnd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --with-gettext --with-mcrypt=/usr/local/libmcrypt

[root@localhost php-7.3.4]#make -j `grep processor /proc/cpuinfo | wc -l` && make install

###################################参数解释####################################

--with-config-file-path                         #设置 php.ini 的搜索路径。默认为 PREFIX/lib

--with-mysql                        #mysql安装目录,对mysql的支持

--with-mysqli                         #mysqli扩展技术不仅可以调用MySQL的存储过程、处理MySQL事务,而且还可以使访问数据库工作变得更加稳定。是一个数据库驱动

--with-iconv-dir                      #种字符集间的转换

--with-freetype-dir                  #打开对freetype字体库的支持

--with-jpeg-dir                      #打开对jpeg图片的支持

--with-png-dir                          #打开对png图片的支持

--with-zlib                        #打开zlib库的支持,实现GZIP压缩输出     

--with-libxml-dir=/usr                     #打开libxml2库的支持,libxml是一个用来解析XML文档的函数库

--enable-xml                        #支持xml文档

--disable-rpath                         #关闭额外的运行库文件

--enable-bcmath                      #打开图片大小调整,用到zabbix监控的时候用到了这个模块

--enable-shmop                       #shmop共享内存操作函数,可以与c/c++通讯

--enable-sysvsem  #加上上面shmop,这样就使得你的PHP系统可以处理相关的IPC函数(活动在内核级别)。

--enable-inline-optimization       #优化线程

--with-curl                            #打开curl浏览工具的支持

--with-curlwrappers                    #运用curl工具打开url流 ,新版PHP5.6已弃用

--enable-mbregex                    #支持多字节正则表达式

--enable-fpm                       #CGI方式安装的启动程序,PHP-FPM服务

--enable-mbstring                     #多字节,字符串的支持

--with-gd                             #打开gd库的支持,是php处理图形的扩展库,GD库提供了一系列用来处理图片的API,使用GD库可以处理图片,或者生成图片。

--enable-gd-native-ttf                    #支持TrueType字符串函数库

--with-openssl                          #打开ssl支持

--with-mhash                       #支持mhash算法扩展

--enable-pcntl                          #freeTDS需要用到的,pcntl扩展可以支持php的多线程操作

--enable-sockets                       #打开 sockets 支持

--with-xmlrpc                       #打开xml-rpc的c语言

--enable-zip                         #打开对zip的支持

--enable-soap                          #扩展库通过soap协议实现了客服端与服务器端的数据交互操作

--with-mcrypt                       #mcrypt算法扩展

--with-zlib-dir=/usr/local/libzip   ##指定zip库路径

如果上面在make的时候 提示libzip相关的报错,可以安装下面的方法来解决:

执行 make clean

然后 安装压缩支持库

[root@localhost ~]#tar xf libzip-1.1.2.tar.gz -C /usr/local/src/

[root@localhost ~]#cd /usr/local/src/libzip-1.1.2/

[root@localhost libzip-1.1.2]#./configure --prefix=/usr/local/libzip && make && make install

 

再重新编译:

[root@localhost php-7.3.4]#./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex  --enable-fpm --enable-mbstring --with-gd --enable-mysqlnd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --with-gettext --with-mcrypt=/usr/local/libmcrypt   --with-pcre-dir=/usr/local/src/pcre-8.37/ --with-zlib-dir=/usr/local/libzip

 

配置php和php-fpm

PHP配置文件:

[root@localhost php-7.3.4]# cp /usr/local/src/php-7.3.4/php.ini-production /usr/local/php/php.ini

 

PHP-FPM配置文件:

[root@localhost php-7.3.4]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

 

修改 /usr/local/php/etc/php-fpm.conf 运行用户和组改为nginx

[root@localhost php-fpm.d]# vim php-fpm.conf

; Unix user/group of processes

; Note: The user is mandatory. If the group is not set, the default user's group

;       will be used.

user = nginx   #修改成nginx

group = nginx  #nginx

将这个路径下的文件/usr/local/php/etc/php-fpm.d,重命名为php-fpm.conf

 

PHP-FPM启动脚本

[root@localhost php-7.3.4]# cp /usr/local/src/php-7.3.4/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

[root@localhost php-7.3.4]# chmod +x /etc/init.d/php-fpm

[root@localhost php-7.3.4]# chkconfig php-fpm on

启动

[root@localhost php-fpm.d]# /etc/init.d/php-fpm start

Starting php-fpm  done

[root@localhost php-fpm.d]# ps -uax |grep php

root      86264  0.0  0.1 219888  4364 ?        Ss   21:32   0:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)

nginx     86265  0.0  0.0 219888  3916 ?        S    21:32   0:00 php-fpm: pool www

nginx     86266  0.0  0.0 219888  3916 ?        S    21:32   0:00 php-fpm: pool www

root      86268  0.0  0.0 112728   972 pts/1    S+   21:32   0:00 grep --color=auto php

 

测试LNMP的PHP支持

[root@localhost html]# vim index.php

<?php

phpinfo();

?>

 

 

Php版本 和linux命令如果不一致:

find / -name php

/var/lib/php

/usr/bin/php

/usr/lib64/php

/usr/share/swig/2.0.10/php

/usr/share/php

/usr/include/php-zts/php

/usr/include/php

/usr/local/bin/php

/usr/local/include/php

/usr/local/lib/php

/usr/local/php

/selftemp/php-5.4.17/ext/pcntl/sapi/cli/php

2.查看列出的php的版本信息

/usr/local/bin/php -v

PHP 5.4.17 (cli) (built: Sep 21 2017 10:27:13) 

Copyright (c) 1997-2013 The PHP Group

Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

/usr/bin/php -v

PHP 7.2.6 (cli) (built: Jun  2 2018 07:49:42) ( NTS )

Copyright (c) 1997-2018 The PHP Group

Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

with Zend OPcache v7.2.6, Copyright (c) 1999-2018, by Zend Technologies

3.因为5.4.17版本php在/usr/local/bin/下,所以删除/usr/local/bin/目录下的所有PHP相关的目录或文件

cd /usr/local/bin/

ls

courierauthconfig  c_rehash  parl     par.pl  peardev  phantomjs  phar.phar  php-cgi     phpize  scandeps.pl  zipdetails

crc32              openssl   parldyn  pear    pecl     phar       php        php-config  pp      tkpp

rm -rf ./php

rm -rf ./php-cgi

rm -rf ./php-config

4.环境变量中加上正确PHP版本的路径

vim /etc/profile

文件末尾加上 export PATH="/usr/local/php/bin:$PATH"

5.执行

source /etc/profile

6.如果不出错则再次查看php版本如果是7则说明成功了

php -v

PHP 7.2.6 (cli) (built: Jun  2 2018 07:49:42) ( NTS )

Copyright (c) 1997-2018 The PHP Group

Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

with Zend OPcache v7.2.6, Copyright (c) 1999-2018, by Zend Technologies

7.如果报错没有sokcet函数,stream_socket_server() has been disabled for security...

编辑php.ini把disable_functions=...中找到stream_socket_server()、stream_socket_client,删除掉,重新启动web组件

其他可能用到的知识点:

查找php.ini配置文件 :find / -name php.ini

/etc/php.ini

查看PHP加载的是哪个配置文件,这个获取的是系统内的php.ini 的位置。不是网页apache加载的php.ini文件

php -i | grep php.ini

Configuration File (php.ini) Path => /usr/local/lib

 

6.远程连接数据库

授予全部权限 所有库的所有表 用户名为root 密码为123456

mysql > grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;

mysql > grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;


刷新MySQL的系统权限相关表,在不重启MySQL服务的情况下直接生效

mysql>flush privileges;

猜你喜欢

转载自www.cnblogs.com/suli0827/p/12016336.html