双十一来了,有没有打算自己某云买服务器搭建网站的,现在服务器挺便宜,建站也可以自己“免费”DIY。
本文手把手从零开始搭建,软件选择比较成熟的WordPress,操作系统选择CentOS.

1. 环境准备

官网地址:https://cn.wordpress.org

  • PHP 7.4或更高版本
  • MySQL 5.6或更高版本,或MariaDB 10.1或更高版本
  • Nginx或带mod_rewrite模块的Apache
  • HTTPS支持

2. 安装PHP8

2.1 首先更新一下

dnf upgrade

2.2 查看当前dnf库中的php版本

dnf list php

我这里看到的是7.2版,版本过低,

php.x86_64     7.2.24-1.module_el8.2.0+313+b04d0a66     appstream

需要安装个新的。

2.3 首先安装Remi存储库

dnf install -y https://rpms.remirepo.net/enterprise/remi-release-8.rpm
remi-release-8.rpm           0 kB/s |  26 kB     00:01
依赖关系解决。
=====================================================================================
软件包              架构               版本            仓库                 大小
=====================================================================================
安装:remi-release      noarch             8.4-1.el8.remi  @commandline         26 k
安装依赖关系:epel-release      noarch             8-11.el8        extras               24 k

会自动安装依赖epel-release,无需单独安装。

2.4 列出PHP module

dnf module list php

结果类似如下:

CentOS Linux 8 - AppStream
Name        Stream        Profiles                       Summary
php         7.2 [d]       common [d], devel, minimal     PHP scripting language
php         7.3           common [d], devel, minimal     PHP scripting language
php         7.4           common [d], devel, minimal     PHP scripting languageRemi's Modular repository for Enterprise Linux 8 - x86_64
Name        Stream         Profiles                      Summary
php         remi-7.2       common [d], devel, minimal    PHP scripting language
php         remi-7.3       common [d], devel, minimal    PHP scripting language
php         remi-7.4       common [d], devel, minimal    PHP scripting language
php         remi-8.0       common [d], devel, minimal    PHP scripting language
php         remi-8.1       common [d], devel, minimal    PHP scripting language

可以看到已经有了8.0和8.1版本,官网现在8.1还是RC版,准备安装8.0。
期间会询问导入各种公钥,选择“y”即可。

2.5 安装php 8.0

dnf module enable php:remi-8.0
dnf install php
===================================================================================软件包            架构     版本                 仓库                  大小
===================================================================================
安装:php              x86_64   8.0.12-1.el8.remi     remi-modular         1.6 M
安装依赖关系:apr              x86_64   1.6.3-11.el8          AppStream            125 kapr-util         x86_64   1.6.1-6.el8           AppStream            105 kcentos-logos-httpd noarch 85.8-1.el8            base                  75 khttpd            x86_64   2.4.37-39.module_el8  AppStream            1.4 Mhttpd-filesystem noarch   2.4.37-39.module_el8  AppStream             39 khttpd-tools      x86_64   2.4.37-39.module_el8  AppStream            106 klibsodium        x86_64   1.0.18-2.el8          epel                 162 klibxslt          x86_64   1.1.32-6.el8          base                 250 kmailcap          noarch   2.1.48-3.el8          base                  39 kmod_http2        x86_64   1.15.7-3.module_el8   AppStream            154 koniguruma5php    x86_64   6.9.7.1-1.el8.remi    remi-safe            210 kphp-common       x86_64   8.0.12-1.el8.remi     remi-modular         1.2 M
安装弱的依赖:apr-util-bdb     x86_64   1.6.1-6.el8           AppStream             25 kapr-util-openssl x86_64   1.6.1-6.el8           AppStream             27 knginx-filesystem noarch   1:1.14.1-9.module_el8 AppStream             24 kphp-cli          x86_64   8.0.12-1.el8.remi     remi-modular         4.7 Mphp-fpm          x86_64   8.0.12-1.el8.remi     remi-modular         1.6 Mphp-mbstring     x86_64   8.0.12-1.el8.remi     remi-modular         525 kphp-opcache      x86_64   8.0.12-1.el8.remi     remi-modular         768 kphp-pdo          x86_64   8.0.12-1.el8.remi     remi-modular         156 kphp-sodium       x86_64   8.0.12-1.el8.remi     remi-modular          94 kphp-xml          x86_64   8.0.12-1.el8.remi     remi-modular         238 k
启用模块流:httpd                     2.4nginx                     1.14事务概要
================================================================================
安装  23 软件包

