Pure Soul

  1. 首页
  2. 个人建站
  3. 正文

个人建站——第二步:搭建LAMP环境

2020年4月1日 1162点热度 1人点赞 0条评论

搭建好服务器之后,随后就可以搭建博客环境,我选择的是LAMP+WordPress。显而易见,LAMP=Linux+Apache+Mariadb+PHP,WordPress就不用说了,它是使用PHP语言开发的博客平台,用户可以在支持PHP和MySQL数据库的服务器上架设属于自己的网站。

刚刚讲了LAMP环境实际上是由四部分组成的,Linux系统不再多说,下面来讲讲余下的A,M,P如何安装,注意需要按顺序安装

目录

  • 1、安装Apache
  • 2、安装Mariadb数据库
  • 3、安装PHP
  • 4、安装PHPMyAdmin

1、安装Apache

#利用yum命令安装Apache
yum -y install httpd
#启动Apache
systemctl start httpd.service
#设置为开机启动
systemctl enable httpd.service
#关闭防火墙(也可以设置仅80、443通过,这里介绍的是简单unsafe方法)
systemctl stop firewalld
#禁止防火墙开机启动
systemctl disable firewalld

安装成功后,在浏览器地址栏中输入你的vps的IP地址,就可以看见熟悉的界面。这就表示我们安装Apache成功了
Apache界面

2、安装Mariadb数据库

#yum安装
yum -y install mariadb-server mariadb

#启动数据库并设置为开机启动
systemctl start mariadb.service
systemctl enable mariadb.service

#需要设置数据库数据root密码(需牢记)
mysql_secure_installation

输入完上面命令进入如下界面。截取部分ssh代码行,以供参考:

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] (是否设置root密码:Y)
New password:(需牢记)
Re-enter new password:(需牢记)
Password updated successfully!
Reloading privilege tables..
 ... Success!

Remove anonymous users? [Y/n] (是否移除匿名用户:Y)
 ... Success!

Disallow root login remotely? [Y/n] (是否禁止远程root登陆:n)
 ... skipping.

Remove test database and access to it? [Y/n] (是否删除测试数据库:Y)

Reload privilege tables now? [Y/n] (重新载入:Y)
 ... 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!

到这里我们就完成了Mariadb数据库的安装和root密码的配置。

3、安装PHP

#安装PHP及其组件
yum -y install php
yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel

#重启httpd服务,如果你用的不是centos7以上的操作系统,那么systemctl命令可能无法使用
systemctl restart httpd.service

4、安装PHPMyAdmin

PHPMyAdmin不在LAMP的构成之内,我们为什么要安装它呢?因为当wordpress安装好之后,我们没有上传文件的权限,需要去数据库里面开放,PHPMyAdmin就为我们提供了很好的图形话数据库管理界面,以后的备份也要用到它。

#yum安装
yum install phpMyAdmin
#如果上一条语句安装不成功,vps自带的发行版本找不到安装包,则换源 

yum install epel-release 

sudo rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

#配置phpMyAdmin 
vi /etc/httpd/conf.d/phpMyAdmin.conf 

下面截取部分修改好的数据,按照此版本修改即可,vi进入编辑界面之后是搜索模式,按s键进入编辑模式,按照下面编辑好了之后,按Esc退出,之后输入:wq保存退出。

<Directory /usr/share/phpMyAdmin/>
   AddDefaultCharset UTF-8

   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
     # Require ip 127.0.0.1     #加上注释
     # Require ip ::1           #加上注释
       Require all granted      #这一行加上
     </RequireAny>
   </IfModule>
   <IfModule !mod_authz_core.c>
     # Apache 2.2
     Order Deny,Allow
     Deny from All
     Allow from 127.0.0.1
     Allow from ::1
   </IfModule>
</Directory>

<Directory /usr/share/phpMyAdmin/setup/>
   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
     # Require ip 127.0.0.1      #加上注释
     # Require ip ::1            #加上注释
       Require all granted       #这一行加上,并且在配置文件当中把这一行的注释去掉,否则接下来不能正确的重启http服务
     </RequireAny>
   </IfModule>
   <IfModule !mod_authz_core.c>
     # Apache 2.2
     Order Deny,Allow
     Deny from All
     Allow from 127.0.0.1
     Allow from ::1
   </IfModule>
</Directory>

# These directories do not require access over HTTP - taken from the original
# phpMyAdmin upstream tarball
#
<Directory /usr/share/phpMyAdmin/libraries/>
    Order Deny,Allow
    Deny from All
    Allow from None
</Directory>

修改完之后

#重启http服务
systemctl restart  httpd.service

这样,我们就完成了PHPMyAdmin的全部安装。在浏览器地址栏输入 http://x.x.x.x/phpMyAdmin 就可以看见PHP管理界面了,x.x.x.x是你自己vps的IP地址

标签: VPS 个人建站
最后更新:2020年12月28日

ycq

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

COPYRIGHT © 2021 oo2ee.com. ALL RIGHTS RESERVED.

THEME KRATOS MADE BY VTROIS