CentOS7.2配置LNMP环境并安装配置网站WordPress
1,安装环境查看
2,安装MySQL5.7.22
下载MySQL
1 | wget https: / / downloads.mysql.com / archives / get / file / mysql - 5.7 . 22 - 1.el7 .x86_64.rpm - bundle.tar |
解压
1 | tar - xf mysql - 5.7 . 22 - 1.el7 .x86_64.rpm - bundle.tar |
清理mysql-libs
1 | yum remove mysql - libs |
安装,安装顺序为common-libs-client-server
1 2 3 4 5 | rpm - vih mysql - community - common - 5.7 . 22 - 1.el7 .x86_64.rpm rpm - vih mysql - community - libs - 5.7 . 22 - 1.el7 .x86_64.rpm rpm - vih mysql - community - client - 5.7 . 22 - 1.el7 .x86_64.rpm rpm - vih mysql - community - server - 5.7 . 22 - 1.el7 .x86_64.rpm rpm - vih mysql - community - libs - compat - 5.7 . 22 - 1.el7 .x86_64.rpm |
PS: mysql-community-libs-compat-5.7.22-1.el7.x86_64.rpm需要安装 否则在安装php时会报错
修改my.cnf配置文件增加一行取消密码复杂度验证
1 | validate_password_policy = LOW |
启动
1 2 3 | systemctl start mysqld systemctl status mysqld systemctl enable mysqld |
初始密码为
1 | cat / var / log / mysqld.log | grep password |
登录修改密码
1 2 | mysql - uroot - p1qaz2wsx set password = password( 'password' ); |
创建数据库设置权限
1 2 3 4 | create database wordpress; create user wordpress@ 'localhost' identified by 'password' ; garnt all on wordpress. * ro wordpress@ 'localhost' ; flush privileges; |
3,安装nginx
下载
1 | wget http: / / nginx.org / download / nginx - 1.16 . 0.tar .gz |
解压
1 | tar - xf nginx - 1.16 . 0.tar .gz |
安装必要插件
1 | yum - y install gcc - c + + zlib - devel pcre - devel |
安装
1 2 3 | cd nginx . / configure - - prefix = / usr / local / nginx - 1.16 . 0 make && make install |
设置软连接
1 | ln - s / usr / local / nginx - 1.16 . 0 / / usr / local / nginx |
修改配置文件
1 | / usr / local / nginx / conf / nginx.conf |
增加以下内容
1 2 3 4 5 6 7 8 | location ~ \.php$ { root html / wordpress; fastcgi_pass 127.0 . 0.1 : 9000 ; fastcgi_index index.php; #fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } |
PS:标红地方与默认配置不同,需要注意,如不设置如此会导致网站访问php文件出现404
启动
1 | / usr / local / nginx / sbin / nginx |
4,安装配置php
设置yum
1 2 | rpm - ivh https: / / mirror.webtatic.com / yum / el7 / epel - release.rpm rpm - ivh https: / / mirror.webtatic.com / yum / el7 / webtatic - release.rpm |
安装php7
1 | yum - y install php70w php70w - fpm php70w - pdo php70w - mysql |
查看php版本
1 2 | php - v php - fpm - v |
验证在跟目录下面创建test.php
1 2 3 | <?php phpinfo() ?> |
访问
1 | http: //ip/test.php |
出现以下界面代表安装php成功
php连接mysql测试
mysql.php
1 2 3 4 5 6 7 8 9 | <?php $mysqli = new mysqli( "localhost" , "root" , "Mysql123456!" ); if (! $mysqli ) { echo "database error" ; } else { echo "MySQL successful" ; } $mysqli ->close(); ?> |
访问出现以下代表php连接mysql成功
5,安装wordpress
官网下载压缩包下载地址
https://cn.wordpress.org/download/
解压至网站根目录,页面访问按照提示一步步操作即可,配置文件wp-config.php会在页面生成复制代码新建配置文件即可
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
2017-06-19 PPTP不使用远程网关访问公网设置