选择y,等待安装完成。

2.6 安装php-mysql扩展

逐一执行下面命令安装扩展

dnf install php-mysql
dnf install php-gd
dnf install php-imagick
dnf install php-zip

2.7 验证安装

输入命令查看php版本:

 php -v
PHP 8.0.12 (cli) (built: Oct 19 2021 10:34:32) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.12, Copyright (c) Zend Technologieswith Zend OPcache v8.0.12, Copyright (c), by Zend Technologies

3. 安装mysql8.0

3.1 查看dnf库中mysql版本

dnf list mysql
mysql.x86_64        8.0.26-1.module_el8.4.0+915+de215114     appstream

版本8.0,直接安装。

3.2 安装Mysql8.0

输入安装命令,注意有“@”:

dnf install @mysql
依赖关系解决。
========================================================================================软件包         架构     版本              仓库                大小
========================================================================================
安装组/模块包:mysql-server  x86_64   8.0.26-1.module_el8.4.0+915+de215114   AppStream      25 M
安装依赖关系:...省略....
安装模块配置档案:mysql/server
启用模块流:perl                   5.26perl-IO-Socket-SSL     2.066perl-libwww-perl       6.34事务概要
========================================================================================
安装  54 软件包

选择y等待安装完成。

3.3配置

启动mysql

systemctl start mysqld

查看运行状态

systemctl status mysqld

设为开机启动

systemctl enable mysqld

运行配置向导

mysql_secure_installation

根据提示进行操作:

[root@localhost mysql]# mysql_secure_installation
## 默认已用空密码登录
Securing the MySQL server deployment.
Connecting to MySQL using a blank password.##是否安装密码强度验证模块,看自己需求
VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?
Press y|Y for Yes, any other key for No: no## 设置root的密码
Please set the password for root here.
New password:
Re-enter new password:## 是否删除匿名用户,可删
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.## 默认情况下只允许本机访问,是否开启远程访问,按自己需求
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.## 是否删除测试数据库,可删
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y- Dropping test database...
Success.- Removing privileges on test database...
Success.## 是否立即重新加载刚才的配置,选择是
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
## 配置完毕
All done!

3.4 为WordPress创建数据库

登录数据库

mysql -uroot -p

提示输入密码,输入刚设置的root的密码。
创建数据库,名称自己定,例如wordpress

create database wordpress;

查看现有数据库

show databases;

可以看到新建好的数据库

+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| wordpress          |
+--------------------+
5 rows in set (0.00 sec)

输入exit退出。

4 安装Nginx

4.1 查看dnf库中Nginx版本

dnf list nginx
nginx.x86_64      1:1.14.1-9.module_el8.0.0+184+e34fea82     appstream

版本有点低,安装新版。

4.2 安装Nginx1.20

输入安装命令

dnf install http://nginx.org/packages/centos/8/x86_64/RPMS/nginx-1.20.2-1.el8.ngx.x86_64.rpm
==========================================================================================
软件包            架构       版本                        仓库                  大小
==========================================================================================
安装:nginx           x86_64     1:1.20.2-1.el8.ngx          @commandline          819 k事务概要
==========================================================================================
安装  1 软件包

选择y等待安装完成。

4.3 查看防火墙

查看是否已开放80端口,修改防火墙设置。某云需要修改安全组设置。

firewall-cmd --query-port=80/tcp

若返回no则未开放。
开放80端口命令:

firewall-cmd --zone=public --add-port=80/tcp --permanent

使设置生效:

 firewall-cmd --reload

4.4 访问默认网站验证安装

启动nginx

systemctl start nginx

查看运行状态

systemctl status nginx

会看到包含“ Active: active (running)”字样的成功提示。

设置开机自动启动

systemctl enable nginx

访问 http://服务器ip, 正常会是如下页面

