lnmp部署

1. LNMP介绍

LNMP代表的就是:Linux系统下Nginx+MySQL+PHP这种网站服务器架构。
Linux是一类Unix计算机操作系统的统称,是目前最流行的免费操作系统。代表版本有:debian、centos、ubuntu、fedora、gentoo等。
Nginx (engine x) 是一个高性能的HTTP和反向代理web服务器,同时也提供了IMAP/POP3/SMTP服务。其特点是占有内存少,并发能力强,事实上nginx的并发能力在同类型的网页服务器中表现较好
MySQL是一种开放源代码的关系型数据库管理系统(RDBMS),使用最常用的数据库管理语言–结构化查询语言(SQL)进行数据库管理。MySQL不仅是开放源代码的,也因为其速度、可靠性和适应性而备受关注。大多数人都认为在不需要事务化处理的情况下,MySQL是管理内容最好的选择。
PHP即“超文本预处理器”,是一种通用开源脚本语言。PHP是在服务器端执行的脚本语言,与C语言类似,是常用的网站编程语言。因为PHP的开源性、免费性、快捷性等特点使其成为目前最流行的编程语言。

2. 优点

四种软件均为免费开源软件,组合到一起,成为一个免费、高效、扩展性强的网站服务系统。
Nginx使用更少的资源,支持更多的并发连接,体现更高的效率。
Nginx 既可以在内部直接支持Rails和PHP,也可以支持作为 HTTP代理服务器对外进行服务。
Nginx 安装非常的简单,配置文件非常简洁(还能够支持perl语法)。Nginx支持平滑加载新的配置,还能够在不间断服务的情况下进行软件版本的升级。

3. LNMP工作原理

在这里插入图片描述
第一步:用户在浏览器输入域名或者IP访问网站
第二步:用户在访问网站的时候,向web服务器发出http request请求,服务器响应并处理web请求,返回静态网页资源,如CSS、picture、video等,然后缓存在用户主机上。
第三步:服务器调用动态资源,PHP脚本调用fastCGI传输给php-fpm,然后php-fpm调用PHP解释器进程解析PHP脚本。
第四步:出现大流量高并发情况,PHP解析器也可以开启多进程处理高并发,将解析后的脚本返回给php-fpm,然后php-fpm再调给fast-cgi将脚本解析信息传送给nginx,服务器再通过http response传送给用户浏览器。
第五步:浏览器再将服务器传送的信息进行解析与渲染,呈现给用户。

4. FastCGI

4.1 什么是CGI
CGI全称"通用网关接口"(Common Gateway Interface),用于HTTP服务器与其它机器上的程序服务通信交流的一种工具,CGI程序须运行在网络服务器上。
传统CGI接口方式的主要缺点是性能较差,因为每次HTTP服务器遇到动态程序时都需要重启解析器来执行解析,然后结果被返回给HTTP服务器。这在处理高并发访问几乎是不可用的,因此就诞生了FastCGI。另外传统的CGI接口方式安全性也很差。
4.2 什么是FastCGI
FastCGI是一个可伸缩地、高速地在HTTP服务器和动态脚本语言间通信的接口(FastCGI接口在Linux下是socket(可以是文件socket,也可以是ip socket)),主要优点是把动态语言和HTTP服务器分离开来。多数流行的HTTP服务器都支持FastCGI,包括Apache、Nginx和lightpd。
同时,FastCGI也被许多脚本语言所支持,比较流行的脚本语言之一为PHP。FastCGI接口方式采用C/S架构,可以将HTTP服务器和脚本解析服务器分开,同时在脚本解析服务器上启动一个或多个脚本解析守护进程。当HTTP服务器每次遇到动态程序时,可以将其直接交付给FastCGI进程执行,然后将得到的结构返回给浏览器。这种方式可以让HTTP服务器专一地处理静态请求或者将动态脚本服务器的结果返回给客户端,这在很大程度上提高了整个应用系统的性能。
FastCGI的重要特点:

  • FastCGI是HTTP服务器和动态脚本语言间通信的接口或者工具。
  • FastCGI优点是把动态语言解析和HTTP服务器分离开来。
  • Nginx、Apache、Lighttpd以及多数动态语言都支持FastCGI。
  • FastCGI接口方式采用C/S架构,分为客户端(HTTP服务器)和服务端(动态语言解析服务器)。
  • PHP动态语言服务端可以启动多个FastCGI的守护进程。
  • HTTP服务器通过FastCGI客户端和动态语言FastCGI服务端通信。
    4.3 Nginx FastCGI的运行原理
    Nginx不支持对外部动态程序的直接调用或者解析,所有的外部程序(包括PHP)必须通过FastCGI接口来调用。
    FastCGI接口在Linux下是socket(可以是文件socket,也可以是ip socket)。为了调用CGI程序,还需要一个FastCGI的wrapper,这个wrapper绑定在某个固定socket上,如端口或者文件socket。
    [图片]
    当Nginx将CGI请求发送给这个socket的时候,通过FastCGI接口,wrapper接收到请求,然后派生出一个新的线程,这个线程调用解释器或者外部程序处理脚本并读取返回数据;接着,wrapper再将返回的数据通过FastCGI接口,沿着固定的socket传递给Nginx;最后,Nginx将返回的数据发送给客户端,这就是Nginx+FastCGI的整个运作过程。
    FastCGI的主要优点是把动态语言和HTTP服务器分离开来,是Nginx专一处理静态请求和向后转发动态请求,而PHP/PHP-FPM服务器专一解析PHP动态请求。

