ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

LNMP搭建WordPress博客系统

2022-05-11 20:03:09  阅读:310  来源: 互联网

标签:index LNMP nginx html WordPress php root localhost 搭建


改主机名

hostnamectl set-hostname lnmp

传入LNMP压缩包于root下

配置网络(略)及yum源

先检查CD有没有挂载
[root@localhost ~]# mount /dev/cdrom /media             #挂载
mount: /dev/sr0 is write-protected, mounting read-only  
[root@localhost ~]# vi /etc/yum.repos.d/local.repo
进入之后:
[rhel]
name=rhel
baseurl=file:///media
enabled=1
gpgcheck=0
保存退出
[root@localhost ~]# yum clean all          #清理环境
[root@localhost ~]# yum repolist           #检索yum包
[root@localhost ~]# yum -y install unzip   #下载解压工具
[root@localhost ~]# ls                     #查看压缩包
anaconda-ks.cfg  lnmp.zip  wordpress-4.7.3-zh_CN.zip
[root@localhost ~]# unzip lnmp.zip         #解压
[root@localhost ~]# unzip wordpress-4.7.3-zh_CN.zip
再次进入:
[root@localhost ~]# vi /etc/yum.repos.d/local.repo
进入之后:
[rhel]
name=rhel
baseurl=file:///media
enabled=1
gpgcheck=0
[lnmp]
name=lnmp
baseurl=file:///root/lnmp/lnmp
enabled=1
gpgcheck=0
保存退出
[root@localhost ~]# yum clean all          #清理环境
[root@localhost ~]# yum repolist           #检索yum包,此时已有lnmp包
下载服务:
[root@localhost ~]# yum -y install nginx mariadb-server php  php-mysql php-fpm  

配置nginx,修改nginx配置文件

[root@localhost ~]# vi /etc/nginx/conf.d/default.conf
进入之后:需要修改的可自行与下对比
location / {
              root   /usr/share/nginx/html;
              index  index.php  index.html index.htm;    #这行加个index.php
          }

#30-36行注释去掉,修改以下两处参数
查看行数方法:按ESC,输入":",输入set nu ,回车即可
群体去掉#方法:光标移至30行#处,按Ctrl+v,下键选中至36行,按d即可删除
 location ~ \.php$ {
              root           /usr/share/nginx/html;   #改html为/usr/share/nginx/html
             fastcgi_pass   127.0.0.1:9000;
             fastcgi_index  index.php;
             fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;   #改/scripts为$document_root
             include        fastcgi_params;
          }
保存退出
[root@localhost ~]# systemctl start nginx   #启动nginx

配置数据库,数据库初始化,添加WordPress数据库

[root@localhost ~]# systemctl enable --now mariadb
[root@localhost ~]# mysql_secure_installation
然后回车(第二次进入需要输入密码)
y
设置密码
重复输入密码
y 
n 
y
y 
[root@localhost ~]# mysql  -uroot -p000000(密码为你设置的)
MariaDB [(none)]> create  database  wordpress;
MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| wordpress          |
+--------------------+
MariaDB [(none)]> exit
root@localhost ~]# systemctl restart mariadb  #重启

配置php,导入wordpress网站的文件

[root@localhost ~]# cd wordpress/
[root@localhost wordpress]# cp -ar * /usr/share/nginx/html/
[root@localhost wordpress]# cd  /usr/share/nginx/html/
[root@localhost html]# chmod  -R 777 ./
[root@localhost html]# systemctl start php-fpm
[root@localhost html]# systemctl enable php-fpm
Created symlink from /etc/systemd/system/multi-user.target.wants/php-fpm.service to /usr/lib/systemd/system/php-fpm.service.

查看所有服务的端口

[root@localhost ~]# netstat -ntpl  
有一下三个即可:
->  3306:mysqld
->  9000:php-fpm
->  80:nginx

防火墙配置

systemctl stop firewalld
查看防火墙状态命令: systemctl status firewalld
打开防火墙命令为: systemctl start firewalld
如果不想关闭防火墙服务,可使用firewall-cmd命令添加规则;

SElinux设置

直接关闭SElinux即可:
[root@localhost ~]# setenforce 0
但是并不安全,实验无妨
如果为了安全可进入配置文件进行修改:
vi /etc/nginx/conf.d/default.conf
location / {
              root   /usr/share/nginx/html;
              index  index.php  index.html index.htm;
          } #配置文件中的内容
 index  index.php  index.html index.htm  #上下文要一致
semanage fcontext -a -t httpd_sys_content_t '/usr/share/nginx/html/index.php(/.*)?'
restorecon  -RFv /usr/share/nginx/html/index.php

打开火狐浏览器进入地址查看

输入:http://192.168.100.10(此ip应为自己虚拟机ip)即可

本博客转载于:https://www.cnblogs.com/zhengyan6/p/15707335.html

标签:index,LNMP,nginx,html,WordPress,php,root,localhost,搭建
来源: https://www.cnblogs.com/kongshuo/p/16259512.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有