2-25 源码编译搭建LNMP环境

1.安装配置Nginx

epel源需要先装

[root@xuegod13 yum.repos.d]# rpm -ivh http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

然后装部署LNMP架构phpmyadmin需要安装依赖包:

[root@xuegod13 ~]# yum -y install make gcc gcc-c++ flex bison file libtool libtool-libs autoconf kernel-devel libjpeg libjpeg-devel libpng libpng-devel gd freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel bzip2 bzip2-devel libevent ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssl-devel gettext gettext-devel gmp-devel unzip libcap lsof

本节课涉及mysql密码忘记了怎么办到的源码包如下,上传到/opt目录

[root@xuegod13 opt]# ls -1
boost_1_59_0.tar.gz
libiconv-1.14.tar.gz
libmcrypt_downcc.zip
mcrypt-2.6.8.tar.gz
mysql-5.7.19.tar.gz
nginx-1.14.2.tar.gz
pcre-8.41.tar.gz
php-7.1.24.tar.gz

再次安装依赖包php中文网:注意,使用epel源的时候要在yum.linux是什么操作系统repo.d目录下

[root@xuegod13 yum.repos.d]# yum -y install gcc gcc-c++ autoconf automake zlib zlib-devel openssl openssl-devel pcre*

创建Nginx运行用户

[root@xuegod13 opt]# useradd -M -s /sbin/nologin nginx

解压缩pcre和nginx到/usr/local/src/下:

[root@xuegod13 opt]# ls
boost_1_59_0.tar.gz libmcrypt_downcc.zip mhash-0.9.9.9.tar.gz nginx-1.14.2.tar.gz php-7.1.24.tar.gz
libiconv-1.14.tar.gz mcrypt-2.6.8.tar.gz mysql-5.7.19.tar.gz pcre-8.41.tar.gz
[root@xuegod13 opt]# tar xf pcre-8.41.tar.gz -C /usr/local/src/
[root@xuegod13 opt]# tar xf nginx-1.14.2.tar.gz -C /usr/local/src/
[root@xuegod13 opt]# cd !$
cd /usr/local/src/
[root@xuegod13 src]# ls
nginx-1.14.2 pcre-8.41
[root@xuegod13 src]#

安装nginx:

[root@xuegod13 src]# cd nginx-1.14.2/
[root@xuegod13 nginx-1.14.2]# ls
auto CHANGES CHANGES.ru conf configure contrib html LICENSE man README src
[root@xuegod13 nginx-1.14.2]# ./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.41 --user=nginx --group=nginx
#输出内容省略
[root@xuegod13 nginx-1.14.2]# make -j 4 && make install
#输出内容省略

修改nginx配置文件

[root@xuegod13 nginx-1.14.2]# ll /usr/local/nginx/
总用量 0
drwxr-xr-x 2 root root 333 210 18:30 conf
drwxr-xr-x 2 root root 40 210 18:30 html
drwxr-xr-x 2 root root 6 210 18:30 logs
drwxr-xr-x 2 root root 19 210 18:30 sbin
[root@xuegod13 nginx]# cd conf/
[root@xuegod13 conf]# ls
fastcgi.conf koi-utf nginx.conf uwsgi_params
fastcgi.conf.default koi-win nginx.conf.default uwsgi_params.default
fastcgi_params mime.types scgi_params win-utf
fastcgi_params.default mime.types.default scgi_params.default
[root@xuegod13 conf]# cp nginx.conf nginx.conf.bak
[root@xuegod13 conf]# vim nginx.conf

改用户

#user  nobody;
改为
user nginx;

启用支持php,66-70行,去掉前面的#号

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

加载环境变量

[root@xuegod13 conf]# cd ..
[root@xuegod13 nginx]# ll sbin/
总用量 4032
-rwxr-xr-x 1 root root 4125688 210 18:30 nginx
[root@xuegod13 nginx]# vim /etc/profile.d/nginx.sh
export PATH=/usr/local/nginx/sbin:$PATH
[root@xuegod13 nginx]# . /etc/profile.d/nginx.sh
[root@xuegod13 nginx]# cd
[root@xuegod13 ~]# nginx -v #查看版本
nginx version: nginx/1.14.2

