LAMP是Linux Apache MySQL PHP 的简写,即把Apache、MySQL以及PHP安装在Linux系统上,组成一个环境来运行PHP的脚本语言,通常是网站。
LAMP是一组常用来搭建动态网站或者服务器的开源软件,本身都是各自独立的程序,但是因为常被放在一起使用,拥有了越来越高的兼容度共同组成了一个强大的web应用程序平台。而从网站的流量上来说,70%以上的访问流量是LAMP来提供的,LAMP是最强大的网站解决方案。
MariaDB是MySQL的一个分支。
实验步骤:
本次实验使用了http+mariadb+php的组合。
很重要的一点:你的yum源必须要有足够的包,否则下面的一些工具你就只能通过网址下载。
-
首先关闭防火墙和selinux,当然如果你觉得直接关闭防火墙不安全,那么可以使用iptables来制定规则,允许指定的端口进行指定的动作,我这里就直接采用简单的方法,直接关闭防火墙。
[root@localhost ~]# systemctl stop firewalld [root@localhost ~]# setenforce 0
-
安装mariadb,初始化配置mariadb,设置其密码,并登录,进行测试。mariadb它没有初始的密码,可直接设置,且对密码复杂程度无要求。
如果你要选择安装mysql,那么第四步你就要下载另外一个工具,phpMyAdmin不支持mysql使用。还有mysql有初始密码,首次登录你要先查看初始密码,才可对mysql进行初始化配置、设置密码。查看mysql初始密码命令“ grep password /var/log/mysql.log ”。mysql对密码的复杂度有要求,至少8位,且必须包含数字、字母和特殊符号。#安装mariadb,两个都要安装 [root@localhost ~]# yum install mariadb mariadb-server.x86_64 -y #开启mariadb服务 [root@localhost ~]# systemctl start mariadb.service #初始化配置mariadb,并设置其密码 [root@localhost ~]# 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 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] 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? [Y/n] y ... 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] n ... skipping. Reloading the privilege tables will ensure that all changes made so far will take effect immediately. 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! #登录数据库,查看数据库,也可做适当的测试 [root@localhost ~]# mysql -uroot -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 8 Server version: 5.5.60-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)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | test | +--------------------+ 4 rows in set (0.00 sec) MariaDB [(none)]>
-
安装php、apche(即http)、mod_ssl
[root@localhost ~]# yum install php httpd mod_ssl -y [root@bogon ~]# systemctl stop mariadb.service
-
安装phpMAdmine图形化管理工具。
如果你刚刚安装的是mysql的话,此工具不支持mysql登录,你需要下载另一个图形化管理工具wordpress。[root@bogon yum.repos.d]# yum install epel-release.noarch -y [root@bogon ~]# rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm [root@bogon ~]# sudo yum install phpmyadmin [root@bogon ~]# cd /etc/httpd/conf.d/ [root@bogon conf.d]# ls autoindex.conf php.conf phpMyAdmin.conf README ssl.conf userdir.conf welcome.conf [root@bogon conf.d]# vim phpMyAdmin.conf <RequireAny> Require ip 127.0.0.1 192.168.192.0/24 Require ip ::1 </RequireAny> <RequireAny> Require ip 127.0.0.1 192.168.192.0/24 Require ip ::1 </RequireAny> [root@bogon ~]# systemctl start httpd.service [root@bogon ~]# systemctl start mariadb.service
-
在物理机测试
接下来使用浏览器通过phpMyAdmin登录mariadb
在地址栏中输入 “ 192.168.192.130/phpMyAdmin ”
然后输入 “ root ” 和刚刚设置的密码,登录
接下来就开始你们自己的表演啦。