linux搭建简单的LAMP服务架构
LAMP:Linux ---- Apache ---- MariaDB / MySQL ---- PHP / Python
Linux 服务管理:
systemctl start //开启服务
systemctl stop //停止服务
systemctl reload //重新加载
systemctl restart //重启服务
systemctl status //查看服务运行状态
systemctl enable //设置开机自启
systemctl disble //禁止开机启动
--------------------------------------------------------
LAMP安装及启用:基于Linux主机快速构建LAMP动态网站平台,并启用相关系统服务
1)安装LAMP平台各组件
安装: yum -y install httpd mariadb-server mariadb php php-mysql
确认结果:yum list httpd mariadb-server mariadb php php-mysql
2)启用LAMP网站平台:
启动数据库:systemctl start mariadb
-->设置开机启动: systemctl enable mariadb
开启服务: systemctl restart httpd
设置开机自启:systemctl enable httpd mariadb
关闭防火墙: systemctl stop firewalld
设置开机不启动防火墙: systemctl disable firewalld
关闭SELinux保护机制:
setenforce 0 #临时关闭
vim /etc/selinux/config #永久关闭 :SELINUX=disabled
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled #修改为disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
查看SeLinux状态
getenforce
---------------------------------------------------------------------------------------------------
测试LAMP网站平台
[root@svr7 ~]# vim /var/www/html/test1.php
<?php
phpinfo(); //用来显示PHP环境信息
?>
测试PHP访问数据库
本机的mariadb数据库服务未做配置时,管理员账号为root、密码为空。
[root@svr7 ~]# vim /var/www/html/test2.php
<?php
$link=mysql_connect('localhost','root','');
if($link) echo "Success !!"; //成功则显示 Success !!
else echo "Failure !!"; //失败则显示 Failure !!
mysql_close(); //关闭数据库连接
?>
浙公网安备 33010602011771号