Centos 7安装Nginx+PHP+MariaDB环境搭建WordPress博客

文章目录

[隐藏]

  • 运行环境搭建
    • 1.安装nginx
    • 2.安装php和mariadb
    • 3.修改配置文件
    • 4.开启服务
    • 5.设置开机自启
  • 安装WorePress

WordPress是一个免费的开源项目,是使用PHP语言开发的博客平台,用户可以在支持PHP和MySQL数据库的服务器上架设属于自己的网站。也可以把 WordPress当作一个内容管理系统(CMS)来使用,国内外有不少的知名网站建设都是基于WordPress程序,WordPress有许多第三方开发的免费模板和免费插件,安装方式简单易用,相信很多人的第一个站点都是基于WordPress建的。访问官网https://wordpress.org/

在安装ShadowsocksR服务之前希望先对服务器做基本安全配置(非强制) 跳转链接https://www.gyuryong.com/index.php/archives/18/

运行环境搭建

WordPress基于PHP开发的,相信是大家最熟悉也是最容易部署的Web项目了。环境准备:lnmp(linux+nginx+mysql+php)或者lamp(linux+apache+mysql+php),大同小异,本文推荐使用nginx作为Web服务器。
为了避免不必要的麻烦先关闭防火墙和selinux。

1.安装nginx

安装nginx,默认情况Centos7中无Nginx的源,可以如下执行命令添加源,Centos其他版本或者RHEL查看官方教程(教程链接https://www.nginx.com/resources/wiki/start/topics/tutorials/install/):

vi /etc/yum.repos.d/nginx.repo  

写入

[nginx]  name=nginx repo  baseurl=http://nginx.org/packages/centos/7/$basearch/  gpgcheck=0  enabled=1  

安装nginx:

yum install nginx -y  

2.安装php和mariadb

yum install php-fpm php-mysql mariadb-server unzip  

3.修改配置文件

修改/etc/nginx/conf.d/default.conf中下面两断内容:

vi /etc/nginx/conf.d/default.conf  

更改前:

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

更改后:

    root   /usr/share/nginx/html;      index  index.html index.htm index.php;  location / {      try_files $uri $uri/ /index.php$is_args$args;  }  

更改前:

#location ~ .php$ {  #    root           html;  #    fastcgi_pass   127.0.0.1:9000;  #    fastcgi_index  index.php;  #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;  #    include        fastcgi_params;  #}  

更改后:

location ~ .php$ {      fastcgi_pass   127.0.0.1:9000;      fastcgi_index  index.php;      fastcgi_param  SCRIPT_FILENAME  $request_filename;      include        fastcgi_params;  }  

修改/etc/php-fpm.d/www.conf配置:

vi /etc/php-fpm.d/www.conf  

user = apache改为user = nginx,将group = apache改为group = nginx

4.开启服务

systemctl start nginx.service  systemctl start mariadb.service  systemctl start php-fpm.service  

5.设置开机自启

systemctl enable nginx mariadb php-fpm  
安装WorePress

1.移除/usr/share/nginx/html内所有文件:

cd /usr/share/nginx/html  rm 50x.html index.html  

2.下载WordPress并解压,到官网复制最新版链接(跳转链接https://cn.wordpress.org/download/):

yum install wget -y  wget https://cn.wordpress.org/wordpress-4.9.4-zh_CN.zip  unzip wordpress-4.9.4-zh_CN.zip  

3.将Web文件移动到根目录并删除没用文件夹:

mv wordpress/* .  rmdir wordpress  rm wordpress-4.9.4-zh_CN.zip  

4.权限设置

chown nginx.nginx -R .  

5.创建数据库wordpress:

mysql  create database wordpress;  exit  

接下来输入你的ip地址就可以安装WordPress了!

原文出处:gyuryong -> https://www.gyuryong.com/index.php/archives/33/

本站所发布的一切资源仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。如果侵犯你的利益,请发送邮箱到 [email protected],我们会很快的为您处理。