在云服务器centos7.6上利用LAMP搭建Typecho博客

在云服务器centos7.6上利用LAMP搭建Typecho博客

感悟人生
2023-09-17 / 0 评论 / 86 阅读 / 正在检测是否收录...
一、前言

● 其实LAMP就是Linux、Apache、MySQL、PHP这些开头字母。
● 本次演示过程使用腾讯云的轻量应用服务器演示
● 虽然在云服务器中,在选购过程中都可以选预装什么系统,比如:宝象塔、LAMP这些预装
● 但是如果对于想自己搭建出来的,还是建议自己上手试一试。

二、安装Apache
● 安装Apache服务
[root@centos7 ~]# yum install -y httpd  
● 设定开机自启动
[root@centos7 ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
● 启动Apache服务
[root@centos7 ~]# systemctl start httpd
● 查看Apache服务状态
[root@centos7 ~]# systemctl status httpd
● 防火墙,其实针对对外开放的服务器是不建议关闭防火墙的,但是我们这里做演示就直接关闭了,只利用云服务器上的防火墙进行控制。
[root@centos7 ~]# systemctl stop firewalld
● 然后打开试试
● 打开浏览器输入HTTP://云服务器IP,检查一下Apache服务运行是否正常。

Test

安装PHP服务
● 安装PHP
[root@centos7 ~]# yum install -y php 
● 安装PHP 驱动程序
[root@centos7 ~]# yum install -y php-mysql
● 可以测试一下是否安装成功
[root@centos7 ~]# cd /var/www/html  ##先到html目录下
● 先做个info.php文件
[root@centos7 html]# vim info.php
<?php
phpinfo();
?>
● 重启Apache服务
[root@centos7 html]# systemctl restart httpd

● 打开浏览器访问http://云服务器ip/info.php
Test

三、安装Maria DB数据库

● 这里借鉴一下,刚开始学如何搭建博客的一篇文章中用到的数据库,MySQL比较慢,而且还麻烦。

● 安装Maria DB数据库
[root@centos7 ~]yum install -y mariadb-server mariadb*
● 设置数据库开机自启动
[root@centos7 ~]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
● 启动数据库
[root@centos7 ~]# systemctl start mariadb
●  然后
##初始化Maria DB数据库,并且设定root密码
##除了备注的地方需要输入y,其他地方都直接回车!
[root@centos7 ~]# 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       #选择Y
New 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!
重启数据库
● 重启数据库
[root@centos7 ~]# systemctl restart mariadb
● 登录数据库,创建typecho的数据库
[root@centos7 ~]# mysql -uroot -p
Enter password:          ##数据密码
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.68-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> grant all privileges on *.* to root@'%' identified by 'zxcvbnm'; #设定相关权限
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> create database typecho;   #创建typecho的库
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> flush privileges;           #重新加载相关权限
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> select User,Host,Password from mysql.user;     
+------+-----------+-------------------------------------------+
| User | Host      | Password                                  |
+------+-----------+-------------------------------------------+
| root | localhost | *D1523220ED740182587AB4860EA1EF4ECEC0F0F5 |
| root | 127.0.0.1 | *D1523220ED740182587AB4860EA1EF4ECEC0F0F5 |
| root | ::1       | *D1523220ED740182587AB4860EA1EF4ECEC0F0F5 |
| root | %         | *7DE69B235B6AD96041172B949D90F88326B74612 |
+------+-----------+-------------------------------------------+
4 rows in set (0.00 sec)

MariaDB [(none)]> exit    #退出数据库
Bye
四、安装typecho
下载:[typecho下载网址](http://typecho.org/download)

● 把下载的文件上传的云服务器中,我是使用xshell个人版连接的,可以先试一下输入rz,如果显示未安装就安装一下

● 未安装
[root@centos7 typecho]# rz
-bash: rz: command not found
● 安装lrzsz
[root@centos7 typecho]# yum -y install lrzsz
安装完成再次输入rz就能够打开传输文件的界面了,在传输之前先创建一个目录。
● 创建typecho目录
[root@centos7 ~]# mkdir typecho
● 切换到typecho目录中,因为上传文件,会上传到当前目录,所以使用时,最好在新创建的目录中
测速
[root@centos7 ~]# cd typecho
● 上传文件,上传完会在目录中显示。
● 解压typecho安装包
[root@centos7 typecho]# tar -xzvf 1.1-17.10.30-release.tar.gz 
● 解压完输入ls 会看到一个build的文件,把这个文件剪切到网站的根目录下/var/www/html.
[root@centos7 typecho]# cp -r build/* /var/www/html
● 把原来创建的info.php删除
[root@centos7 html]# rm  info.php


打开浏览器输入HTTP://云服务器IP/install.php进行后续的安装。

Test

Test

Test

Test

0

评论 (0)

取消