4.5 启用php支持

修改nginx配置文件

cd /etc/nginx/conf.d

备份默认的配置文件

cp default.conf default.conf.bak

修改default.conf

vi default.conf

按"i"键,找到如下代码块,默认是注释状态,去掉#号,并修改为如下配置

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000#location ~ \.php$ {root           /usr/share/nginx/html/;fastcgi_pass   unix:/run/php-fpm/www.sock;fastcgi_index  index.php;fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;include        fastcgi_params;}

fastcgi_pass对应php-fpm的监听配置, 配置文件为: /etc/php-fpm.d/www.conf,可查看验证。

; The address on which to accept FastCGI requests.
; Valid syntaxes are:
;   'ip.add.re.ss:port'    - to listen on a TCP socket to a specific IPv4 address on
;                            a specific port;
;   '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
;                            a specific port;
;   'port'                 - to listen on a TCP socket to all addresses
;                            (IPv6 and IPv4-mapped) on a specific port;
;   '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = /run/php-fpm/www.sock

设置默认文件为index.php

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

修改完毕后,按ESC,输入:wq保存并退出。
重启nginx:

systemctl restart nginx

5. 安装WordPress

5.1 访问网站目录

nginx的默认网站目录在/usr/share/nginx/html/,访问并验证一下

cd /usr/share/nginx/html/
ll

可以看到两个html文件,即默认的“Welcome to nginx!”页面。

-rw-r--r--. 1 root root 494 5月  25 09:41 50x.html
-rw-r--r--. 1 root root 612 5月  25 09:41 index.html

可以删除默认的index.html文件

rm -r index.html

询问是否删除,输入y回车即可。

5.2 下载安装包

安装下载和解压工具,如果已安装则忽略

dnf install wget
dnf install tar

下载wordpress

wget https://cn.wordpress.org/latest-zh_CN.tar.gz

下载完成之后,解压

tar -zxvf latest-zh_CN.tar.gz

拷贝到当前目录

