• 源码编译安装LNMP


    目录

    LNMP包含:

    LNMP的工作原理 :

    编译安装: 

    nginx服务器配置

    安装依赖包 

     创建用户

    上传软件包至/opt目录下并解压

     编译安装

    设置软链接,可以直接调用nginx命令来进行管理

     添加Nginx系统服务

    配置Nginx支持php解析(7 8 9 的操作是在配置完后面的mysql和php才开始的) 

    ​编辑 ​编辑

    验证php测试页

    动态页面

    静态页面

    在本服务器中安装NFS

    挂载目录

    php服务器进行操作

     验证mysql测试页

    Mysql服务器配置 

    上传压缩包至/opt目录中并解压 

    安装环境依赖包 

     创建用户

    配置软件模块

    编译安装 

    清除mariadb缓存 

    修改mysql配置文件

    更换mysql配置文件和安装目录的属主属组

    在环境变量中添加mysql的bin和lib目录

    mysql初始化操作

    添加mysqld系统服务

    修改mysql密码 

    授权并刷新 

    php服务器配置 

     上传压缩包至/opt目录中并解压

    ​编辑

    安装环境依赖包

    配置软件模块

    编译安装

    路径优化

    修改php配置文件(共三个)

    修改主配置文件 

    修改进程服务配置文件 

    ​编辑

    修改扩展配置文件

    ​编辑​编辑​编辑创建用户

    启动php-fpm

    安装论坛 

    上传压缩包到Nginx服务器的/opt目录下并解压 

    设置属主属组

    ​编辑创建数据库 


    LNMP包含

    linux、Nginx、Mysql、php

    LNMP的工作原理 :

    由客户端发送页面请求给Nginx,Nginx会根据location匹配用户访问请求的URL路径判断是静态还是动态,静态的一般是以 .html .htm .css .shtml结尾,动态的一般是以 .php .jsp .py结尾。

    如果是静态,由Nginx直接处理和响应。如果是动态,Nginx会通过fastcgi接口转发给php-fpm进程接受,

    然后再由php解析器处理解释动态页面后响应返回给Nginx,Nginx再返回给客户端。如果动态页面涉及到数据库的读写,php会通过程序代码访问,mysql的api接口,并使用sql语句进行数据库的速写操作

    编译安装: 

    三台虚拟机,Nginx服务器,Mysql服务器,php服务器。

    三台虚拟机系统初始化 :

    1. [root@l1 ~]# systemctl stop firewalld
    2. [root@l1 ~]# setenforce 0
    3. [root@l1 ~]#
    1. [root@l2 ~]# systemctl stop firewalld
    2. [root@l2 ~]# setenforce 0
    3. [root@l2 ~]#
    1. [root@l3 ~]# systemctl stop firewalld
    2. [root@l3 ~]# setenforce 0
    3. [root@l3 ~]#

    nginx服务器配置

    安装依赖包 
    1. [root@l1 ~]# df
    2. 文件系统 1K-块 已用 可用 已用% 挂载点
    3. devtmpfs 480736 0 480736 0% /dev
    4. tmpfs 497816 0 497816 0% /dev/shm
    5. tmpfs 497816 14912 482904 3% /run
    6. tmpfs 497816 0 497816 0% /sys/fs/cgroup
    7. /dev/mapper/centos-root 38770180 5435772 33334408 15% /
    8. /dev/sda1 1038336 177472 860864 18% /boot
    9. tmpfs 99564 32 99532 1% /run/user/0
    10. /dev/sr0 4635056 4635056 0 100% /mnt
    11. [root@l1 ~]# yum -y install pcre-devel zlib-devel openssl-devel gcc gcc-c++ make
    12. //安装依赖包
     创建用户
    1. [root@l1 ~]# useradd -M -s /sbin/nologin nginx //创建用户
    2. [root@l1 ~]# cat /etc/passwd | grep nginx:
    3. nginx:x:1001:1001::/home/nginx:/sbin/nologin
    4. [root@l1 ~]#
    上传软件包至/opt目录下并解压

    ​ 

    1. [root@l1 opt]# ls
    2. nginx-1.26.0.tar.gz rh
    3. [root@l1 opt]# tar xf nginx-1.26.0.tar.gz //解压
    4. [root@l1 opt]# ls
    5. nginx-1.26.0 nginx-1.26.0.tar.gz rh
    6. [root@l1 opt]# cd nginx-1.26.0/
    7. [root@l1 nginx-1.26.0]#
     编译安装
    1. ./configure \
    2. --prefix=/usr/local/nginx \
    3. --user=nginx \
    4. --group=nginx \
    5. --with-http_stub_status_module
    [root@l1 nginx-1.26.0]#  ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module  --with-http_ssl_module
    [root@l1 nginx-1.26.0]# make -j4 && make install
    设置软链接,可以直接调用nginx命令来进行管理
    1. [root@l1 nginx-1.26.0]# cd /usr/local/nginx/
    2. [root@l1 nginx]# ls sbin/
    3. nginx
    4. [root@l1 nginx]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/ //软连接
    5. [root@l1 nginx]# nginx -t
    6. nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
    7. nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
    8. [root@l1 nginx]#
     添加Nginx系统服务
    1. [root@l1 nginx]# cd /usr/lib/systemd/system
    2. [root@l1 system]# vim nginx.service

     

    1. [Unit]
    2. Description=nginx
    3. After=network.target
    4. [Service]
    5. Type=forking
    6. PIDFile=/usr/local/nginx/logs/nginx.pid
    7. ExecStart=/usr/local/nginx/sbin/nginx
    8. ExecReload=/bin/kill -s HUP $MAINPID
    9. ExecStop=/bin/kill -s QUIT $MAINPID
    10. PrivateTmp=true
    11. [Install]
    12. WantedBy=multi-user.target
    1. [root@l1 system]# systemctl daemon-reload
    2. [root@l1 system]# systemctl start nginx
    3. [root@l1 system]# systemctl enable nginx
    4. Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
    5. [root@l1 system]# netstat -lntp | grep nginx
    6. tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 10947/nginx: master
    7. [root@l1 system]#
    配置Nginx支持php解析(7 8 9 的操作是在配置完后面的mysql和php才开始的) 
    1. [root@l1 nginx]# cd /usr/local/nginx/
    2. [root@l1 nginx]# cd conf/
    3. [root@l1 conf]# ls
    4. fastcgi.conf koi-win scgi_params
    5. fastcgi.conf.default mime.types scgi_params.default
    6. fastcgi_params mime.types.default uwsgi_params
    7. fastcgi_params.default nginx.conf uwsgi_params.default
    8. koi-utf nginx.conf.default win-utf
    9. [root@l1 conf]# vim nginx.conf
    10. [root@l1 conf]#

     

     

     

    1. [root@l1 conf]# nginx -t
    2. nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
    3. nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
    4. [root@l1 conf]#

    验证php测试页

    动态页面
    1. [root@l1 conf]# mkdir -p /var/www/html
    2. [root@l1 conf]# cd /var/www/html/
    3. [root@l1 html]# vim test.php
    4. [root@l1 html]#

    静态页面
    1. [root@l1 html]# cd /usr/local/nginx/html/
    2. [root@l1 html]# ls
    3. 50x.html index.html
    4. [root@l1 html]# rz -E
    5. rz waiting to receive.
    6. [root@l1 html]# vim m.html
    7. [root@l1 html]# ls
    8. 50x.html index.html m.html w.jpg
    9. [root@l1 html]#

     

    此时动态页面现在是查不到的,静态页面是由Nginx直接处理和响应的,而动态页面是Nginx通过fastcgi接口转发给php-fpm进程接受,然后再由php解析器处理解释动态页面后响应返回给Nginx,Nginx再返回给客户端的,所以我们要在将动态页面位置也放入到php服务器中

    在本服务器中安装NFS

    yum安装rbcbind和nfs-utils

    [root@l1 html]# vim /etc/exports
    

    1. [root@l1 html]# systemctl --now enable rpcbind nfs
    2. Created symlink from /etc/systemd/system/multi-user.target.wants/nfs-server.service to /usr/lib/systemd/system/nfs-server.service.
    3. [root@l1 html]# showmount -e
    4. Export list for l1:
    5. /var/www/html 192.168.18.0/24
    6. [root@l1 html]#
    挂载目录
    [root@localhost opt]# vim /etc/fstab
    

    php服务器进行操作

    能查到我们Nginx服务器共享的目录

    1. [root@localhost ~]# showmount -e 192.168.18.10
    2. Export list for 192.168.18.10:
    3. /var/www/html 192.168.18.0/24
    4. [root@localhost ~]#

    挂载目录 

    1. [root@localhost ~]# vim /etc/fstab
    2. [root@localhost ~]# mkdir -p /var/www/html
    3. [root@localhost ~]# mount -a
    4. [root@localhost ~]# df -h
    5. 文件系统 容量 已用 可用 已用% 挂载点
    6. devtmpfs 470M 0 470M 0% /dev
    7. tmpfs 487M 0 487M 0% /dev/shm
    8. tmpfs 487M 8.5M 478M 2% /run
    9. tmpfs 487M 0 487M 0% /sys/fs/cgroup
    10. /dev/mapper/centos-root 37G 5.1G 32G 14% /
    11. /dev/sda1 1014M 174M 841M 18% /boot
    12. tmpfs 98M 60K 98M 1% /run/user/0
    13. /dev/sr0 4.5G 4.5G 0 100% /mnt
    14. 192.168.18.10:/var/www/html 37G 5.3G 32G 15% /var/www/html
    15. [root@localhost ~]#
    1. [root@localhost ~]# ls /var/www/html/ //查看目录,显示成功
    2. test.php
    3. [root@localhost ~]#

     

     验证mysql测试页

     随便在nginx还是php服务器的/var/www/html目录下创建一个mysql.php文件

    我这是在php服务器创建的,文件里面的IP地址是mysql服务器的IP地址

    1. [root@localhost php-7.1.10]# cd /var/www/html/
    2. [root@localhost html]# ls
    3. test.php
    4. [root@localhost html]# vim mysql.php
    5. [root@localhost html]#

    1. $link=mysqli_connect('192.168.18.20','root','abc123');
    2. if($link) echo "

      mysql connect successful

      "
      ;
    3. else echo "

      mysql connect failed

      "
      ;
    4. ?>

     


    Mysql服务器配置 

    上传压缩包至/opt目录中并解压 
    1. [root@l2 ~]# cd /opt
    2. [root@l2 opt]# ls
    3. abc.txt cywl cywl.txt rh
    4. [root@l2 opt]# rz -E
    5. rz waiting to receive.
    6. [root@l2 opt]# ls
    7. abc.txt cywl cywl.txt mysql-boost-5.7.44.tar.gz rh

     

    1. [root@l2 opt]# tar xf mysql-boost-5.7.44.tar.gz //解压
    2. [root@l2 opt]# ls
    3. abc.txt cywl cywl.txt mysql-5.7.44 mysql-boost-5.7.44.tar.gz rh
    4. [root@l2 opt]# cd mysql-5.7.44/
    安装环境依赖包 
    1. [root@l2 mysql-5.7.44]# mount /dev/sr0 /mnt/
    2. mount: /dev/sr0 写保护,将以只读方式挂载
    3. [root@l2 mysql-5.7.44]# df
    4. 文件系统 1K-块 已用 可用 已用% 挂载点
    5. devtmpfs 1913548 0 1913548 0% /dev
    6. tmpfs 1930628 0 1930628 0% /dev/shm
    7. tmpfs 1930628 12528 1918100 1% /run
    8. tmpfs 1930628 0 1930628 0% /sys/fs/cgroup
    9. /dev/mapper/centos-root 38770180 6265016 32505164 17% /
    10. /dev/sda1 1038336 191100 847236 19% /boot
    11. tmpfs 386128 12 386116 1% /run/user/42
    12. tmpfs 386128 0 386128 0% /run/user/0
    13. /dev/sr0 4635056 4635056 0 100% /mnt
    14. [root@l2 mysql-5.7.44]# yum -y install gcc gcc-c++ ncurses ncurses-devel bison cmake openssl-devel
     创建用户
    1. [root@zx3 mysql-5.7.44]# useradd -M -s /sbin/nologin mysql
    2. [root@zx3 mysql-5.7.44]# cat /etc/passwd | grep mysql:
    3. mysql:x:1001:1001::/home/mysql:/sbin/nologin
    4. [root@zx3 mysql-5.7.44]#
    配置软件模块
    1. [root@l2 mysql-5.7.44]# cmake \
    2. > -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
    3. > -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
    4. > -DSYSCONFDIR=/etc \
    5. > -DSYSTEMD_PID_DIR=/usr/local/mysql \
    6. > -DDEFAULT_CHARSET=utf8 \
    7. > -DDEFAULT_COLLATION=utf8_general_ci \
    8. > -DWITH_EXTRA_CHARSETS=all \
    9. > -DWITH_INNOBASE_STORAGE_ENGINE=1 \
    10. > -DMYSQL_DATADIR=/usr/local/mysql/data \
    11. > -DWITH_BOOST=boost \
    12. > -DWITH_SYSTEMD=1
    1. cmake \
    2. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
    3. -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
    4. -DSYSCONFDIR=/etc \
    5. -DSYSTEMD_PID_DIR=/usr/local/mysql \
    6. -DDEFAULT_CHARSET=utf8 \
    7. -DDEFAULT_COLLATION=utf8_general_ci \
    8. -DWITH_EXTRA_CHARSETS=all \
    9. -DWITH_INNOBASE_STORAGE_ENGINE=1 \
    10. -DMYSQL_DATADIR=/usr/local/mysql/data \
    11. -DWITH_BOOST=boost \
    12. -DWITH_SYSTEMD=1
    编译安装 
    [root@l2 mysql-5.7.44]# make -j 4 && make install
    
    清除mariadb缓存 
    [root@l2 mysql-5.7.44]# yum remove -y mariadb*
    
    修改mysql配置文件
    [root@l2 mysql-5.7.44]# vim /etc/my.cnf
    

    1. [client]
    2. port = 3306
    3. socket=/usr/local/mysql/mysql.sock
    4. [mysqld]
    5. user = mysql
    6. basedir=/usr/local/mysql
    7. datadir=/usr/local/mysql/data
    8. port = 3306
    9. character-set-server=utf8
    10. pid-file = /usr/local/mysql/mysqld.pid
    11. socket=/usr/local/mysql/mysql.sock
    12. bind-address = 0.0.0.0
    13. skip-name-resolve
    14. max_connections=2048
    15. default-storage-engine=INNODB
    16. max_allowed_packet=16M
    17. server-id = 1
    18. sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,PIPES_AS_CONCAT,ANSI_QUOTES
    更换mysql配置文件和安装目录的属主属组
    1. [root@l2 mysql-5.7.44]# chown mysql:mysql /etc/my.cnf
    2. [root@l2 mysql-5.7.44]# ll /etc/my.cnf
    3. -rw-r--r--. 1 mysql mysql 555 62 13:20 /etc/my.cnf
    4. [root@l2 mysql-5.7.44]# cd /usr/local/
    5. [root@l2 local]# ll
    6. 总用量 0
    7. drwxr-xr-x. 2 root root 6 411 2018 bin
    8. drwxr-xr-x. 2 root root 6 411 2018 etc
    9. drwxr-xr-x. 2 root root 6 411 2018 games
    10. drwxr-xr-x. 2 root root 6 411 2018 include
    11. drwxr-xr-x. 2 root root 6 411 2018 lib
    12. drwxr-xr-x. 2 root root 6 411 2018 lib64
    13. drwxr-xr-x. 2 root root 6 411 2018 libexec
    14. drwxr-xr-x. 11 root root 177 62 12:57 mysql
    15. drwxr-xr-x. 2 root root 6 411 2018 sbin
    16. drwxr-xr-x. 5 root root 49 430 23:03 share
    17. drwxr-xr-x. 2 root root 6 411 2018 src
    18. [root@l2 local]# chown -R mysql:mysql mysql/
    19. [root@l2 local]# ll
    20. 总用量 0
    21. drwxr-xr-x. 2 root root 6 411 2018 bin
    22. drwxr-xr-x. 2 root root 6 411 2018 etc
    23. drwxr-xr-x. 2 root root 6 411 2018 games
    24. drwxr-xr-x. 2 root root 6 411 2018 include
    25. drwxr-xr-x. 2 root root 6 411 2018 lib
    26. drwxr-xr-x. 2 root root 6 411 2018 lib64
    27. drwxr-xr-x. 2 root root 6 411 2018 libexec
    28. drwxr-xr-x. 11 mysql mysql 177 62 12:57 mysql
    29. drwxr-xr-x. 2 root root 6 411 2018 sbin
    30. drwxr-xr-x. 5 root root 49 430 23:03 share
    31. drwxr-xr-x. 2 root root 6 411 2018 src
    32. [root@l2 local]#
    在环境变量中添加mysql的bin和lib目录
    1. [root@l2 local]# cd mysql/bin/
    2. [root@l2 bin]# pwd
    3. /usr/local/mysql/bin
    4. [root@l2 bin]# ls
    5. innochecksum mysql_config mysqlslap
    6. lz4_decompress mysql_config_editor mysql_ssl_rsa_setup
    7. myisamchk mysqld mysqltest
    8. myisam_ftdump mysqld_pre_systemd mysqltest_embedded
    9. myisamlog mysqldump mysql_tzinfo_to_sql
    10. myisampack mysqldumpslow mysql_upgrade
    11. my_print_defaults mysql_embedded mysqlxtest
    12. mysql mysqlimport perror
    13. mysqladmin mysql_install_db replace
    14. mysqlbinlog mysql_plugin resolveip
    15. mysqlcheck mysqlpump resolve_stack_dump
    16. mysql_client_test mysql_secure_installation zlib_decompress
    17. mysql_client_test_embedded mysqlshow
    18. [root@l2 bin]# vim /etc/profile

    1. [root@l2 bin]# source /etc/profile
    2. [root@l2 bin]# echo $PATH
    3. /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/mysql/bin:/usr/local/mysql/lib
    4. [root@l2 bin]#
    mysql初始化操作
    1. ./mysqld \
    2. --initialize-insecure \
    3. --user=mysql \
    4. --basedir=/usr/local/mysql \
    5. --datadir=/usr/local/mysql/data
    1. [root@l2 bin]# ./mysqld \
    2. > --initialize-insecure \
    3. > --user=mysql \
    4. > --basedir=/usr/local/mysql \
    5. > --datadir=/usr/local/mysql/data
    添加mysqld系统服务
    1. [root@l2 bin]# cd /usr/local/mysql/usr/lib/systemd/system/
    2. [root@l2 system]# ls
    3. mysqld.service mysqld@.service
    4. [root@l2 system]# cp mysqld.service /usr/lib/systemd/system
    5. [root@l2 system]# systemctl daemon-reload
    6. [root@l2 system]# systemctl enable mysqld
    7. Created symlink from /etc/systemd/system/multi-user.target.wants/mysqld.service to /usr/lib/systemd/system/mysqld.service.
    8. [root@l2 system]# systemctl start mysqld
    9. [root@l2 system]# netstat -lntp | grep mysqld
    10. tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 33819/mysqld
    11. [root@l2 system]#
    修改mysql密码 
    1. [root@l2 system]# mysqladmin -u root -p password "abc123"
    2. Enter password: //直接回车,因为原先是没有密码的
    3. mysqladmin: [Warning] Using a password on the command line interface can be insecure.
    4. Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.

    1. [root@l2 system]# mysql -u root -pabc123
    2. mysql: [Warning] Using a password on the command line interface can be insecure.
    3. Welcome to the MySQL monitor. Commands end with ; or \g.
    4. Your MySQL connection id is 3
    5. Server version: 5.7.44 Source distribution
    6. Copyright (c) 2000, 2023, Oracle and/or its affiliates.
    7. Oracle is a registered trademark of Oracle Corporation and/or its
    8. affiliates. Other names may be trademarks of their respective
    9. owners.
    10. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    11. mysql> show databases;
    12. +--------------------+
    13. | Database |
    14. +--------------------+
    15. | information_schema |
    16. | mysql |
    17. | performance_schema |
    18. | sys |
    19. +--------------------+
    20. 4 rows in set (0.00 sec)
    21. mysql> quit
    22. Bye
    23. [root@l2 system]#
    授权并刷新 
    1. [root@l2 system]# mysql -u root -pabc123
    2. mysql: [Warning] Using a password on the command line interface can be insecure.
    3. Welcome to the MySQL monitor. Commands end with ; or \g.
    4. Your MySQL connection id is 4
    5. Server version: 5.7.44 Source distribution
    6. Copyright (c) 2000, 2023, Oracle and/or its affiliates.
    7. Oracle is a registered trademark of Oracle Corporation and/or its
    8. affiliates. Other names may be trademarks of their respective
    9. owners.
    10. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    1. mysql> grant all on *.* to 'root'@'%' identified by 'abc123';
    2. Query OK, 0 rows affected, 1 warning (0.00 sec)
    1. mysql> flush privileges;
    2. Query OK, 0 rows affected (0.00 sec)
    3. mysql>

    php服务器配置 

     上传压缩包至/opt目录中并解压
    1. [root@l3 ~]# cd /opt/
    2. [root@l3 opt]# ls
    3. rh
    1. [root@l3 opt]# ls
    2. php-7.1.10.tar.bz2 rh
    3. [root@l3 opt]# tar xf php-7.1.10.tar.bz2
    4. [root@l3 opt]#
    安装环境依赖包
    1. [root@l3 opt]# cd php-7.1.10/
    2. [root@l3 php-7.1.10]# df
    3. 文件系统 1K-块 已用 可用 已用% 挂载点
    4. devtmpfs 1913544 0 1913544 0% /dev
    5. tmpfs 1930624 0 1930624 0% /dev/shm
    6. tmpfs 1930624 12528 1918096 1% /run
    7. tmpfs 1930624 0 1930624 0% /sys/fs/cgroup
    8. /dev/mapper/centos-root 38770180 5624548 33145632 15% /
    9. /dev/sda1 1038336 191100 847236 19% /boot
    10. tmpfs 386128 8 386120 1% /run/user/42
    11. tmpfs 386128 0 386128 0% /run/user/0
    12. [root@l3 php-7.1.10]# mount /dev/sr0 /mnt
    13. mount: /dev/sr0 写保护,将以只读方式挂载
    14. [root@l3 php-7.1.10]#yum -y install gd \
    15. libjpeg libjpeg-devel \
    16. libpng libpng-devel \
    17. freetype freetype-devel \
    18. libxml2 libxml2-devel \
    19. zlib zlib-devel \
    20. curl curl-devel \
    21. openssl openssl-devel
    1. yum -y install gd \
    2. libjpeg libjpeg-devel \
    3. libpng libpng-devel \
    4. freetype freetype-devel \
    5. libxml2 libxml2-devel \
    6. zlib zlib-devel \
    7. curl curl-devel \
    8. openssl openssl-devel
    配置软件模块
    1. [root@l3 php-7.1.10]# ./configure \
    2. > --prefix=/usr/local/php \
    3. > --with-mysql-sock=/usr/local/mysql/mysql.sock \
    4. > --with-mysqli \
    5. > --with-zlib \
    6. > --with-curl \
    7. > --with-gd \
    8. > --with-jpeg-dir \
    9. > --with-png-dir \
    10. > --with-freetype-dir \
    11. > --with-openssl \
    12. > --enable-fpm \
    13. > --enable-mbstring \
    14. > --enable-xml \
    15. > --enable-session \
    16. > --enable-ftp \
    17. > --enable-pdo \
    18. > --enable-tokenizer \
    19. > --enable-zip
    1. ./configure \
    2. --prefix=/usr/local/php \
    3. --with-mysql-sock=/usr/local/mysql/mysql.sock \
    4. --with-mysqli \
    5. --with-zlib \
    6. --with-curl \
    7. --with-gd \
    8. --with-jpeg-dir \
    9. --with-png-dir \
    10. --with-freetype-dir \
    11. --with-openssl \
    12. --enable-fpm \
    13. --enable-mbstring \
    14. --enable-xml \
    15. --enable-session \
    16. --enable-ftp \
    17. --enable-pdo \
    18. --enable-tokenizer \
    19. --enable-zip
    编译安装
    make && make install
    路径优化
    1. [root@localhost php-7.1.10]# cd /usr/local/php/
    2. [root@localhost php]# ls
    3. bin etc include lib php sbin var
    4. [root@localhost php]# ln -s /usr/local/php/bin/* /usr/local/bin/
    5. [root@localhost php]# ln -s /usr/local/php/sbin/* /usr/local/sbin/
    6. [root@localhost php]#
    修改php配置文件(共三个)
    修改主配置文件 
    1. [root@localhost php]# php --ini
    2. Configuration File (php.ini) Path: /usr/local/php/lib
    3. Loaded Configuration File: (none)
    4. Scan for additional .ini files in: (none)
    5. Additional .ini files parsed: (none)
    6. [root@localhost php]# cd /opt/php-7.1.10/
    7. [root@localhost php-7.1.10]# ls
    8. acinclude.m4 ltmain.sh README.PARAMETER_PARSING_API
    9. aclocal.m4 main README.REDIST.BINS
    10. appveyor makedist README.RELEASE_PROCESS
    11. build Makefile README.SELF-CONTAINED-EXTENSIONS
    12. buildconf Makefile.frag README.STREAMS
    13. buildconf.bat Makefile.fragments README.SUBMITTING_PATCH
    14. CODING_STANDARDS Makefile.gcov README.TESTING
    15. config.guess Makefile.global README.TESTING2
    16. config.log Makefile.objects README.UNIX-BUILD-SYSTEM
    17. config.nice makerpm README.WIN32-BUILD-SYSTEM
    18. config.status missing run-tests.php
    19. config.sub mkinstalldirs sapi
    20. configure modules scripts
    21. configure.in netware server-tests-config.php
    22. CONTRIBUTING.md NEWS server-tests.php
    23. CREDITS pear snapshot
    24. ext php7.spec stamp-h.in
    25. EXTENSIONS php7.spec.in stub.c
    26. footer php.gif tests
    27. generated_lists php.ini-development travis
    28. genfiles php.ini-production TSRM
    29. header README.EXT_SKEL UPGRADING
    30. include README.GIT-RULES UPGRADING.INTERNALS
    31. INSTALL README.input_filter vcsclean
    32. install-sh README.MAILINGLIST_RULES win32
    33. libs README.md Zend
    34. libtool README.namespaces
    35. LICENSE README.NEW-OUTPUT-API
    36. [root@localhost php-7.1.10]#
    37. [root@localhost php-7.1.10]# cp php.ini-production /usr/local/php/lib/php.ini
    38. [root@localhost php-7.1.10]# cd /usr/local/php/lib/
    39. [root@localhost lib]# ls
    40. php php.ini
    41. [root@localhost lib]#
    1. [root@localhost lib]# vim php.ini
    2. [root@localhost lib]#

    修改进程服务配置文件 
    1. [root@localhost php]# cd /usr/local/php/etc/
    2. [root@localhost etc]# ls
    3. pear.conf php-fpm.conf.default php-fpm.d
    4. [root@localhost etc]#
    5. [root@localhost etc]# cp php-fpm.conf.default php-fpm.conf
    6. [root@localhost etc]# ls
    7. pear.conf php-fpm.conf php-fpm.conf.default php-fpm.d
    8. [root@localhost etc]#
    1. [root@localhost etc]# vim php-fpm.conf
    2. [root@localhost etc]#

    修改扩展配置文件
    1. [root@localhost etc]# cd php-fpm.d/
    2. [root@localhost php-fpm.d]# ls
    3. www.conf.default
    4. [root@localhost php-fpm.d]#
    1. [root@localhost php-fpm.d]# cp www.conf.default www.conf
    2. [root@localhost php-fpm.d]# vim www.conf
    3. [root@localhost php-fpm.d]#

    创建用户
    1. [root@localhost php-fpm.d]# useradd -M -s /sbin/nologin php
    2. [root@localhost php-fpm.d]# cat /etc/passwd | grep php:
    3. php:x:1001:1001::/home/php:/sbin/nologin
    4. [root@localhost php-fpm.d]#
    启动php-fpm
    1. [root@localhost php-fpm.d]# cd /opt/php-7.1.10/
    2. [root@localhost php-7.1.10]# ls
    3. acinclude.m4 ltmain.sh README.PARAMETER_PARSING_API
    4. aclocal.m4 main README.REDIST.BINS
    5. appveyor makedist README.RELEASE_PROCESS
    6. build Makefile README.SELF-CONTAINED-EXTENSIONS
    7. buildconf Makefile.frag README.STREAMS
    8. buildconf.bat Makefile.fragments README.SUBMITTING_PATCH
    9. CODING_STANDARDS Makefile.gcov README.TESTING
    10. config.guess Makefile.global README.TESTING2
    11. config.log Makefile.objects README.UNIX-BUILD-SYSTEM
    12. config.nice makerpm README.WIN32-BUILD-SYSTEM
    13. config.status missing run-tests.php
    14. config.sub mkinstalldirs sapi
    15. configure modules scripts
    16. configure.in netware server-tests-config.php
    17. CONTRIBUTING.md NEWS server-tests.php
    18. CREDITS pear snapshot
    19. ext php7.spec stamp-h.in
    20. EXTENSIONS php7.spec.in stub.c
    21. footer php.gif tests
    22. generated_lists php.ini-development travis
    23. genfiles php.ini-production TSRM
    24. header README.EXT_SKEL UPGRADING
    25. include README.GIT-RULES UPGRADING.INTERNALS
    26. INSTALL README.input_filter vcsclean
    27. install-sh README.MAILINGLIST_RULES win32
    28. libs README.md Zend
    29. libtool README.namespaces
    30. LICENSE README.NEW-OUTPUT-API
    31. [root@localhost php-7.1.10]# cd sapi/
    32. [root@localhost sapi]# ls
    33. apache2handler cgi cli embed fpm litespeed phpdbg tests
    34. [root@localhost sapi]# cd fpm/
    35. [root@localhost fpm]# ls
    36. config.m4 LICENSE php-fpm.conf status.html.in
    37. CREDITS Makefile.frag php-fpm.conf.in tests
    38. fpm php-fpm php-fpm.service www.conf
    39. init.d.php-fpm php-fpm.8 php-fpm.service.in www.conf.in
    40. init.d.php-fpm.in php-fpm.8.in status.html
    41. [root@localhost fpm]# cp php-fpm.service /usr/lib/systemd/system
    42. [root@localhost fpm]# systemctl daemon-reload
    43. [root@localhost fpm]# systemctl start php-fpm.service
    44. [root@localhost fpm]# systemctl enable php-fpm.service
    45. Created symlink from /etc/systemd/system/multi-user.target.wants/php-fpm.service to /usr/lib/systemd/system/php-fpm.service.
    46. [root@localhost fpm]# netstat -lntp | grep php
    47. tcp 0 0 192.168.18.40:9000 0.0.0.0:* LISTEN 86042/php-fpm: mast
    48. [root@localhost fpm]#

    安装论坛 

    上传压缩包到Nginx服务器的/opt目录下并解压 
    1. [root@l1 system]# cd /opt/
    2. [root@l1 opt]# ls
    3. nginx-1.26.0 nginx-1.26.0.tar.gz rh

    1. [root@l1 opt]# ls
    2. Discuz_X3.4_SC_UTF8.zip nginx-1.26.0 nginx-1.26.0.tar.gz rh
    3. [root@l1 opt]# unzip Discuz_X3.4_SC_UTF8.zip
    4. [root@l1 opt]# cd dir_SC_UTF8/
    5. [root@l1 dir_SC_UTF8]# cp -r upload/ /var/www/html/discuz
    6. [root@l1 dir_SC_UTF8]# cd /var/www/html/
    7. [root@l1 html]#
    设置属主属组
    php服务器
    1. [root@localhost html]# cd /usr/local/php/etc/php-fpm.d/
    2. [root@localhost php-fpm.d]# vim www.conf
    3. [root@localhost php-fpm.d]#

    1. [root@localhost php-fpm.d]# useradd -M -s /sbin/nologin nginx
    2. [root@localhost php-fpm.d]# cat /etc/passwd | grep nginx:
    3. nginx:x:1002:1002::/home/nginx:/sbin/nologin
    4. [root@localhost php-fpm.d]# systemctl restart php-fpm.service
    5. [root@localhost php-fpm.d]# ps aux | grep php
    6. root 88567 0.2 0.7 216796 7656 ? Ss 20:00 0:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
    7. nginx 88568 0.0 0.3 218880 3932 ? S 20:00 0:00 php-fpm: pool www
    8. nginx 88569 0.0 0.3 218880 3932 ? S 20:00 0:00 php-fpm: pool www
    9. root 88571 0.0 0.0 112824 972 pts/2 S+ 20:00 0:00 grep --color=auto php
    10. [root@localhost php-fpm.d]# cd /var/www/html/
    11. [root@localhost html]# chown -R nginx:nginx discuz/
    12. [root@localhost html]# ll
    13. 总用量 12
    14. drwxr-xr-x. 13 nginx nginx 4096 62 19:55 discuz
    15. -rw-r--r--. 1 root root 163 62 19:50 mysql.php
    16. -rw-r--r--. 1 root root 20 62 19:25 test.php
    17. [root@localhost html]#
    Nginx服务器
    1. [root@l1 html]# chown -R nginx:nginx discuz/
    2. [root@l1 html]# ll
    3. 总用量 12
    4. drwxr-xr-x. 13 nginx nginx 4096 62 19:55 discuz
    5. -rw-r--r--. 1 root root 163 62 19:50 mysql.php
    6. -rw-r--r--. 1 root root 20 62 19:25 test.php
    7. [root@l1 html]#
    修改文件
    1. [root@l1 html]# cd /usr/local/nginx/conf/
    2. [root@l1 conf]# vim nginx.conf
    3. [root@l1 conf]#

    创建数据库 

    mysql服务器
    1. [root@l2 system]# mysql -u root -pabc123
    2. mysql: [Warning] Using a password on the command line interface can be insecure.
    3. Welcome to the MySQL monitor. Commands end with ; or \g.
    4. Your MySQL connection id is 6
    5. Server version: 5.7.44 Source distribution
    6. Copyright (c) 2000, 2023, Oracle and/or its affiliates.
    7. Oracle is a registered trademark of Oracle Corporation and/or its
    8. affiliates. Other names may be trademarks of their respective
    9. owners.
    10. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    1. mysql> create database discuz;
    2. Query OK, 1 row affected (0.00 sec)
    3. mysql>
    1. mysql> show databases;
    2. +--------------------+
    3. | Database |
    4. +--------------------+
    5. | information_schema |
    6. | discuz |
    7. | mysql |
    8. | performance_schema |
    9. | sys |
    10. +--------------------+
    11. 5 rows in set (0.00 sec)
    12. mysql>
    1. mysql> grant all on discuz. * to 'zy'@'%' identified by 'zy1234';
    2. Query OK, 0 rows affected, 1 warning (0.00 sec)
    3. mysql>
    1. mysql> flush privileges;
    2. Query OK, 0 rows affected (0.00 sec)
    3. mysql>
    nginx服务器 
    [root@l1 conf]# nginx -s reload      //刷新
     

  • 相关阅读:
    Codeforces 1535F 字符串 + 倍增 + BIT
    我为博客园生商业化运营献计
    Ubuntu18.04LTS安装配置VScode及下载C++相应第三方库
    学生环境网页设计模板下载 保护环境大学生HTML网页制作作品 简单环境网页设计成品 dreamweaver学生网站模板
    Day45 MySQL
    SpringBoot中使用Spring integration加Eclipse Paho Java Client 实现MQTT客户端
    Vue2整合图片
    觉哥java网站搭建笔记——后端开发环境搭建
    【docker】容器跟宿主机、其他容器通信
    超市结算系统|Springboot+Vue通用超市结算收银系统
  • 原文地址:https://blog.csdn.net/2301_82109773/article/details/139388689