【Linux 超详细部署Lnmp环境安装WordPress】

反诈示警:如遇到文章内跳转至别的网站或产生需要交钱,交易等行为,均为诈骗行为,请谨慎对待。对于网上兼职、刷单、刷信誉的就是诈骗,请勿相信!需要提供身份证明、短信验证和短信链接点击都是诈骗, 请不要提供!同时请下载“国家反诈中心”App能自查自检,规避诈骗电话,免遭损失。

先了解知道什么是lnmp环境?

LNMP 是指一组通常一起使用来运行动态网站或者服务器的自由软件名称首字母缩写

L指Linux,N指Nginx,M一般指MySQL,也可以指MariaDB,P一般指PHP,也可以指PerlPython。 LNMP代表的就是:Linux系统下Nginx+MySQL+PHP这种 网站服务器架构。 (转载度娘)

我这里选择用到(lnmp)的是:Linux + Nginx + MySQL + PHP

1.安装mysql

linux 安装 Mysql_被程序支配的小彭的博客-CSDN博客

https://blog.csdn.net/m0_59127553/article/details/124103469?spm=1001.2014.3001.5501

2.安装php

CentOS7 --详细配置Nginx支持PHP程序_被程序支配的小彭的博客-CSDN博客https://blog.csdn.net/m0_59127553/article/details/124503533?spm=1001.2014.3001.5501

3.安装nginx

CentOS7详细安装nginx_被程序支配的小彭的博客-CSDN博客https://blog.csdn.net/m0_59127553/article/details/124343092?spm=1001.2014.3001.5501

安装好之后就可以开始搭建wordpress

我们配置以下需要的文件

1.mysql

//先登入mysql

mysql -uroot -p

create database wordpress; //创建数据库

//设置用户名,wordpress数据库密码
grant all on wordpress.* to 'root'@'localhost' identified by 'Wordpress123!';
Query OK, 0 rows affected, 1 warning (0.00 sec)

//查看数据库
 show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| wordpress          |
+--------------------+
5 rows in set (0.00 sec)

flush privileges;
Query OK, 0 rows affected (0.00 sec)

quit //退出数据库


2.nginx

vim /usr/local/nginx/conf/nginx.conf //配置nginx文件

修改内容如下:

 server {
        listen       80;
        server_name  localhost;
    
        location / {
            root   /www/wordpress;
            index index.php index.html index.htm;
        }

 location ~ \\.php$ {
            root           /www/wordpress;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /www/wordpress$fastcgi_script_name; //wordpress文件路径 /www/wordpress
            include        fastcgi_params;
        }
 

/usr/local/nginx/sbin/nginx -t //检查语法
/usr/local/nginx/sbin/nginx -s reload //重启nginx服务

如果没有在根目录里创建www目录,则
[root@localhost ~]# mkdir /www

3.启动php-fpm(如果已经启动,则跳过此步骤)

/usr/local/php/sbin/php-fpm //启动php-fpm 注意自己的php-fpm路径

4.下载wordpress

官网:下载 | WordPress.org China 简体中文

【Linux 超详细部署Lnmp环境安装WordPress】,插图,来源:资源仓库www.zycang.com

 点击下载.tar.gz 我选择的版本是:wordpress-5.9.3-zh_CN.tar.gz

下载之后上传到虚拟机中,并解压 ,修改配置

[root@localhost local]# tar -zxf wordpress-5.9.3-zh_CN.tar.gz 
[root@localhost local]# mv wordpress /www //移动wordpress文件,路径要和nginx里配置的路径一样

cd /www/wordpress/
[root@localhost wordpress]# cp wp-config-sample.php wp-config.php //复制wp-config-sample.php 并改名  wp-config.php
[root@localhost wordpress]# vim wp-config.php

//根据自己设置的数据库,对应修改下面配置  (grant all on wordpress.* to 'root'@'localhost' identified by 'Wordpress123!';)

/** The name of the database for WordPress */
define( 'DB_NAME', 'wordpress' );

/** Database username */ 用户名
define( 'DB_USER', 'root' );

/** Database password */ 密码
define( 'DB_PASSWORD', 'Wordpress123!' );

/** Database hostname */ (如果是localhost 最好写成IP 127.0.0.1 不然之后可能会报错)
define( 'DB_HOST', '127.0.0.1' );

/** Database charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );

/** The database collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );

最后保存退出

最后一步:进入浏览器

http://ip

接着会出现下面的界面

【Linux 超详细部署Lnmp环境安装WordPress】,插图1,来源:资源仓库www.zycang.com

点击现在开始

会出现让你输入数据库名字等信息 (要和数据库,wp-config.php 配置内容一致)

因为我忘了截图,找了一张别人的图

数据库名 :wordpress

用户名:root

密码:Wordpress123!

数据库主机:127.0.0.1

表前缀 :wp_

【Linux 超详细部署Lnmp环境安装WordPress】,插图2,来源:资源仓库www.zycang.com

然后开始安装 (后续也忘了截图,只要不报错,一直继续就会出现下图)

【Linux 超详细部署Lnmp环境安装WordPress】,插图3,来源:资源仓库www.zycang.com

根据自己填写内容

【Linux 超详细部署Lnmp环境安装WordPress】,插图4,来源:资源仓库www.zycang.com

【Linux 超详细部署Lnmp环境安装WordPress】,插图5,来源:资源仓库www.zycang.com

【Linux 超详细部署Lnmp环境安装WordPress】,插图6,来源:资源仓库www.zycang.com

 您已经安装好了  Wordpress!!

【Linux 超详细部署Lnmp环境安装WordPress】,插图7,来源:资源仓库www.zycang.com

 下一次登录

【Linux 超详细部署Lnmp环境安装WordPress】,插图8,来源:资源仓库www.zycang.com

有什么问题,欢迎在评论区留言哦~

可以的话一键三连哦~~ 么么哒

 【Linux 超详细部署Lnmp环境安装WordPress】,插图9,来源:资源仓库www.zycang.com

如需 WordPress 优化加速、二次开发、网站维护、企业网站建设托管等服务,点此联系我 | 近期站内热门福利推荐:
文章版权及转载声明

本文地址:https://www.zycang.com/79901.html
文章转载或复制请以超链接形式并注明来源出处。 本文最后更新于:2022-09-18 00:21:02
声明:某些文章或资源具有时效性,若有 错误 或 所需下载资源 已失效,请联系客服QQ:11210980

喜欢就支持一下吧
点赞94赞赏 分享
相关推荐
评论 抢沙发

请登录后发表评论