5. 实战部署LNMP架构(yum部署WordPress站点)

环境说明:
系统 主机名 IP 服务
centos7 nginx 192.168.1.11 mysql、nginx、php、wordpress

5.1 搭建nginx相关的yum源

注意:本次安装所获得的软件包都是来源于httpd源(都是由该软件包厂商提供)。所以切记不能像往常一样直接使用本地源去安装一切包

vim /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1

5.1.2 刷新yum仓库,安装启动nginx服务 
yum clean all && yum makecache
yum install nginx -y 
nginx -v
 
systemctl start nginx
systemctl enable nginx

5.2 mysql的安装
5.2.1 卸载一切与mysql有关的包
——为了新mysql版本的包做环境准备,以免老版本干扰新版本的植入

yum remove mariadb* -y

5.2.2 wget mysql相关的yum源
注意 : wget默认会将下载的安置在当前目录

cd /opt  
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql57-community-release-el7-10.noarch.rpm
(注意:当这一步执行完成以后,会在/etc/yum.repos.d中 生成mysql-community.repo 和mysql-community-source.repo )
yum -y install mysql-community-server

cd /etc/yum.repos.d
sed -i 's/gpgcheck=1/gpgcheck=0/' mysql-community.repo
yum -y install mysql-community-server

附加:第二种方式(与上面可以二选一使用)

wget https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm
rpm -ivh mysql57-community-release-el7-11.noarch.rpm
cd /etc/yum.repos.d
sed -i 's/gpgcheck=1/gpgcheck=0/' mysql-community.repo
yum -y install mysql-server

5.2.3 启动mysql服务并且做一些初步设置

systemctl start mysqld.service
systemctl enable mysqld.service
systemctl status mysqld.service
yum安装的数据库初始密码的查看:
grep "password" /var/log/mysqld.log                        #在日志文件中找出root用户的初始密码
 
grep "password" /var/log/mysqld.log | awk '{print $NF}'
数据库密码修改
mysql  -u root -p

ALTER USER 'root'@'localhost' IDENTIFIED BY 'Admin@123';     #密码设置要求有 大小写字母、数字和符号 组合
grant all privileges on *.* to root@"%" identified by "Admin@123" with grant option; #允许所有通过数据库密码访问的主机
flush privileges; #刷新数据库

5.2.4 停止版本更新,稳定数据库的运行

yum -y remove mysql57-community-release-el7-10.noarch     
#为了防止每次yum操作都会自动更新,卸载这个软件

5.3 php的yum安装
5.3.1 获取php的相关yum源
注意:下载保持好网络的畅通性。

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm 
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

5.3.2 安装相关的依赖拓展模块

yum -y install php72w \
php72w-cli\
 php72w-common\
 php72w-devel\
 php72w-embedded\
 php72w-gd\
 php72w-mbstring\
 php72w-pdo\
 php72w-xml\
 php72w-fpm\
 php72w-mysqlnd\
 php72w-opcache \
 php72w-redis
 
systemctl start php-fpm
systemctl enable php-fpm
php -v

5.3.3 nginx支持php的解析

cd /etc/nginx/conf.d

//给default.conf 做一个备份,防止配置修改错误,无法还原
cp default.conf default.conf.bak
修改php的默认配置:

vim /etc/nginx/conf.d/default.conf
......
    location ~ \.php$ {
        root           html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/html$fastcgi_script_name;  #将 /scripts 修改为nginx的工作目录
        include        fastcgi_params;
    }

完整版!!!!!

server {
    listen       80;
    server_name  localhost;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }


    location ~ \.php$ {
        root           html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/html$fastcgi_script_name;
        include        fastcgi_params;
    }
}

保存配置后并重启服务:

systemctl restart nginx