cp -R wordpress/* /usr/share/nginx/html/

5.3 开始安装

访问"http://服务器ip/wp-admin/install.php",可以看到如下页面:

点击按钮开始配置:

输入准备好的数据库相关信息。
如果提示无法写入wp-config.php,如下图

手动创建wp-config.php文件

cd /usr/share/nginx/html/
vi wp-config.php

按i键,粘贴网页中给出的文件内容。
按ESC,输入:wq回车保存。

继续安装,在新页面设置网站的相关信息

点击按钮开始安装。
安装成功后,访问http://服务器ip即可。
管理后台地址:http://服务器ip/wp-admin

免费建站?手把手自己从零开始(超详细)相关推荐

  1. 老榕智能建站软件_2020年,10大最佳免费建站软件

    文章目录 1 10大最佳免费建站软件 1.1 1. Site123 –是否像1-2-3一样容易? 1.2 2. Wix –国际重量级 1.3 3. Weebly –一个缺点很大的网站建设者 1.4 4 ...

  2. 免费建站平台测评分析

    所谓有需求就有市场,现在的免费建站平台也是多的数不甚数,可是不是所有的工具都好,只有适合自己的.目前市场上免费建站平台种类繁多,性能各异,价格也有所不同.经过对比多家,精选出2款自助建站平台:「上线了 ...

  3. 新浪云平台——免费建站100个(图解教程)

    新浪云平台--免费建站100个(图解教程) 如何免费建站?大部分SEO还有淘宝客们都希望建立属于自己的网站,可是刚开始的菜鸟们,没有强硬的建站本领,没有相关的建站知识,也没什么钱,所以都希望能有一个免 ...

  4. github免费建站和文件夹上传技巧

    1.github免费建站 项目名字 ###.github.io (###为github账户名) 创建后就能上传html网页相关文件 效果展示: 2.github上传文件夹方式 下面截图2方式点击cho ...

  5. 微软免费服务器申请教程,2019年8月13日最新免费申请微软OneDrive5TB云盘超详细教程!...

    2019年8月13日最新免费申请微软OneDrive5TB云盘超详细教程!(已亲测!) 本人已于今天2019年8月13日日亲测,成功获取微软OneDrive 5T云盘! 第一步:.打开申请链接 学生版 ...

  6. php移动建站,zzzphp 免费建站整站系统含手机站 v1.8.2 Build20200915

    zzzphp采用PHP+ACCESS/MSSQL免费建站整站系统,所有源码开源完整,支持直接使用. zzzphp功能 1.支持mysql,sqlite,access三种数据库. 2.模板和标签与asp ...

  7. Wordpress免费建站图文教程(二):建站虚拟主机的购买

    L氪迹将在这里给各位新手分享Wordpress程序完整的免费建站教程,拆分每一个步骤,附上图文,让建站新手们更好地理解和操作,零基础也能快速上手学会建站. 上一期讲到如何购买域名,那么接着分享一下:搭 ...

  8. 族蚂免费建站系统,3分钟搭建官网!

    传统建站是一个系统的工程,他需要一个团队,各自有不同的分工.这种建站方式时间长.花费高,若双方沟通不好,建站时间就会延长.现在大多数中小企业建站都使用族蚂自助建站系统,不需要更改代码,拖拽式更改网站布 ...

  9. 搜狐快站 mysql_免费建站哪个最好?免费建站平台推荐

    免费建站哪个最好?建站就是建立一个自己的网站,但是一把都需要借助一些平台来进行建站的操作,今天就给大家分享几个免费建站平台. 1.Wix (国外) Wix 是国外比较有名的一款免费网站建站系统,模板设 ...

  10. 建站宝盒——最适合中小企业的免费建站工具

    作为一个中小型企业,在如今互联网早已深入人们生活的时代里,无论我们提供的是何种服务亦或某种产品,最先想到的应该就是通过网络进行曝光.宣传,让更多的用户能够在搜索引擎上找到我们的商品.如果我们的预算充足 ...

最新文章

  1. webconfig的解决方案怎么添加_解决在Web.config或App.config中添加自定义配置的方法详解...
  2. suse docker 安装mysql_Docker(三):Docker安装MySQL
  3. MVC中Spring.net 对基类控制器无效 过滤器控制器无效
  4. 最新android版本奥利奥,最新Android 8.1即将来临,你想吃奥利奥了吗?
  5. Boost:线程实例
  6. hdu1247(Hat’s Words)
  7. 泛型类、泛型方法及泛型应用
  8. 五年26个版本:Linux系统内核全程回顾
  9. matlab贝塞尔函数的根,matlab画贝塞尔函数根分布的曲线图.doc
  10. movelast对数据记录数有要求吗_客户验厂,电脑坏了,考勤记录数据可以自动生成找回来吗?...
  11. jsp中使用jsp:include /在切换tomcat版本时遇到的问题
  12. FM信号测试软件,音频测试方案:音频FM指标测试方法
  13. 如何在 Excel 中计算 NPS
  14. 电机精密运动控制专家电机驱动芯片TMC260
  15. 博弈论模型——Part 2 Part 3
  16. 魔兽世界燃烧的远征最新服务器,魔兽世界燃烧的远征怀旧服
  17. 路飞学城Python-Day23
  18. vlc播放器linux编译,linux安装vlc视频播放器
  19. 在 iOS 微信浏览器中自动播放 HTML5 audio(音乐) 的正确方式
  20. 网页微信公众平台登录电脑版

热门文章

  1. yoyo跑_yoyo主持人5岁女儿照片曝光 其老公魏哲浩个人资料简介
  2. shopee海外仓如何申请及 收 费 标 准
  3. 使用ArchR分析单细胞ATAC-seq数据(第四章)
  4. [CryptoHack] RSA-PRIMES PART1 Write-Up
  5. 阿里研究院启动2017年度淘宝村辅助认证活动(附表格下载)
  6. 51单片机的智能窗帘设计
  7. 华为设备DHCP配置命令
  8. python中函数包括_python中函数与函数之间的调用,总是晕菜,整理如下,有不对或者补充的请提出来~...
  9. 微软365网盘国内服务器,5TB微软Office365网盘OneDrive详细申请方法教程
  10. 蔡高厅高等数学23-导数的几何意义、可导与连续的关系