大佬教程收集整理的这篇文章主要介绍了免费建站?手把手自己从零开始(超详细),大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
双十一来了c;有没有打算自己某云买服务器搭建网站的c;现在服务器挺便宜c;建站也可以自己“免费”DIY。 本文手把手从零开始搭建c;软件选择比较成熟的WordPressc;操作系统选择CentOs.@H_607_6@
dnf upgrade
dnf list php
我这里看到的是7.2版c;版本过低c;@H_607_6@
php.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 appstream
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-releasec;无需单独安装。@H_607_6@
dnf module list php
结果类似如下:@H_607_6@
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 language
Remi'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版本c;官网现在8.1还是RC版c;准备安装8.0。 期间会询问导入各种公钥c;选择“y”即可。@H_607_6@
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 k
apr-util x86_64 1.6.1-6.el8 AppStream 105 k
centos-logos-httpd noarch 85.8-1.el8 base 75 k
httpd x86_64 2.4.37-39.module_el8 AppStream 1.4 M
httpd-filesystem noarch 2.4.37-39.module_el8 AppStream 39 k
httpd-tools x86_64 2.4.37-39.module_el8 AppStream 106 k
libsodium x86_64 1.0.18-2.el8 epel 162 k
libxslt x86_64 1.1.32-6.el8 base 250 k
mailcap noarch 2.1.48-3.el8 base 39 k
mod_http2 x86_64 1.15.7-3.module_el8 AppStream 154 k
oniguruma5php x86_64 6.9.7.1-1.el8.remi remi-safe 210 k
php-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 k
apr-util-openssl x86_64 1.6.1-6.el8 AppStream 27 k
nginx-filesystem noarch 1:1.14.1-9.module_el8 AppStream 24 k
php-cli x86_64 8.0.12-1.el8.remi remi-modular 4.7 M
php-fpm x86_64 8.0.12-1.el8.remi remi-modular 1.6 M
php-mbString x86_64 8.0.12-1.el8.remi remi-modular 525 k
php-opcache x86_64 8.0.12-1.el8.remi remi-modular 768 k
php-pdo x86_64 8.0.12-1.el8.remi remi-modular 156 k
php-sodium x86_64 8.0.12-1.el8.remi remi-modular 94 k
php-xml x86_64 8.0.12-1.el8.remi remi-modular 238 k
启用模块流:
httpd 2.4
nginx 1.14
事务概要
================================================================================
安装 23 软件包
dnf install php-mysql
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 Technologies
with Zend OPcache v8.0.12, Copyright (c), by Zend Technologies
dnf list mysql
@H_694_26@mysql.x86_64 8.0.26-1.module_el8.4.0+915+de215114 appstream
dnf install @mysql
依赖关系解决。
========================================================================================
软件包 架构 版本 仓库 大小
========================================================================================
安装组/模块包:
mysql-server x86_64 8.0.26-1.module_el8.4.0+915+de215114 AppStream 25 M
安装依赖关系:
...省略....
安装模块配置档案:
mysql/server
启用模块流:
perl 5.26
perl-IO-Socket-SSL 2.066
perl-libwww-perl 6.34
事务概要
========================================================================================
安装 54 软件包
选择y等待安装完成。@H_607_6@
启动mysql@H_607_6@
systemctl start mysqld
查看运行状态@H_607_6@
systemctl enable mysqld
设为开机启动@H_607_6@
systemctl enable mysqld
运行配置向导@H_607_6@
@H_694_26@mysql_secure_installation
根据提示进行操作:@H_607_6@
[root@localhost mysql]# mysql_secure_installation
## 默认已用空密码登录
Securing the MySQL server deployment.
ConnecTing to MySQL using a blank password.
##是否安装密码强度验证模块c;看自己需求
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:
## 是否删除匿名用户c;可删
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 @H_131_49@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.
## 默认情况下只允许本机访问c;是否开启远程访问c;按自己需求
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.
## 是否删除测试数据库c;可删
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.
## 是否立即重新加载刚才的配置c;选择是
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!
登录数据库@H_607_6@
@H_694_26@mysql -uroot -p
提示输入密码c;输入刚设置的root的密码。 创建数据库c;名称自己定c;例如wordpress@H_607_6@
create database wordpress;
查看现有数据库@H_607_6@
show databases;
可以看到新建好的数据库@H_607_6@
+--------------------+
| Database |
+--------------------+
| information_scheR_155_11845@a |
| mysql |
| perfoRMANce_scheR_155_11845@a |
| sys |
| wordpress |
+--------------------+
5 rows in set (0.00 sec)
输入exit退出。@H_607_6@
dnf list nginx
nginx.x86_64 1:1.14.1-9.module_el8.0.0+184+e34fea82 appstream
输入安装命令@H_607_6@
dnf install http://nginx.org/packages/centos/8/x86_64/RPMS/nginx-1.20.1-1.el8.ngx.x86_64.rpm
==========================================================================================
软件包 架构 版本 仓库 大小
==========================================================================================
安装:
nginx x86_64 1:1.20.1-1.el8.ngx @commandline 819 k
事务概要
==========================================================================================
安装 1 软件包
选择y等待安装完成。@H_607_6@
查看是否已开放80端口c;修改防火墙设置。某云需要修改安全组设置。@H_607_6@
firewall-cmd --query-port=80/tcp
若返回no则未开放。 开放80端口命令:@H_607_6@
firewall-cmd --zone=public --add-port=80/tcp --peRMANent
使设置生效:@H_607_6@
firewall-cmd --reload
启动nginx@H_607_6@
systemctl start nginx
查看运行状态@H_607_6@
systemctl status nginx
会看到包含“ Active: active (running)”字样的成功提示。@H_607_6@
设置开机自动启动@H_607_6@
systemctl enable nginx
访问 http://服务器ipc; 正常会是如下页面 @H_5_1616@@H_607_6@@H_607_6@
修改nginx配置文件@H_607_6@
cd /etc/nginx/conf.d
备份默认的配置文件@H_607_6@
cp default.conf default.conf.bak
修改default.conf@H_607_6@
vi default.conf
按"I"键c;找到如下代码块c;默认是注释状态c;去掉#号c;并修改为如下配置@H_607_6@
# 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的监听配置c; 配置文件为: /etc/php-fpm.d/www.confc;可查看验证。@H_607_6@
; 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
LOCATIOn / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}
修改完毕后c;按ESCc;输入:wq保存并退出。 重启nginx:@H_607_6@
systemctl restart nginx
nginx的默认网站目录在/usr/share/nginx/html/c;访问并验证一下@H_607_6@
cd /usr/share/nginx/html/
ll
可以看到两个html文件c;即默认的“Welcome to nginx!”页面。@H_607_6@
-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文件@H_607_6@
rm -r index.html
yum install wget
yum install tar
下载wordpress@H_607_6@
wget https://cn.wordpress.org/latest-zh_CN.tar.gz
tar -zxvf latest-zh_CN.tar.gz
拷贝到当前目录@H_607_6@
cp -R wordpress/* /usr/share/nginx/html/
访问"http://服务器ip/wp-admin/install.php",可以看到如下页面: @H_5_1616@@H_607_6@ 点击按钮开始配置: @H_5_1616@@H_607_6@ 输入准备好的数据库相关信息。 如果提示无法写入wp-config.php,如下图 @H_5_1616@@H_607_6@ 手动创建wp-config.php文件@H_607_6@
cd /usr/share/nginx/html/
vi wp-config.php
按i键c;粘贴网页中给出的文件内容。 按ESCc;输入:wq回车保存。@H_607_6@
继续安装c;在新页面设置网站的相关信息 @H_5_1616@@H_607_6@ 点击按钮开始安装。 安装成功后c;访问http://服务器ip即可。 管理后台地址:http://服务器ip/wp-admin@H_607_6@
以上是大佬教程为你收集整理的免费建站?手把手自己从零开始(超详细)全部内容,希望文章能够帮你解决免费建站?手把手自己从零开始(超详细)所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。