分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > IT知识

第二十三期 Linux的LAMP网站平台构建

发布时间:2023-09-06 01:43责任编辑:蔡小小关键词:Linux
在CentOS7系统中开启Web/FTP等网络服务应用时,可能会收到默认配置的防火墙、SELinux等安全防护策略影响。为了避免干扰,学习过程中建议禁止这些保护机制。

关闭防火墙策略:

[root@svr7 ~]# systemctl ?stop ?firewalld[root@svr7 ~]# systemctl ?disable ?firewalld

关闭SELinux保护机制:

[root@svr7 ~]# setenforce ?0 ?????????????????????//立即切换为宽松模式[root@svr7 ~]# getenforce ?????????????????????//确认结果Permissive[root@svr7 ~]# vim ?/etc/selinux/config ?????????//以后开机不再强制生效SELINUX=permissive ?????????????????????????????????//宽松模式

安装LAMP平台各组件,启动LAMP平台

1)安装LAMP各组件软件包

主要包括:httpd、mariadb-server、mariadb、php、php-mysql。

[root@svr7 ~]# yum ?-y ?install ?httpd ?mariadb-server ?mariadb ?php ?php-mysql.. ..已安装: ?mariadb.x86_64 1:5.5.52-1.el7 ??????????????????????????????mariadb-server.x86_64 1:5.5.52-1.el7 ???????????????????????php.x86_64 0:5.4.16-42.el7 ?????????????????????????????????php-mysql.x86_64 0:5.4.16-42.el7 ?????????????????????????作为依赖被安装: ?libzip.x86_64 0:0.10.1-8.el7 ???????????????????????????????perl-DBD-MySQL.x86_64 0:4.023-5.el7 ????????????????????????php-cli.x86_64 0:5.4.16-42.el7 ?????????????????????????????php-common.x86_64 0:5.4.16-42.el7 ??????????????????????????php-pdo.x86_64 0:5.4.16-42.el7 ???????????????????????????完毕!

2)启动LAMP组建对应的系统服务

主要包括:Web服务httpd、数据库服务mariadb。PHP网页解析的功能由httpd服务在需要时调用相应的模块文件实现,无对应服务。

[root@svr7 ~]# systemctl ?restart ?httpd ?mariadb ?????????//起服务[root@svr7 ~]# systemctl ?enable ?httpd ?mariadb ?????????//设置开机自启Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

编写测试网页,确保LAMP平台可用

1)测试PHP网页解析

在Web服务器的网页目录下新建一个测试网页 test1.php。

[root@svr7 ~]# vim ?/var/www/html/test1.php<?phpphpinfo(); ?????????????????????????????????????????????//显示PHP环境信息?>

通过Firefox浏览器访问 http://127.0.0.1/test1.php ,可以看到PHP环境信息

2)测试PHP网页解析及数据库连接

在Web服务器的网页目录下新建另一个测试网页 test2.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(); ?????????????????????????????//关闭数据库连接?>

通过Firefox浏览器访问 http://127.0.0.1/test2.php ,可以看到数据库连接的反馈信息,正常结果页面应显示"Success !!"

谢谢大家

第二十三期 Linux的LAMP网站平台构建

原文地址:http://blog.51cto.com/13556999/2073658

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved