微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

第六章 6.2 LNMP搭建wordpress博客系统

6.2.1 LNMP架构介绍

  LNMP是linux、NginxMysqLPHP的网站架构缩写,是基于linux系统的最基础的网站架构模式,linux系统可选择centos7,web服务用NginxMysqL用来存储数据,PHP应用程序提供前后端服务。LNMP架构常用在论坛博客中小网站上,它环境稳定、支持高并发是当前比较流行的小网站架构。

6.2.2 LNMP环境搭建

  一 环境准备:

  安装centos7.6系统,2核4G内存40G盘,最小化安装
  设置好网络和防火墙 网络需要能访问外网
  ip 192.168.1.103
  
  关闭防火墙
  setenforce 0
  systemctl stop firewalld
  systemctl disable firewalld
  sed -i 's/enforcing/disabled/g' /etc/sysconfig/selinux
  

  设置yum源
  cd /etc/yum.repos.d/
  yum install vim unzip lrzsz wget net-tools -y
  wget http://mirrors.aliyun.com/repo/Centos-7.repo
  wget http://mirrors.aliyun.com/repo/epel-7.repo
  wget http://repo.MysqL.com/MysqL57-community-release-el7-8.noarch.rpm
  rpm -ivh MysqL57-community-release-el7-8.noarch.rpm
  yum -y install epel-release
  yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
  yum -y install yum-utils
  yum-config-manager --enable remi-PHP74

  二 安装Nginx1.16、PHP74、MysqL5.7

  安装Nginx
  [root@centos7 ~]# yum install Nginx -y
  [root@centos7 ~]# systemctl start Nginx
  [root@centos7 ~]# systemctl enable Nginx

  安装MysqL
  [root@centos7 ~]# yum -y install MysqL-community-server
  [root@centos7 ~]# systemctl start MysqLd
  [root@centos7 ~]# systemctl enable MysqLd
  [root@centos7 ~]# cat /var/log/MysqLd.log|grep password
  [root@centos7 ~]# 2021-01-04T11:32:27.789879K 1 [Note] A temporary password is generated for root@localhost: ;p>M$Qf9IoKE

  安装PHP7.4
  [root@centos7 ~]# yum install epel-release
  [root@centos7 ~]# yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
  [root@centos7 ~]# yum -y install yum-utils
  [root@centos7 ~]# yum repolist all |grep PHP
  [root@centos7 ~]# yum-config-manager --enable remi-PHP74
  [root@centos7 ~]# yum install PHP PHP-cli PHP-fpm PHP-MysqLnd PHP-zip PHP-devel PHP-gd PHP-mcrypt PHP-mbstring PHP-curl PHP-xml PHP-pear PHP-bcmath PHP-json PHP-redis
  [root@centos7 ~]# systemctl start PHP-fpm
  [root@centos7 ~]# systemctl enable PHP-fpm

  查看服务
  [root@centos7 ~]# netstat -lnupt
  tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 74928/PHP-fpm: master
  tcp6 0 0 :::3306 :::* LISTEN 25437/MysqLd
  tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 25985/Nginx: master

6.2.3 worldpress博客系统

  下载worldpress
  https://cn.wordpress.org/download/releases/
  https://cn.wordpress.org/wordpress-5.6-zh_CN.zip
  unzip wordpress-5.6-zh_CN.zip
  cp -a wordpress /usr/share/Nginx/html/wordpress

  chown Nginx.Nginx /usr/share/Nginx/html/wordpress/ -R
  
  创建worldpress数据库
  MysqL -u root -p
  MysqL> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Super@2020';
  MysqL> CREATE DATABASE wordpress;
  MysqL> GRANT ALL PRIVILEGES ON *.* TO 'wordpress'@'%' IDENTIFIED BY 'Super@2020' WITH GRANT OPTION;
  MysqL> flush privileges;
  MysqL> exit
  

  增加Nginx配置
  Nginx.conf中增加新配置 root/location
  server {
   listen 80 default_server;
   listen [::]:80 default_server;
   server_name _;
   root /usr/share/Nginx/html/wordpress;
   # Load configuration files for the default server block.
   include /etc/Nginx/default.d/*.conf;
   location / {
   index index.PHP index.html;
   }
   location ~ \.PHP?.*$ {
   root /usr/share/Nginx/html/wordpress;
   fastcgi_pass 127.0.0.1:9000;
   fastcgi_index index.PHP;
   include fastcgi_params;
   fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
   }
   error_page 404 /404.html;
   location = /404.html {
   }
   error_page 500 502 503 504 /50x.html;
   location = /50x.html {
   }
  }

  重启Nginx
  Nginx -t
  Nginx -s reload

  页面配置worldpress

  打开192.168.1.103进行配置

 

 

 

 

 

 

 到应用的根目录,创建wp-config.php,然后执行现在安装

 

 填写好信息,并记住密码,安装worldpress

 

 

 

 

 

 

 

 

到此 博客网站安装完成,这是原始的worldpress博客,网上有很多优秀好看的模板,可以拿来借鉴学习,让自己的网站更美观好看。

 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