1、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语句进行数据库的速写操作
2、编译安装
准备工具:三台虚拟机,一台做Nginx服务器(20.0.0.40),一台做Mysql服务器(20.0.0.30),一台做php服务器(20.0.0.20)。
网段:20.0.0.0/24
实验步骤
(1)三台虚拟机系统初始化
[root@zx2 ~]# systemctl stop firewalld
[root@zx2 ~]# setenforce 0
[root@zx2 ~]#-------------------------------------------------------------------------------------------[root@zx3 ~]# systemctl stop firewalld
[root@zx3 ~]# setenforce 0
setenforce: SELinux is disabled
[root@zx3 ~]#-------------------------------------------------------------------------------------------[root@zx4 ~]# systemctl stop firewalld
[root@zx4 ~]# setenforce 0
setenforce: SELinux is disabled
[root@zx4 ~]#
(2)Nginx服务器配置
1)安装依赖包
[root@zx4 ~]# df
文件系统 1K-块 已用 可用 已用% 挂载点
devtmpfs 915656 0 915656 0% /dev
tmpfs 931496 0 931496 0% /dev/shm
tmpfs 931496 10504 920992 2% /run
tmpfs 931496 0 931496 0% /sys/fs/cgroup
/dev/sda3 39301380 4585608 34715772 12% /
/dev/sda1 520868 179820 341048 35% /boot
tmpfs 186300 12 186288 1% /run/user/42
tmpfs 186300 0 186300 0% /run/user/0
[root@zx4 ~]# mount /dev/sr0 /mnt/
mount: /dev/sr0 写保护,将以只读方式挂载
[root@zx4 ~]# yum -y install pcre-devel zlib-devel openssl-devel gcc gcc-c++ make
2)创建用户
[root@zx4 ~]# useradd -M -s /sbin/nologin nginx
[root@zx4 ~]# cat /etc/passwd | grep nginx:
nginx:x:1000:1000::/home/nginx:/sbin/nologin
[root@zx4 ~]#
3)上传软件包至/opt目录下并解压
[root@zx4 ~]# cd /opt/
[root@zx4 opt]# ls
nginx-1.26.0.tar.gz
[root@zx4 opt]# tar xf nginx-1.26.0.tar.gz
[root@zx4 opt]# ls
nginx-1.26.0 nginx-1.26.0.tar.gz
[root@zx4 opt]# cd nginx-1.26.0/
[root@zx4 nginx-1.26.0]#
4)安装依赖包
[root@zx4 nginx-1.26.0]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module
5)编译安装
[root@zx4 nginx-1.26.0]# make -j4 && make install
6)设置软链接,可以直接调用nginx命令来进行管理
[root@zx4 nginx-1.26.0]# cd /usr/local/nginx/
[root@zx4 nginx]# ls sbin/
nginx
[root@zx4 nginx]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
[root@zx4 nginx]# 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@zx4 nginx]#
7)添加Nginx系统服务
[root@zx4 nginx]# cd /usr/lib/systemd/system
[root@zx4 system]# vim nginx.service
[root@zx4 system]# systemctl daemon-reload
[root@zx4 system]# systemctl start nginx
[root@zx4 system]# systemctl enable nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/s ystemd/system/nginx.service.
[root@zx4 system]# netstat -lntp | grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 2279/nginx: master
[root@zx4 system]#[Unit]
Description=nginx
After=network.target[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true[Install]
WantedBy=multi-user.target
8)配置Nginx支持php解析(8 9 10 的操作是在配置完后面的mysql和php才开始的)
[root@zx4 system]# cd /usr/local/nginx/
[root@zx4 nginx]# cd conf/
[root@zx4 conf]# ls
fastcgi.conf koi-win scgi_params
fastcgi.conf.default mime.types scgi_params.default
fastcgi_params mime.types.default uwsgi_params
fastcgi_params.default nginx.conf uwsgi_params.default
koi-utf nginx.conf.default win-utf
[root@zx4 conf]# vim nginx.conf
[root@zx4 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@zx4 conf]#
$document_root代表网页根目录的值
9)验证php测试页
动态页面
[root@zx4 conf]# mkdir -p /var/www/html
[root@zx4 conf]# cd /var/www/html/
[root@zx4 html]# vim test.php
静态页面
[root@zx4 html]# cd /usr/local/nginx/html/
[root@zx4 html]# ls
50x.html index.html
[root@zx4 html]# vim zx.html
[root@zx4 html]# ls
50x.html index.html zx.html zx.jpg
[root@zx4 html]#
在本机的hosts文件中添加配置
在浏览器输入http://www.xy101.com/zx.html(我们的静态网页网址)
此时我们的动态页面现在是查不到的
因为我们静态页面是由Nginx直接处理和响应的,而动态页面是Nginx通过fastcgi接口转发给php-fpm进程接受,然后再由php解析器处理解释动态页面后响应返回给Nginx,Nginx再返回给客户端的,所以我们要在将动态页面位置也放入到php服务器中
在本服务器中安装NFS
yum安装rbcbind和nfs-utils
显示已经安装过了
设置挂载点目录
[root@zx4 html]# vim /etc/exports
[root@zx4 html]# systemctl --now enable rpcbind nfs
Created symlink from /etc/systemd/system/multi-user.target.wants/nver.service to /usr/lib/systemd/system/nfs-server.service.
[root@zx4 html]# showmount -e
Export list for zx4:
/var/www/html 20.0.0.0/24
[root@zx4 html]#
然后回到我们的php服务器进行操作
能查到我们Nginx服务器共享的目录
[root@zx2 fpm]# showmount -e 20.0.0.40
Export list for 20.0.0.40:
/var/www/html 20.0.0.0/24
[root@zx2 fpm]#
挂载目录
[root@zx2 fpm]# vim /etc/fstab
[root@zx2 fpm]# mkdir -p /var/www/html
[root@zx2 fpm]# mount -a
[root@zx2 fpm]# df -h
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 13M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/mapper/centos-root 36G 5.9G 30G 17% /
/dev/sda1 1014M 187M 828M 19% /boot
tmpfs 378M 12K 378M 1% /run/user/42
tmpfs 378M 0 378M 0% /run/user/0
/dev/sr0 4.5G 4.5G 0 100% /mnt
20.0.0.40:/var/www/html 38G 4.5G 34G 12% /var/www/html
[root@zx2 fpm]#
查看目录,显示成功
[root@zx2 fpm]# ls /var/www/html/
test.php
然后再刷新一下页面(如果没刷出来,回到Nginx服务器重启一下nginx服务)
10)验证mysql测试页
随便在nginx还是php服务器的/var/www/html目录下创建一个mysql.php文件
我这是在php服务器创建的,文件里面的IP地址是mysql服务器的IP地址
[root@zx2 fpm]# cd /var/www/html/
[root@zx2 html]# ls
test.php
[root@zx2 html]# vim mysql.php
[root@zx2 html]#<?php
$link=mysqli_connect('20.0.0.30','root','abc123');
if($link) echo "<h1>mysql connect successful </h1>";
else echo "<h1>mysql connect failed</h1>";?>
~
我们在nginx服务器的/var/www/html目录下也能查找到mysql.php文件
在浏览器输入http://www.xy101.com/mysql.php
(3)Mysql服务器配置
1)上传压缩包至/opt目录中并解压
[root@zx3 opt]# ls
mysql-boost-5.7.44.tar.gz
[root@zx3 opt]# tar xf mysql-boost-5.7.44.tar.gz
[root@zx3 opt]# ls
mysql-5.7.44 mysql-boost-5.7.44.tar.gz
[root@zx3 opt]# cd mysql-5.7.44/
2)安装环境依赖包
[root@zx3 mysql-5.7.44]# df
文件系统 1K-块 已用 可用 已用% 挂载点
devtmpfs 1913624 0 1913624 0% /dev
tmpfs 1930644 0 1930644 0% /dev/shm
tmpfs 1930644 12592 1918052 1% /run
tmpfs 1930644 0 1930644 0% /sys/fs/cgroup
/dev/mapper/centos-root 36805060 6238132 30566928 17% /
/dev/sda1 1038336 189024 849312 19% /boot
tmpfs 386132 12 386120 1% /run/user/42
tmpfs 386132 0 386132 0% /run/user/0
[root@zx3 mysql-5.7.44]# mount /dev/sr0 /mnt/
mount: /dev/sr0 写保护,将以只读方式挂载
[root@zx3 mysql-5.7.44]# yum -y install gcc gcc-c++ ncurses ncurses-devel bison cmake openssl-devel
3)创建用户
[root@zx3 mysql-5.7.44]# useradd -M -s /sbin/nologin mysql
[root@zx3 mysql-5.7.44]# cat /etc/passwd | grep mysql:
mysql:x:1026:1026::/home/mysql:/sbin/nologin
[root@zx3 mysql-5.7.44]#
4)配置软件模块
[root@zx3 mysql-5.7.44]# cmake \
> -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
> -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
> -DSYSCONFDIR=/etc \
> -DSYSTEMD_PID_DIR=/usr/local/mysql \
> -DDEFAULT_CHARSET=utf8 \
> -DDEFAULT_COLLATION=utf8_general_ci \
> -DWITH_EXTRA_CHARSETS=all \
> -DWITH_INNOBASE_STORAGE_ENGINE=1 \
> -DMYSQL_DATADIR=/usr/local/mysql/data \
> -DWITH_BOOST=boost \
> -DWITH_SYSTEMD=1
5)编译安装
[root@zx3 mysql-5.7.44]# make -j4 && make install
6)清除mariadb缓存
[root@zx3 mysql-5.7.44]# yum remove -y mariadb*
7)修改mysql配置文件
[root@zx3 mysql-5.7.44]# vim /etc/my.cnf[client]
port = 3306
socket=/usr/local/mysql/mysql.sock[mysqld]
user = mysql
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
port = 3306
character-set-server=utf8
pid-file = /usr/local/mysql/mysqld.pid
socket=/usr/local/mysql/mysql.sock
bind-address = 0.0.0.0
skip-name-resolve
max_connections=2048
default-storage-engine=INNODB
max_allowed_packet=16M
server-id = 1sql_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
8)更换mysql配置文件和安装目录的属主属组
[root@zx3 mysql-5.7.44]# chown mysql:mysql /etc/my.cnf
[root@zx3 mysql-5.7.44]# ll /etc/my.cnf
-rw-r--r-- 1 mysql mysql 554 5月 30 18:04 /etc/my.cnf
[root@zx3 mysql-5.7.44]# cd /usr/local/
[root@zx3 local]# ll
总用量 0
drwxr-xr-x. 2 root root 6 4月 11 2018 bin
drwxr-xr-x. 2 root root 6 4月 11 2018 etc
drwxr-xr-x. 2 root root 6 4月 11 2018 games
drwxr-xr-x. 2 root root 6 4月 11 2018 include
drwxr-xr-x. 2 root root 6 4月 11 2018 lib
drwxr-xr-x. 2 root root 6 4月 11 2018 lib64
drwxr-xr-x. 2 root root 6 4月 11 2018 libexec
drwxr-xr-x 11 root root 177 5月 29 16:12 mysql
drwxr-xr-x. 2 root root 6 4月 11 2018 sbin
drwxr-xr-x. 5 root root 49 4月 30 23:58 share
drwxr-xr-x. 2 root root 6 4月 11 2018 src
[root@zx3 local]# chown -R mysql:mysql mysql/
[root@zx3 local]# ll
总用量 0
drwxr-xr-x. 2 root root 6 4月 11 2018 bin
drwxr-xr-x. 2 root root 6 4月 11 2018 etc
drwxr-xr-x. 2 root root 6 4月 11 2018 games
drwxr-xr-x. 2 root root 6 4月 11 2018 include
drwxr-xr-x. 2 root root 6 4月 11 2018 lib
drwxr-xr-x. 2 root root 6 4月 11 2018 lib64
drwxr-xr-x. 2 root root 6 4月 11 2018 libexec
drwxr-xr-x 11 mysql mysql 177 5月 29 16:12 mysql
drwxr-xr-x. 2 root root 6 4月 11 2018 sbin
drwxr-xr-x. 5 root root 49 4月 30 23:58 share
drwxr-xr-x. 2 root root 6 4月 11 2018 src
[root@zx3 local]#
9)在环境变量中添加mysql的bin和lib目录
[root@zx3 local]# cd mysql/bin/
[root@zx3 bin]# pwd
/usr/local/mysql/bin
[root@zx3 bin]# ls
innochecksum mysql_config mysqlslap
lz4_decompress mysql_config_editor mysql_ssl_rsa_setup
myisamchk mysqld mysqltest
myisam_ftdump mysqld_pre_systemd mysqltest_embedded
myisamlog mysqldump mysql_tzinfo_to_sql
myisampack mysqldumpslow mysql_upgrade
my_print_defaults mysql_embedded mysqlxtest
mysql mysqlimport perror
mysqladmin mysql_install_db replace
mysqlbinlog mysql_plugin resolveip
mysqlcheck mysqlpump resolve_stack_dump
mysql_client_test mysql_secure_installation zlib_decompress
mysql_client_test_embedded mysqlshow
[root@zx3 bin]# vim /etc/profile
[root@zx3 bin]# source /etc/profile
[root@zx3 bin]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/mysql/bin:/usr/local/mysql/lib
10)mysql初始化操作
[root@zx3 bin]# ./mysqld \
> --initialize-insecure \
> --user=mysql \
> --basedir=/usr/local/mysql \
> --datadir=/usr/local/mysql/data
11)添加mysqld系统服务
[root@zx3 bin]# cd /usr/local/mysql/usr/lib/systemd/system/
[root@zx3 system]# ls
mysqld.service mysqld@.service
[root@zx3 system]# cp mysqld.service /usr/lib/systemd/system
[root@zx3 system]# systemctl daemon-reload
[root@zx3 system]# systemctl enable mysqld
Created symlink from /etc/systemd/system/multi-user.target.wants/mysqld.service to /usr/lib/systemd/system/mysqld.service.
[root@zx3 system]# systemctl start mysqld
[root@zx3 system]# netstat -lntp | grep mysqld
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 3011/mysqld
[root@zx3 system]#
12)修改mysql密码
[root@zx3 system]# mysqladmin -u root -p password "abc123"
Enter password:
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
[root@zx3 system]# mysql -u root -pabc123
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.7.44 Source distributionCopyright (c) 2000, 2023, Oracle and/or its affiliates.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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)mysql> quit
Bye
[root@zx3 system]#
Enter password那边直接回车即可,因为原先是没有密码的
13)授权并刷新
mysql> grant all on *.* to 'root'@'%' identified by 'abc123';
Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
(4)php服务器配置
1)上传压缩包至/opt目录中并解压
[root@zx2 opt]# ls
php-7.1.10.tar.bz2
[root@zx2 opt]# tar xf php-7.1.10.tar.bz2
2)安装环境依赖包
[root@zx2 opt]# cd php-7.1.10/
[root@zx2 php-7.1.10]# df
文件系统 1K-块 已用 可用 已用% 挂载点
devtmpfs 1913504 0 1913504 0% /dev
tmpfs 1930624 0 1930624 0% /dev/shm
tmpfs 1930624 12528 1918096 1% /run
tmpfs 1930624 0 1930624 0% /sys/fs/cgroup
/dev/mapper/centos-root 36805060 5614616 31190444 16% /
/dev/sda1 1038336 191268 847068 19% /boot
tmpfs 386128 12 386116 1% /run/user/42
tmpfs 386128 0 386128 0% /run/user/0
[root@zx2 php-7.1.10]# mount /dev/sr0 /mnt/
mount: /dev/sr0 写保护,将以只读方式挂载
[root@zx2 php-7.1.10]#
yum -y install gd \
> libjpeg libjpeg-devel \
> libpng libpng-devel \
> freetype freetype-devel \
> libxml2 libxml2-devel \
> zlib zlib-devel \
> curl curl-devel \
> openssl openssl-devel pcre-devel
3)配置软件模块
[root@zx2 php-7.1.10]# ./configure \
> --prefix=/usr/local/php \
> --with-mysql-sock=/usr/local/mysql/mysql.sock \
> --with-mysqli \
> --with-zlib \
> --with-curl \
> --with-gd \
> --with-jpeg-dir \
> --with-png-dir \
> --with-freetype-dir \
> --with-openssl \
> --enable-fpm \
> --enable-mbstring \
> --enable-xml \
> --enable-session \
> --enable-ftp \
> --enable-pdo \
> --enable-tokenizer \
> --enable-zip
4)编译安装
[root@zx2 php-7.1.10]# make -j4 && make install
5)路径优化
[root@zx2 php-7.1.10]# cd /usr/local/php/
[root@zx2 php]# ls
bin etc include lib php sbin var
[root@zx2 php]# ln -s /usr/local/php/bin/* /usr/local/bin/
[root@zx2 php]# ln -s /usr/local/php/sbin/* /usr/local/sbin/
6)修改php配置文件
有三个配置文件
1、修改主配置文件
[root@zx2 php]# php --ini
Configuration File (php.ini) Path: /usr/local/php/lib
Loaded Configuration File: (none)
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
[root@zx2 php]# cd /opt/php-7.1.10/
[root@zx2 php-7.1.10]# ls
acinclude.m4 ltmain.sh README.PARAMETER_PARSING_API
aclocal.m4 main README.REDIST.BINS
appveyor makedist README.RELEASE_PROCESS
build Makefile README.SELF-CONTAINED-EXTENSIONS
buildconf Makefile.frag README.STREAMS
buildconf.bat Makefile.fragments README.SUBMITTING_PATCH
CODING_STANDARDS Makefile.gcov README.TESTING
config.guess Makefile.global README.TESTING2
config.log Makefile.objects README.UNIX-BUILD-SYSTEM
config.nice makerpm README.WIN32-BUILD-SYSTEM
config.status missing run-tests.php
config.sub mkinstalldirs sapi
configure modules scripts
configure.in netware server-tests-config.php
CONTRIBUTING.md NEWS server-tests.php
CREDITS pear snapshot
ext php7.spec stamp-h.in
EXTENSIONS php7.spec.in stub.c
footer php.gif tests
generated_lists php.ini-development travis
genfiles php.ini-production TSRM
header README.EXT_SKEL UPGRADING
include README.GIT-RULES UPGRADING.INTERNALS
INSTALL README.input_filter vcsclean
install-sh README.MAILINGLIST_RULES win32
libs README.md Zend
libtool README.namespaces
LICENSE README.NEW-OUTPUT-API
[root@zx2 php-7.1.10]# cp php.ini-production /usr/local/php/lib/php.ini
[root@zx2 php-7.1.10]# cd /usr/local/php/lib/
[root@zx2 lib]# ls
php php.ini
[root@zx2 lib]# vim php.ini
[root@zx2 lib]#
2、修改进程服务配置文件
[root@zx2 php]# cd etc/
[root@zx2 etc]# ls
pear.conf php-fpm.conf.default php-fpm.d
[root@zx2 etc]# cp php-fpm.conf.default php-fpm.conf
[root@zx2 etc]# ls
pear.conf php-fpm.conf php-fpm.conf.default php-fpm.d
[root@zx2 etc]# vim php-fpm.conf
删除17行的注释
3、修改扩展配置文件
[root@zx2 etc]# cd php-fpm.d/
[root@zx2 php-fpm.d]# ls
www.conf.default
[root@zx2 php-fpm.d]# cp www.conf.default www.conf
[root@zx2 php-fpm.d]# vim www.conf
[root@zx2 php-fpm.d]#
修改用户名和组名
将监听地址改为本机地址
修改允许访问的客户端地址即Nginx服务器地址
7)创建用户
[root@zx2 php-fpm.d]# useradd -M -s /sbin/nologin php
[root@zx2 php-fpm.d]# cat /etc/passwd | grep php:
php:x:1001:1001::/home/php:/sbin/nologin
[root@zx2 php-fpm.d]#
8)启动php-fpm
[root@zx2 php-fpm.d]# cd /opt/php-7.1.10/
[root@zx2 php-7.1.10]# ls
acinclude.m4 ltmain.sh README.PARAMETER_PARSING_API
aclocal.m4 main README.REDIST.BINS
appveyor makedist README.RELEASE_PROCESS
build Makefile README.SELF-CONTAINED-EXTENSIONS
buildconf Makefile.frag README.STREAMS
buildconf.bat Makefile.fragments README.SUBMITTING_PATCH
CODING_STANDARDS Makefile.gcov README.TESTING
config.guess Makefile.global README.TESTING2
config.log Makefile.objects README.UNIX-BUILD-SYSTEM
config.nice makerpm README.WIN32-BUILD-SYSTEM
config.status missing run-tests.php
config.sub mkinstalldirs sapi
configure modules scripts
configure.in netware server-tests-config.php
CONTRIBUTING.md NEWS server-tests.php
CREDITS pear snapshot
ext php7.spec stamp-h.in
EXTENSIONS php7.spec.in stub.c
footer php.gif tests
generated_lists php.ini-development travis
genfiles php.ini-production TSRM
header README.EXT_SKEL UPGRADING
include README.GIT-RULES UPGRADING.INTERNALS
INSTALL README.input_filter vcsclean
install-sh README.MAILINGLIST_RULES win32
libs README.md Zend
libtool README.namespaces
LICENSE README.NEW-OUTPUT-API
[root@zx2 php-7.1.10]# cd sapi/
[root@zx2 sapi]# ls
apache2handler cgi cli embed fpm litespeed phpdbg tests
[root@zx2 sapi]# cd fpm/
[root@zx2 fpm]# ls
config.m4 LICENSE php-fpm.conf status.html.in
CREDITS Makefile.frag php-fpm.conf.in tests
fpm php-fpm php-fpm.service www.conf
init.d.php-fpm php-fpm.8 php-fpm.service.in www.conf.in
init.d.php-fpm.in php-fpm.8.in status.html
[root@zx2 fpm]# cp php-fpm.service /usr/lib/systemd/system
[root@zx2 fpm]# systemctl daemon-reload
[root@zx2 fpm]# systemctl start php-fpm.service
[root@zx2 fpm]# systemctl enable php-fpm.service
Created symlink from /etc/systemd/system/multi-user.target.wants/php-fpm.service to /usr/lib/systemd/system/php-fpm.service.
[root@zx2 fpm]# netstat -lntp | grep php
tcp 0 0 20.0.0.20:9000 0.0.0.0:* LISTEN 10837/php-fpm: mast
[root@zx2 fpm]#
(5)安装论坛
1)上传压缩包到Nginx服务器的/opt目录下并解压
[root@zx4 opt]# ls
Discuz_X3.4_SC_UTF8.zip nginx-1.26.0 nginx-1.26.0.tar.gz
[root@zx4 opt]# unzip Discuz_X3.4_SC_UTF8.zip
[root@zx4 opt]# cd dir_SC_UTF8/
[root@zx4 dir_SC_UTF8]# cp -r upload/ /var/www/html/discuz
[root@zx4 dir_SC_UTF8]# cd /var/www/html/
[root@zx4 html]# ls
discuz mysql.php test.php
2)设置属主属组
在php服务器中操作
[root@zx2 discuz]# cd /usr/local/php/etc/php-fpm.d/
[root@zx2 php-fpm.d]# vim www.conf
[root@zx2 php-fpm.d]# useradd -M -s /sbin/nologin nginx
[root@zx2 php-fpm.d]# cat /etc/passwd | grep nginx:
nginx:x:1002:1002::/home/nginx:/sbin/nologin
[root@zx2 php-fpm.d]# systemctl restart php-fpm.service
[root@zx2 php-fpm.d]# ps aux | grep php
root 12938 0.0 0.2 216796 9676 ? Ss 22:35 0:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
nginx 12941 0.0 0.1 218880 5948 ? S 22:35 0:00 php-fpm: pool www
nginx 12942 0.0 0.1 218880 5948 ? S 22:35 0:00 php-fpm: pool www
root 12946 0.0 0.0 112824 988 pts/0 S+ 22:36 0:00 grep --color=auto php
[root@zx2 php-fpm.d]# cd /var/www/html/
[root@zx2 html]# chown -R nginx:nginx discuz/
[root@zx2 html]# ll
总用量 12
drwxr-xr-x 13 nginx nginx 4096 5月 30 22:22 discuz
-rw-r--r-- 1 root root 157 5月 30 21:43 mysql.php
-rw-r--r-- 1 root root 20 5月 30 21:22 test.php
[root@zx2 html]#
回到Nginx服务器
[root@zx4 html]# chown -R nginx:nginx discuz/
[root@zx4 html]# ll
总用量 12
drwxr-xr-x 13 nginx nginx 4096 5月 30 22:22 discuz
-rw-r--r-- 1 root root 157 5月 30 21:43 mysql.php
-rw-r--r-- 1 root root 20 5月 30 21:22 test.php
[root@zx4 html]#
修改文件
[root@zx4 html]# cd /usr/local/nginx/conf/
[root@zx4 conf]# vim nginx.conf
[root@zx4 conf]# systemctl restart nginx.service
[root@zx4 conf]#
3)创建数据库
在mysql服务器操作
mysql> create database discuz;
Query OK, 1 row affected (0.00 sec)mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| discuz |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.00 sec)mysql> grant all on discuz. * to 'zx'@'%' identified by 'zx1234';
Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)mysql>
4)验证
在浏览器输入http://www.xy101.com/discuz/index.php