查看nginx加载了哪些模块

[root@xuegod13 ~]# nginx -V
nginx version: nginx/1.14.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
configure arguments: --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.41 --user=nginx --group=nginx

检查配置文件语法是否有错误

[root@xuegod13 ~]# 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

-T检查语法并显示更多配置nginx配置信息

[root@xuegod13 ~]# 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
# configuration file /usr/local/nginx/conf/nginx.conf:
user nginx;
worker_processes 1;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;


events {
worker_connections 1024;
}


http {
include mime.types;
default_type application/octet-stream;

#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';

#access_log logs/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;

#gzip on;

server {
listen 80;
server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
root html;
index index.html index.htm;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# 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 /scripts$fastcgi_script_name;
include fastcgi_params;
}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}


# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;

# location / {
# root html;
# index index.html index.htm;
# }
#}


# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;

# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;

# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;

# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;

# location / {
# root html;
# index index.html index.htm;
# }
#}

}

# configuration file /usr/local/nginx/conf/mime.types:

types {
text/html html htm shtml;
text/css css;
text/xml xml;
image/gif gif;
image/jpeg jpeg jpg;
application/javascript js;
application/atom+xml atom;
application/rss+xml rss;

text/mathml mml;
text/plain txt;
text/vnd.sun.j2me.app-descriptor jad;
text/vnd.wap.wml wml;
text/x-component htc;

image/png png;
image/svg+xml svg svgz;
image/tiff tif tiff;
image/vnd.wap.wbmp wbmp;
image/webp webp;
image/x-icon ico;
image/x-jng jng;
image/x-ms-bmp bmp;

application/font-woff woff;
application/java-archive jar war ear;
application/json json;
application/mac-binhex40 hqx;
application/msword doc;
application/pdf pdf;
application/postscript ps eps ai;
application/rtf rtf;
application/vnd.apple.mpegurl m3u8;
application/vnd.google-earth.kml+xml kml;
application/vnd.google-earth.kmz kmz;
application/vnd.ms-excel xls;
application/vnd.ms-fontobject eot;
application/vnd.ms-powerpoint ppt;
application/vnd.oasis.opendocument.graphics odg;
application/vnd.oasis.opendocument.presentation odp;
application/vnd.oasis.opendocument.spreadsheet ods;
application/vnd.oasis.opendocument.text odt;
application/vnd.openxmlformats-officedocument.presentationml.presentation
pptx;
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
xlsx;
application/vnd.openxmlformats-officedocument.wordprocessingml.document
docx;
application/vnd.wap.wmlc wmlc;
application/x-7z-compressed 7z;
application/x-cocoa cco;
application/x-java-archive-diff jardiff;
application/x-java-jnlp-file jnlp;
application/x-makeself run;
application/x-perl pl pm;
application/x-pilot prc pdb;
application/x-rar-compressed rar;
application/x-redhat-package-manager rpm;
application/x-sea sea;
application/x-shockwave-flash swf;
application/x-stuffit sit;
application/x-tcl tcl tk;
application/x-x509-ca-cert der pem crt;
application/x-xpinstall xpi;
application/xhtml+xml xhtml;
application/xspf+xml xspf;
application/zip zip;

application/octet-stream bin exe dll;
application/octet-stream deb;
application/octet-stream dmg;
application/octet-stream iso img;
application/octet-stream msi msp msm;

audio/midi mid midi kar;
audio/mpeg mp3;
audio/ogg ogg;
audio/x-m4a m4a;
audio/x-realaudio ra;

video/3gpp 3gpp 3gp;
video/mp2t ts;
video/mp4 mp4;
video/mpeg mpeg mpg;
video/quicktime mov;
video/webm webm;
video/x-flv flv;
video/x-m4v m4v;
video/x-mng mng;
video/x-ms-asf asx asf;
video/x-ms-wmv wmv;
video/x-msvideo avi;
}

