AIOps 一场颠覆传统运维的盛筵
764
2022-10-16
LAMP环境搭建
一、什么是LAMP环境?
在中小型公司当中,要想让公司的网站迅速上线,就会采用到LAMP环境。那什么是LAMP环境呢?我们先说一下网站上边数据的构成,网站中数据由两种组成,一种是静态数据,一种是动态数据。
静态数据:每一个用户看到的相同的数据(比如:网页上的图片,动画,文字等),一般由html,css,jsp,php等静态语言编写。动态数据:每一个用户得到不一样的数据(比如,用户的个人信息,密码,照片,文件等),一般是由中间件去调用后端数据库去得到。
所以,我们构建一个简单的网站一般会有三部分组成,运行静态语言的web服务,关系型数据库服务,和网站代码。
LAMP = Linux + Apache + Mysql + PHP
也就是说:LAMP环境就是在Linux平台上使用Apache(http)服务运行PHP静态语言写成的web代码,用户的数据放在后端的Mysql数据库当中
二、环境准备
由于是实验环境,我们就不去自己写一个PHP代码了,我们直接借用一个开源的博客系统wordpress,然后将其代码放在http服务的工作目录下
wordpress的下载路径为:https://wordpress.org/download/
Linux平台环境:test1 192.168.1.41
三、软件安装
[root@test1 ~]# yum -y install php php-mysql mariadb-server httpd
php:提供php运行环境php-mysql:连接php和mysql的工具mariadb-server:数据库,存放PHP环境运行时的数据httpd:为用户提供web界面
四、配置wordpress
[root@test1 ~]# tar -zxvf wordpress-4.6.13.tar.gz[root@test1 ~]# cp -rvf wordpress/* var/www/html/[root@test1 ~]# cd var/www/html/[root@test1 html]# mv wp-config-sample.php wp-config.php[root@test1 html]# vim wp-config.phpdefine('DB_NAME', 'wordpress');define('DB_USER', 'wordpress');define('DB_PASSWORD', 'wordpresspwd');define('DB_HOST', 'localhost');
define('DB_NAME', 'wordpress'); #代表wordpress去连接数据库的库名
define('DB_USER', 'wordpress'); #代表wordpress去连接数据库的用户名
define('DB_PASSWORD', 'wordpresspwd'); #代表wordpress去连接数据库的用户名的密码
define('DB_HOST', 'localhost'); #代表wordpress去连接数据库的地址
五、配置mysql
[root@test1 ~]# systemctl start mariadb[root@test1 ~]# mysql_secure_installation 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 MariaDBroot user without the proper authorisation.Set root password? [Y/n] yNew password: Re-enter new password: Password updated successfully!Reloading privilege tables.. ... Success!By default, a MariaDB installation has an anonymous user, allowing anyoneto log into MariaDB without having to have a user account created forthem. This is intended only for testing, and to make the installationgo a bit smoother. You should remove them before moving into aproduction environment.Remove anonymous users? [Y/n] y ... Success!Normally, root should only be allowed to connect from 'localhost'. Thisensures that someone cannot guess at the root password from the network.Disallow root login remotely? [Y/n] n ... skipping.By default, MariaDB comes with a database named 'test' that anyone canaccess. This is also intended only for testing, and should be removedbefore moving into a production environment.Remove test database and access to it? [Y/n] y - Dropping test database... ... Success! - Removing privileges on test database... ... Success!Reloading the privilege tables will ensure that all changes made so farwill 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 MariaDBinstallation should now be secure.Thanks for using MariaDB![root@test1 ~]# mysql -uroot -p000000MariaDB [(none)]> create database wordpress;Query OK, 1 row affected (0.00 sec)MariaDB [(none)]> create user wordpress@'%' identified by 'wordpresspwd';Query OK, 0 rows affected (0.00 sec)MariaDB [(none)]> grant all on wordpress.* to wordpress@'%' identified by 'wordpresspwd';Query OK, 0 rows affected (0.00 sec)
1、启动mysql
2、初始化数据库
3、创建数据库wordpress
4、创建数据库用户wordpress
5、赋予用户wordpress对库wordpress操作的所以权限
六、启动http并验证
[root@test1 ~]# systemctl start httpd
发表评论
暂时没有评论,来抢沙发吧~