5.4 lnmp的连接测试
5.4.1 nginx和php的连接测试
创建php页面测试,进行访问测试

cd /usr/share/nginx/html
vim index.php
<?php
phpinfo();
?>

测试结果
在这里插入图片描述

5.4.2 lnmp的连接测试

vim /usr/share/nginx/html/index.php
<?php
$link=mysqli_connect('192.168.1.12','root','Admin@123');
if($link) echo "<h1>Success!!</h1>";
else echo "Fail!!";
?>

测试结果:
在这里插入图片描述

6. 实战部署LNMP架构(编译安装WordPress)

6.1 部署Nginx
1、安装依赖

[root@web-server-08 ~]# yum install gcc pcre-devel openssl-devel zlib-devel -y

2、创建nginx用户

[root@web-server-08 ~]# useradd -s /sbin/nologin nginx -M

3、下载nginx源码包

[root@web-server-08 ~]# cd /usr/local/src/
[root@web-server-08 src]# wget http://nginx.org/download/nginx-1.18.0.tar.gz
[root@web-server-08 src]# tar xf nginx-1.18.0.tar.gz 

4、编译安装

[root@web-server-08 src]# cd nginx-1.18.0
[root@web-server-08 nginx-1.18.0]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module
[root@web-server-08 nginx-1.18.0]# make && make install

5、授权

[root@web-server-08 nginx-1.18.0]# chown -R nginx:nginx /usr/local/nginx

6、设置开机自启

[root@web-server-08 ~]# cat > /lib/systemd/system/nginx.service <<EOF
[Unit]
Description=nginx service
After=network.target 
   
[Service] 
Type=forking 
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true 
   
[Install] 
WantedBy=multi-user.target
EOF
[root@web-server-08 nginx-1.18.0]# systemctl daemon-reload
[root@web-server-08 nginx-1.18.0]# systemctl enable nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
[root@web-server-08 nginx-1.18.0]# systemctl start nginx

6.2 部署Mysql
1、下载并上传软件至/usr/local/src

1.1、wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz

wget下载过慢解决方法:
安装aria2工具,请运行以下命令:

yum -y  install aria2
aria2c -j5 https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz

[root@mysql-36 ~]# cd /usr/local/src
[root@mysql-36 src]# ls
mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz

2、解压软件

[root@mysql-36 src]# tar xf mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz
[root@mysql-36 src]# mv mysql-5.7.31-linux-glibc2.12-x86_64  ../mysql-5.7.31
[root@mysql-36 src]# cd ..
[root@mysql-36 local]# ln -s mysql-5.7.31/ mysql

3、用户的创建处理原始环境

[root@mysql-36 ~]# yum remove mariadb-libs.x86_64 -y
[root@mysql-36 ~]# rpm -qa |grep mariadb
[root@mysql-36 ~]# useradd -s /sbin/nologin mysql

4、设置环境变量


vim /etc/profile
export PATH=/usr/local/mysql/bin:$PATH
[root@mysql-36 ~]# source /etc/profile
[root@mysql-36 ~]# mysql -V
mysql  Ver 14.14 Distrib 5.7.31, for linux-glibc2.12 (x86_64) using  EditLine wrapper

5、可忽略这一步
创建数据路径并授权
添加一块新磁盘模拟数据盘
格式化并挂载磁盘

[root@mysql-36 ~]# mkfs.xfs /dev/sdb
[root@mysql-36 ~]# mkdir /data
[root@mysql-36 ~]# blkid 或使用 lsblk -f 查看uuid号
[root@mysql-36 ~]# vim /etc/fstab 
UUID=7dfc98e4-6ab0-450e-adc6-c26fe729e6e0 /data  xfs  defaults  0 0
[root@mysql-36 ~]# mount -a
[root@mysql-36 local]# df -h
文件系统        容量  已用  可用 已用% 挂载点
/dev/sda3        17G  2.9G   15G   17% /
devtmpfs        903M     0  903M    0% /dev
tmpfs           912M     0  912M    0% /dev/shm
tmpfs           912M  8.6M  904M    1% /run
tmpfs           912M     0  912M    0% /sys/fs/cgroup
/dev/sdb1        10G  166M  9.9G    2% /data
/dev/sda1      1014M  135M  880M   14% /boot
tmpfs           183M     0  183M    0% /run/user/0