# configuration file /usr/local/nginx/conf/fastcgi_params:

fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;

fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REQUEST_SCHEME $scheme;
fastcgi_param HTTPS $https if_not_empty;

fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;

fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;

启动nginx

[root@xuegod13 ~]# nginx
[root@xuegod13 ~]# ps aux|grep nginx
root 42776 0.0 0.0 18236 640 ? Ss 18:50 0:00 nginx: master process nginx
nginx 42777 0.0 0.0 18604 1360 ? S 18:50 0:00 nginx: worker process
root 42779 0.0 0.0 112724 988 pts/0 S+ 18:50 0:00 grep --color=auto nginx
[root@xuegod13 ~]# netstat -an|grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
unix 3 [ ] DGRAM 22803
unix 3 [ ]

添加个脚本,并设置为开机自启动

[root@xuegod13 ~]# #生成服务启动脚本
[root@xuegod13 ~]# vim /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
[root@xuegod13 ~]# chmod +x /etc/init.d/nginx
[root@xuegod13 ~]# chkconfig --add nginx
[root@xuegod13 ~]# chkconfig nginx on

nginx -sreload|stop重新加载配置文件|停止nginx服务

2linux重启命令.mysql 5.7安装配置

MySQL从5.7版本之后,boost是必须的,建linux系统安装议把系统自带的bphp是前端还是后端oost库卸载,源码编译安装高版本

[root@xuegod13 ~]# yum -y remove boost-*
#输出内容省略

卸载系统自带的mysql

[root@xuegod13 ~]# yum -y remove mysql mariadb-*
#输出内容省略

linux命令装依赖包

[root@xuegod13 ~]# yum -y install cmake make gcc gcc-c++ bison ncurses ncurses-devel
#输出内容省略

注意:

在生成环境中,安装数据库之前,需要规划好数据存储的目录

这个目录最好是一块单独的分区或磁盘,做成raidphp是什么语言或者LVM,便于日后磁盘的维护和扩容

对于读写mysql安装比较频繁的业务,可以采用SSD等转速高的磁盘

[root@xuegod13 ~]# cd /opt/
[root@xuegod13 opt]# tar xf boost_1_59_0.tar.gz -C /usr/local/src/
[root@xuegod13 opt]# tar xf mysql-5.7.19.tar.gz -C /usr/local/src/
[root@xuegod13 opt]# cd /usr/local/src/mysql-5.7.19/
[root@xuegod13 mysql-5.7.19]# ls
BUILD configure.cmake include libmysqld packaging sql unittest
client COPYING INSTALL libservices plugin sql-common VERSION
cmake dbug libbinlogevents man rapid storage vio
CMakeLists.txt Docs libbinlogstandalone mysql-test README strings win
cmd-line-utils Doxyfile-perfschema libevent mysys regex support-files zlib
config.h.cmake extra libmysql mysys_ssl scripts testclients
[root@xuegod13 mysql-5.7.19]# cmake -DCMAKE_INSTALL_PREFIX=/var/lib/mysql -DMYSQL_DATADIR=/var/lib/mysql/data -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/src/boost_1_59_0 -DWITH_EMBEDDED_SERVER=OFF
#输出内容省略
[root@xuegod13 mysql-5.7.19]# make -j 4
#输出内容省略,20多分钟-30分钟
[root@xuegod13 mysql-5.7.19]# make install
#输出内容省略

创建配置文件

[root@xuegod13 ~]# vim /etc/my.cnf
[mysqld]
basedir=/var/lib/mysql
datadir=/var/lib/mysql/data
port=3306
socket=/var/lib/mysql/mysql.sock
character-set-server=utf8
log-error=/var/log/mysqld.log
pid-file=/tmp/mysqld.pid
[mysql]
socket=/var/lib/mysql/mysql.sock
[client]
socket=/var/lib/mysql/mysql.sock

