关于本篇介绍

之前自己有搭建一个WordPress博客(小熊BLOG),但由于之前购买的云服务器将于近期到期,自己又没有资金续费,所以决定将里面的文章全部转发过来。

之前博客搭建目的

之所以搭建此博客,是因为暑期在复习Linux相关知识的时候,意识到很多知识不是通过简单的一两次复习就能完全掌握,因此期望通过搭建此博客不定期的将自己所复习的知识以文章的形式整理出来以巩固自己对知识的理解与记忆,并希望对有幸访问到此网站的网友做一个简单的知识分享,希望对这些网友的学习也有所帮助。

搭建过程

我在搭建此站的时候采用的是LNMP架构,并且在安装nginx的时候采用了基于yum的安装方式,如果有同学有更高的需求或者创新,可以选择编译安装的方式。

具体搭建过程简单介绍如下:

使用官方仓库安装nginx

[root@localhost ~]# vim /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=https://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1

[root@localhost ~]# yum -y install nginx

修改nginx用户

[root@localhost ~]# groupadd www -g 666
[root@localhost ~]# useradd www -u 666 -g 666 -s /sbin/nologin -M
[root@localhost ~]# sed -i '/^user/c user www;' /etc/nginx/nginx.conf

启动nginx并加入开机自启

[root@localhost ~]# systemctl start nginx
[root@localhost ~]# systemctl enable nginx

使用第三方扩展源安装php7.1

[root@localhost ~]# vim /etc/yum.repos.d/php.repo
[php]
name = php Repository
baseurl = https://repo.webtatic.com/yum/el7/x86_64/
gpgcheck = 0

[root@localhost ~]# yum install -y epel-release
[root@localhost ~]# yum -y install php71w php71w-cli php71w-common php71w-devel php71w-embedded php71w-gd php71w-mcrypt php71w-mbstring php71w-pdo php71w-xml php71w-fpm php71w-mysqlnd php71w-opcache php71w-pecl-memcached php71w-pecl-redis php71w-pecl-mongodb

配置php-fpm用户与nginx的运行用户保持一致

[root@localhost ~]# sed -i '/^user/c user = www' /etc/php-fpm.d/www.conf
[root@localhost ~]# sed -i '/^group/c group = www' /etc/php-fpm.d/www.conf

启动php-fpm并加入开机自启

[root@localhost ~]# systemctl start php-fpm
[root@localhost ~]# systemctl enable php-fpm

安装mariadb数据库

[root@localhost ~]# yum install mariadb-server mariadb -y
[root@localhost ~]# systemctl start mariadb
[root@localhost ~]# systemctl enable mariadb
[root@localhost ~]# mysqladmin password '123456'
[root@localhost ~]# mysql -uroot -p123456

配置Nginx虚拟主机站点

部署博客产品WordPress配置Nginx虚拟主机站点,域名为 xxiong.xyz。

[root@localhost ~]# vim /etc/nginx/conf.d/wordpress.conf
server {
    listen 80;
    server_name blog.test.com;
    root /code/wordpress;
    index index.php index.html;

    location ~ \.php$ {
        root /code/wordpress;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}


[root@localhost code]# nginx -t
[root@localhost code]# systemctl restart nginx

下载wordpress源码

[root@localhost ~]# cd /code
[root@localhost code]# wget https://cn.wordpress.org/latest-zh_CN.tar.gz
[root@localhost code]# tar xzvf latest-zh_CN.tar.gz
[root@localhost code]# chown -R www.www /code/wordpress

创建所需数据库

由于wordpress产品需要依赖数据库,所以需要手动建立数据库。

[root@localhost ~]# mysql -uroot -p123456 -e "create database wordpress;show
 databases;"

+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
| wordpress          | 
+--------------------+

配置wordpress

在完成了上述操作之后你到浏览器去访问你的域名你就可以看到如下界面,这时你就可以开始对你的wordpress进行配置了。

设置文件上传大小限制

要完全解决博客内文件上传的大小限制得从这几个方面综合解决:nginx配置文件里面的client_max_body_size、php配置文件里面的upload_max_filesize以及post_max_size。

[root@localhost ~]# vim /etc/nginx/conf.d/wordpress.conf
server {
    listen 80;
    server_name blog.test.com;
    root /code/wordpress;
    index index.php index.html;
    client_max_body_size 1000m;

    location ~ \.php$ {
        root /code/wordpress;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

[root@localhost ~]# nginx -t
[root@localhost ~]# systemctl restart nginx
[root@localhost code]# vim /etc/php.ini
upload_max_filesize = 1000M

[root@localhost code]# systemctl restart php-fpm
[root@localhost code]# vim /etc/php.ini
post_max_size = 1000M

[root@localhost code]# systemctl restart php-fpm

当这三个地方的最大限制都修改后那么文件最大上传大小就为1000M了。

至此,一个博客的搭建就已经完成了。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值