授权 
chown -R mysql.mysql /usr/local/mysql/*
chown -R mysql.mysql /data

6、初始化数据(创建系统数据)
[root@mysql-36 ~]# mkdir /data/mysql/data -p 
[root@mysql-36 ~]# chown -R mysql.mysql /data
[root@mysql-36 ~]# mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/data 

说明:
--initialize 参数:
1. 对于密码复杂度进行定制:12位,4种 
2. 密码过期时间:180天
3. 给root@localhost用户设置临时密码

报错:
mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
解决:
[root@mysql-36 ~]# yum install -y libaio-devel

[root@mysql-36 ~]# mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/data
2019-06-13T04:21:27.706564Z 1 [Note] A temporary password is generated for root@localhost: =mrV)_16is4U

--initialize-insecure 参数:
无限制,无临时密码
[root@mysql-36 /data/mysql/data]# \rm -rf /data/mysql/data/*
[root@mysql-36 ~]# mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/data

[root@bogon mysql]# ./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/data
若不回显数据库密码,则查看报错日志文件:
[root@bogon mysql]# cat /data/mysql/data/error.log | grep "temporary password"
2023-07-21T06:57:30.855228Z 1 [Note] A temporary password is generated for root@localhost: TJkW6N0e*:hf


7、配置文件的准备
cat >/etc/my.cnf <<EOF
[mysqld]
user=mysql
basedir=/usr/local/mysql
datadir=/data/mysql/data
socket=/tmp/mysql.sock
server_id=6
port=3306
pid-file=/data/mysql/data/mysql.pid
log-error=/data/mysql/data/error.log
[mysql]
socket=/tmp/mysql.sock
EOF

8、启动数据库
第一种:用service
[root@mysql-36 /etc/init.d]# cp /usr/local/mysql/support-files/mysql.server  /etc/init.d/mysqld 
[root@mysql-36 /etc/init.d]# service mysqld restart

报错:若出现报错信息,mysql.pid 之类的提示;
查看mysql进程,
ps -ef |grep mysqld
杀掉进程,重新启动 即可;

第二种:用systemd
注意:sysv方式启动过的话,需要先提前关闭,才能以下方式登录
cat >/etc/systemd/system/mysqld.service <<EOF
[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]
User=mysql
Group=mysql
ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf
LimitNOFILE = 5000
EOF
[root@mysql-36 local]# systemctl enable mysqld
[root@mysql-36 local]# systemctl start mysqld
6.3 部署PHP
https://www.cnblogs.com/kaikaiya/p/16598916.html
1、安装依赖
[root@web-server-08 nginx-1.18.0]# yum install epel-release -y
[root@web-server-08 nginx-1.18.0]# yum install gcc openssl-devel libxml2-devel bzip2-devel libmcrypt-devel sqlite-devel lsof oniguruma-devel -y

2、下载php源码文件
[root@web-server-08 nginx-1.18.0]# cd /usr/local/src
[root@web-server-08 src]# wget --no-check-certificate https://www.php.net/distributions/php-7.4.11.tar.xzx'x'x'x'x'x'x'x

3、编译安装php
[root@web-server-08 src]# tar xf php-7.4.11.tar.xz 
[root@web-server-08 src]# cd php-7.4.11
[root@web-server-08 php-7.4.11]# ./configure --prefix=/usr/local/php74 -enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-zlib --with-config-file-path=/etc/php74 --with-config-file-scan-dir=/etc/php.d --enable-mbstring --enable-xml --enable-sockets -enable-fpm --enable-maintainer-zts --disable-fileinfo
[root@web-server-08 php-7.4.11]# make && make install

4、生成配置文件
[root@web-server-08 php-7.4.11]# cp /usr/local/src/php-7.4.11/php.ini-production /etc/php.ini
[root@web-server-08 php-7.4.11]# cd /usr/local/php74/etc/
[root@web-server-08 etc]# cp php-fpm.conf.default php-fpm.conf
[root@web-server-08 etc]# cd php-fpm.d/
[root@web-server-08 php-fpm.d]# cp www.conf.default www.conf
[root@web-server-08 php-fpm.d]# grep '^[^;]' www.conf
[www]
user = nginx
group = nginx
listen = 127.0.0.1:9000
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3

5、创建访问日志路径
[root@web-server-08 php-fpm.d]# mkdir -p /usr/local/php74/log

6、启动并验证php
[root@web-server-08 php-fpm.d]# /usr/local/php74/sbin/php-fpm -t
[24-Feb-2023 21:16:06] NOTICE: configuration file /usr/local/php74/etc/php-fpm.conf test is successful
[root@web-server-08 php-fpm.d]# cp -a /usr/local/src/php-7.4.11/sapi/fpm/php-fpm.service /usr/lib/systemd/system/
[root@web-server-08 php-fpm.d]# systemctl daemon-reload
[root@web-server-08 php-fpm.d]# systemctl enable --now php-fpm
Created symlink from /etc/systemd/system/multi-user.target.wants/php-fpm.service to /usr/lib/systemd/system/php-fpm.service.
[root@web-server-08 php-fpm.d]# ss -lntp|grep 9000
LISTEN     0      128    127.0.0.1:9000                     *:*                   users:(("php-fpm",pid=124723,fd=8),("php-fpm",pid=124722,fd=8),("php-fpm",pid=124721,fd=6))
####若没有进程则是php-fpm未能启动导致;以下是解决方法;
先看报错信息提示:
[root@bogon php-fpm.d]# systemctl status php-fpm
● php-fpm.service - The PHP FastCGI Process Manager
   Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Wed 2023-07-26 15:37:08 CST; 1s ago
  Process: 116259 ExecStart=/usr/local/php74/sbin/php-fpm --nodaemonize --fpm-config /usr/local/php74/etc/php-fpm.conf (code=exited, status=78)
 Main PID: 116259 (code=exited, status=78)

Jul 26 15:37:08 bogon systemd[1]: Started The PHP FastCGI Process Manager.
Jul 26 15:37:08 bogon systemd[1]: Starting The PHP FastCGI Process Manager...
Jul 26 15:37:08 bogon php-fpm[116259]: [26-Jul-2023 15:37:08] ERROR: failed to open error_log (/usr/local/php74/var/log/php-fpm.log): Read-only file system (30)
Jul 26 15:37:08 bogon php-fpm[116259]: [26-Jul-2023 15:37:08] ERROR: failed to post process the configuration
Jul 26 15:37:08 bogon php-fpm[116259]: [26-Jul-2023 15:37:08] ERROR: FPM initialization failed
Jul 26 15:37:08 bogon systemd[1]: php-fpm.service: main process exited, code=exited, status=78/n/a
Jul 26 15:37:08 bogon systemd[1]: Unit php-fpm.service entered failed state.
Jul 26 15:37:08 bogon systemd[1]: php-fpm.service failed.
[root@bogon php-fpm.d]# cat /usr/local/php74/var/log/php-fpm.log 
[26-Jul-2023 15:16:11] NOTICE: configuration file /usr/local/php74/etc/php-fpm.conf test is successful

解决办法:第一种
chmod 666 /usr/local/php74/var/log/php-fpm.log
chmod 755 /usr/local/php74/var/log
systemctl restart php-fpm
tail -n 50 /usr/local/php74/var/log/php-fpm.log

若第一种失效,则使用第二种:
ERROR: failed to open error_log (/usr/local/php/var/log/php-fpm.log): Read-only file system (30)
此时,selinux是关闭状态,普通用户对这个文件也可写,问题就迷离了。
解决方法:
vim /usr/lib/systemd/system/php-fpm.service
把
ProtectSystem=full
改成
ProtectSystem=false
然后重新加载服务
systemctl daemon-reload

7、配置nginx支持fastcgi
[root@web-server-08 php-fpm.d]# vim /usr/local/nginx/conf/nginx.conf

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

    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       80;
        server_name  localhost;

        location / {
            root   /data/wordpress;
            index  index.php index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        
        location ~ \.php$ {
            root           /data/wordpress;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
    }
}
[root@web-server-08 php-fpm.d]# cd /usr/local/nginx/sbin/
[root@web-server-08 sbin]# ./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@web-server-08 sbin]# systemctl restart nginx

8、测试php
[root@web-server-08 sbin]# mkdir -p /data/wordpress
[root@web-server-08 sbin]# cd /data/wordpress/
[root@web-server-08 wordpress]# vim test.php 
<?php
phpinfo();
?>
[图片]
6.4 部署wordpress
1、获取wordpress
https://cn.wordpress.org/download/#download-install
进入官网获取软件
2、解压wordpress至目录中
[root@web-server-08 logs]# cd /usr/local/src/
[root@web-server-08 src]# tar xf wordpress-6.1.1-zh_CN.tar.gz
[root@web-server-08 src]# mv wordpress/* /data/wordpress/

3、安装wordpress
[图片]
[图片]
数据库创建wordpress账户
[root@mysql-36 ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.36 MySQL Community Server (GPL)

Copyright (c) 2000, 2021, 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> create database wordpress;
Query OK, 1 row affected (0.00 sec)

mysql> grant all on wordpress.* to wordpress@'%' identified by '123456';
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
#需要手动创建wp-config.php,并把网页中的内容写入进文件中,注意,不要写入笔记中的内容,还是写入网页中的内容
[root@web-server-08 wordpress]# vim wp-config.php

点击安装wordpress;

点击登录,进入wordpress!
到此,wordpress部署完成。



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值