配置环境变量

[root@xuegod13 ~]# vim /etc/profile.d/mysql.sh
export PATH=/var/lib/mysql/bin:$PATH
[root@xuegod13 ~]# . /etc/profile.d/mysql.sh

复制一下服务脚本,并赋予执行权限

[root@xuegod13 ~]# cp /var/lib/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@xuegod13 ~]# chmod +x /etc/init.d/mysqld

mysql5.7初始化

[root@xuegod13 ~]# /var/lib/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/var/lib/mysql --datadir=/var/lib/mysql/data

启动mysqmysql增删改查语句l服务,发现报错

[root@xuegod13 ~]# /etc/init.d/mysqld start
Starting MySQL.. ERROR! The server quit without updating PID file (/tmp/mysqld.pid).

也不知道具体linux哪里的问题,按照下面一顿操作就成功了

[root@xuegod13 ~]# chown mysql:mysql /var/lib/mysql/ -R
[root@xuegod13 ~]# /etc/init.d/mysqld start
Starting MySQL.. ERROR! The server quit without updating PID file (/tmp/mysqld.pid).
[root@xuegod13 ~]# mysql --version
mysql Ver 14.14 Distrib 5.7.19, for Linux (x86_64) using EditLine wrapper
[root@xuegod13 ~]# chmod +x /etc/my.cnf
[root@xuegod13 ~]# vim /etc/my.cnf
#把配置文件的=号两边都加了个空格
[root@xuegod13 ~]# /etc/init.d/mysqld start
Starting MySQL.. ERROR! The server quit without updating PID file (/tmp/mysqld.pid).
[root@xuegod13 ~]# /var/lib/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/var/lib/mysql --datadir=/var/lib/mysql/data
2022-02-10T14:25:28.904362Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-02-10T14:25:28.908320Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2022-02-10T14:25:28.908555Z 0 [ERROR] Aborting

[root@xuegod13 ~]# /var/lib/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/var/lib/mysql --datadir=/var/lib/mysql/data
2022-02-10T14:25:56.952716Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-02-10T14:25:56.954352Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2022-02-10T14:25:56.954393Z 0 [ERROR] Aborting

[root@xuegod13 ~]# ls /var/lib/mysql/data/
auto.cnf ib_buffer_pool ibdata1 ib_logfile0 ib_logfile1
[root@xuegod13 ~]# rm -f /var/lib/mysql/data/*
[root@xuegod13 ~]# /var/lib/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/var/lib/mysql --datadir=/var/lib/mysql/data
[root@xuegod13 ~]# /etc/init.d/mysqld start
Starting MySQL. SUCCESS!

然后,安全初始化,密码为12345678

[root@xuegod13 ~]# mysql_secure_installation 

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?

Press y|Y for Yes, any other key for No: y

There are three levels of password validation policy:

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
Please set the password for root here.

New password:

Re-enter new password:

Estimated strength of the password: 25
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
... Failed! Error: Your password does not satisfy the current policy requirements

New password:

Re-enter new password:

Estimated strength of the password: 50
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...
Success.

- Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.

All done!

mysql测试登录,并查看信息

