出了问题不要着急,上CSDN或者度娘搜索一下,毕竟,你遇到的大多数问题,前人都曾遇到过,并在网络上留下了解决问题的方法。
#首先安装apache服务
[root@node3 ~]# yum install -y httpd
#设置apache开机自启动
[root@node3 ~]# systemctl enable httpd
#开启apache服务
[root@node3 ~]# systemctl start httpd
打开浏览器,输入IP地址,查看apache是否正常启动,当出现如下页面时,apache启动成功。
首先切换至网页根目录
[root@node3 ~]# cd /var/www/html
安装php及其扩展
[root@node3 ~]# yum install -y php php-fpm php-mysql
启动php-fpm并将其设置为开机自启动
[root@node3 ~]# systemctl restart php-fpm
[root@node3 ~]# systemctl enable php-fpm
重启apache服务
[root@node3 ~]# systemctl restart httpd
首先切换至网页根目录
[root@node3 ~]# cd /var/www/html
安装MariaDB数据库
[root@node3 html]# yum install -y mariadb-server mariadb*
设置数据库开机自启动
[root@node3 html]# systemctl enable mariadb
启动数据库服务
[root@node3 html]# systemctl start mariadb
初始化数据库,设置数据库root密码,其他选项暂时选择默认(直接按Enter键默认选择Yes)
[root@node3 html]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none): #默认回车键
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y #设置root密码
New password: #我在此将密码设置为password
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB 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? [Y/n] #默认回车键
... 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? [Y/n] #默认回车键
... Success!
By default, MariaDB 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? [Y/n] #默认回车键
- 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? [Y/n] #默认回车键
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
初始化数据库完成后,先重启数据库,再登录数据库,为数据库添加远程连接权限,并新建一个名为blog的数据库。
#重启数据库
[root@node3 html]# systemctl restart mariadb
#登陆数据库,为数据库添加远程连接权限
[root@node3 html]# mysql -uroot -ppassword
#用户名为root,密码为上一步设置的密码
外网访问数据库授权
#用户名为root,密码为上上一步设置的密码
grant all privileges on *.* to root@'%' identified by 'password';
#新建数据库blog
create database blog;
#更新数据库权限
flush privileges;
#查看数据库权限
select User,Host,Password from mysql.user;
#退出数据库
quit;
#重启数据库
[root@node3 html]# systemctl restart mariadb.service
#开启防火墙
[root@node3 html]# systemctl start firewalld
#设置防火墙开机自启动
[root@node3 html]# systemctl enable firewalld
#开启80端口
[root@node3 html]# firewall-cmd --per --add-port=80/tcp
#开启3306端口
[root@node3 html]# firewall-cmd --per --add-port=3306/tcp
#重载防火墙
[root@node3 html]# firewall-cmd --reload
#查看防火墙开启的端口状态
[root@node3 html]# firewall-cmd --list-all
进入网页根目录
[root@node3 ~]# cd /var/www/html
使用rz命令上传php探针,检测一下数据库连接是否正常;如果提示没有rz命令
使用yum install -y lrzsz命令,下载安装rz
[root@node3 html]# yum install -y lrzsz
[root@node3 html]# rz
打开浏览器输入ip/tz.php,查看数据库能否成功连接
例如:http://192.168.139.154/tz.php
如果出现以下情况,只需要重启以下apache服务就可以了
[root@node3 html]# systemctl restart httpd
成功进入探针后测试数据库的连通性
检测成功后,记得将探针文件删除。
[root@node3 html]# rm tz.php
LAMP基础环境已经搭建完成,接下来安装Typecho
使用rz命令上传typecho.zip文件并解压
[root@node3 html]# rz
[root@node3 html]# ls
typecho.zip
[root@node3 html]# unzip typecho.zip
#若没有unzip命令,使用yum安装
#查看目录下的文件
[root@node3 html]# ls
admin index.php install install.php LICENSE.txt typecho.zip usr var
为html/目录添加权限
[root@node3 html]# chmod -R 777 /var/www/html/
打开浏览器,输入http://192.168.139.154/install.php进行Typecho安装
演示命令
#在/var/www/html目录下手动创建 config.inc.php 文件
[root@node3 html]# vi config.inc.php
将命令黏贴进配置文件并保存退出
安装成功
安装完成后页面非常的简介,可以去Typecho主题模板网站下载免费的主题使用,或者购买收费主题
https://www.typecho.me/