[root@xuegod13 ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.19 Source distribution

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> \s;
--------------
mysql Ver 14.14 Distrib 5.7.19, for Linux (x86_64) using EditLine wrapper

Connection id: 6
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.7.19 Source distribution
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /var/lib/mysql/mysql.sock
Uptime: 8 min 51 sec

Threads: 1 Questions: 20 Slow queries: 0 Opens: 113 Flush tables: 1 Open tables: 106 Queries per second avg: 0.037
--------------

ERROR:
No query specified

mysql> \q
Bye

3.安装PHP

1.安装依赖库php

[root@xuegod13 ~]# yum -y install php-mcrypt libmcrypt libmcrypt-devel php-pear libxml2 libxml2-devel curl curl-devel libjpeg libjpeg-devel libpng libpng-devel freetype-devel
#输出内容略

2.解压PHP包并配置

[root@xuegod13 ~]# cd /opt/
[root@xuegod13 opt]# ls
boost_1_59_0.tar.gz libmcrypt_downcc.zip mhash-0.9.9.9.tar.gz nginx-1.14.2.tar.gz php-7.1.24.tar.gz
libiconv-1.14.tar.gz mcrypt-2.6.8.tar.gz mysql-5.7.19.tar.gz pcre-8.41.tar.gz
[root@xuegod13 opt]# tar zxf php-7.1.24.tar.gz -C /usr/local/src/
[root@xuegod13 opt]# cd /usr/local/src/
[root@xuegod13 src]# cd /usr/local/src/php-7.1.24/

3.编译安装

[root@xuegod13 php-7.1.24]# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/ --enable-fpm --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-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --disable-fileinfo --enable-mantainer-zts
#输出内容略
[root@xuegod13 php-7.1.24]# make -j 4
#输出内容略
[root@xuegod13 php-7.1.24]# make install
#输出内容略

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

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

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

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

--with-freetype-dir#打开对freetype字体库的支持linux必学的60个命令

--with-jpeg-dphp是什么语言ir#打开对jlinux删除文件命令peg图片的支持

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

--with-zlib#linux操作系统基础知识打开zmysql数据库lib库的支php持,实现GZIP压缩输出

--with-libxml-dir=/usrnginx重启命令linux#打开libxml2库的支持,lphp中文网ibxml是一个用来解linux重启命令析XML文档的函数

--enable-xml#支持xmysql数据库命令大全ml文档

--disable-rpa系统运维工程师th#nginx代理关闭额linux系统安装外的运行库文件

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

--enable-shm系统运维工资一般多少op#shmop共享内存操作函数,可以与c/c++通讯

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

--enable-inline-oplinux是什么操作系统timization#优化线mysql安装

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

--with-curlwrappernginx配置s#运用mysql创建表curl工具打开url流 ,新版PHP5.6已弃用

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

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

--enable-mbstrinmysql索引g#多字节,字符串的支持

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

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

--with-openssl#打开ssl支持

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

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

--enable-nginx启动命令sockets#打开socmysql索引ketmysql数据库s支持

--wmysql索引ith-xmlrpc#打开xml-rpc的c语言

--enable-zip#打开对zmysql安装ip的支持

--enable-soap#扩系统运维工资一般多少展库通过snginx重启命令linuxoap协议实现了客服端与服务器端的数据交互操作

--with-mcrypt#mcrypt算法扩展

--with-zlib-dir=/usr/local/libzlinux操作系统基础知识ip ##指定zip库路径

4.nginx重启命令linux

复制配置文件

[root@xuegod13 php-7.1.24]# cp /usr/local/src/php-7.1.24/php.ini-production /usr/local/php/php.ini

还需要拷贝一个与php-fpm相关的文件

[root@xuegod13 php-7.1.24]# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.conf

然后修改该配置文件

[root@xuegod13 php-7.1.24]# vim /usr/local/php/etc/php-fpm.conf
#23-24行用户和组都改成nginx

5.

复制启动脚本并赋予执行权限

[root@xuegod13 php-7.1.24]# cp -a /usr/local/src/php-7.1.24/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@xuegod13 php-7.1.24]# chmod +x /etc/init.d/php-fpm

设置开机自启动

[root@xuegod13 php-7.1.24]# chkconfig php-fpm on

启动php-fpm服务

[root@xuegod13 php-7.1.24]# /etc/init.d/php-fpm start
Starting php-fpm done
[root@xuegod13 php-7.1.24]# netstat -an|grep 9000
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN

测试前需要改nginx的配置文件nginx.phpstudyconf

[root@xuegod13 ~]# vim /usr/local/nginx/conf/nginx.conf
#修改配置文件68号由
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
#改为
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
[root@xuegod13 conf]# nginx -s reload

测试访问成功