LAMP简介

LAMP指的Linux(操作系统)、ApacheHTTP 服务器,MySQL(有时也指MariaDB,数据库软件) 和PHP(有时也是指Perl或Python) 的第一个字母。LAMP便成了一组常用来搭建动态网站或者服务器的开源软件,本身都是各自独立的程序,但是因为常被放在一起使用,拥有了越来越高的兼容度,共同组成了一个强大的Web应用程序平台。

安装步骤:

安装服务

配置服务

启动服务

测试服务

安装服务

CentOS 6:

yum install httpd php mysql-server php-mysql

CentOS 7:

yum install httpd php php-mysql mariadb-server mariadb

(php-mysql用于支持php连接mysql的组件)

配置服务

配置httpd

Apache的主配置文件:/etc/httpd/conf/httpd.conf

主配置文件一般不去修改,其中有几个选项可以自定义修改。

DocumentRoot /var/www/html/ //指定默认主页路径

Listen 80 //httpd的监听端口,可以设置为监听指定网卡"Listen [IP:]PORT",如果需要修改端口,还要同时修改防火墙和selinux的策略

DirectoryIndex index.html

DirecotryIndex index.html //默认主页,如果有多个,优先级为由左至右

默认站点主目录:/var/www/html/

启动Apache服务后,Apache服务会到默认主目录查找默认主页文件

配置mysql

mysql和mariadb数据库服务软件默认提供一个安全脚本,执行这个脚本,可以对mysql进行基本的安全配置,比如设置密码、删除匿名用户等

mysql_secure_installation //执行MYSQL数据库安全脚本

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):

//验证输入数据库管理用户ROOT的密码,默认为空,回车即可

OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB

root user without the proper authorisation.

You already have a root password set, so you can safely answer 'n'.

Change the root password? [Y/n] y

//是否更改数据库管理员ROOT用户的密码,如果选Y则需要重复输入两遍新口令,N跳过

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

//是否移除匿名用户,即不输入用户名和密码即可访问,建议移除(Y移除,N不移除)

... 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] n

//是否禁用root用户远程登录(Y禁止,N允许)

... skipping.

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

//是否删除数据库软件自动生成的测试数据库(Y删除,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

//是否立即重载权限表(Y重载,N不重载)

... 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!

启动服务

CentOS 6:

service httpd start //启动httpd服务

service mysqld start //启动mysql数据库服务

CentOS 7:

systemctl start httpd //启动httpd服务

systemctl start mariadb //启动mariadb数据库服务

测试服务

测试WEB运行环境

echo "WEB服务器运行环境良好" >> /var/www/html/index.html

使用浏览器或者curl、link等软件访问http://127.0.0.1/index.html,如果页面显示php环境运行良好,即PHP运行环境可以正常使用,否则不能正常使用。

测试php运行环境

echo "<?php echo "PHP环境运行良好"; ?>" >> /var/www/html/index.php

使用浏览器或者curl、link等软件访问http://127.0.0.1/index.php,如果页面显示php环境运行良好,即PHP运行环境可以正常使用,否则不能正常使用。

测试运行连通性

cat << EOF >/var/www/html/mysql.php

$mysqli=new mysqli("localhost","root","00000000");

if(mysqli_connect_errno()){

echo " 连接数据库失败:";

$mysqli=null;

exit;

}

echo " 连接数据库成功!";

$mysqli->close();

?>

EOF

//$mysqli=new mysqli("localhost","root","00000000");

//localhost为服务器地址,root为mysql用户,00000000为mysql用户的密码。

使用浏览器或者curl、link等软件访问http://127.0.0.1/mysql.php,如果页面显示连接数据库成功!即PHP运行环境可以正常使用且数据库也可以正常访问,否则不能正常使用。

最后编辑httpd文件让httpd服务识别.php和.phps文件

AddType application/x-httpd-php .php

AddType application/x-httpd-php-source .phps

DirectoryIndex index.php index.html

至此LAMP环境搭建完成!

lamp配置python_LAMP搭建笔记相关推荐

  1. apollo 配置中心_Apollo配置中心搭建笔记

    如我所愿,十一小长假之前成功跳槽了. 由于准备还算充分,offer拿了不少,涨幅也普遍达到了预期. 但是在offer对比过程中我还是纠结了许久.在薪资差别不大的情况下,主要考虑的是平台规模.业务前景. ...

  2. lamp配置python_LAMP自动化安装脚本

    前辈和我说,刚开始一个个服务慢慢安装,以后要写自动安装脚步,不断学习! 仿他人改了一个脚本,按照自己的习惯,呵呵 #!/bin/bash #version:2011-9-16 #create by r ...

  3. 【CyberSecurityLearning 32】Apache配置、Apache的访问控制设定、LAMP平台的搭建

    目录 Apache配置 web服务 Apache 1.先启动httpd服务 2.通过端口来验证服务是否启动 3.建立主页 4.关于Apache服务软件的主配置文件分析 Apache的访问控制设定 1. ...

  4. Spring框架学习笔记09:基于XML配置方式搭建SSM框架实现用户登录

    文章目录 一.采用MVC架构 二.用户登录运行效果 三.基于XML配置方式搭建SSM框架实现用户登录 (一)创建数据库与表 - simonshop (t_user) 1.创建数据库 - simonsh ...

  5. Linux系列-Red Hat5平台下的LAMP网站服务搭建(四)

    Linux系列-Red Hat5平台下的LAMP网站服务搭建(四)<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com: ...

  6. GIT Windows服务端搭建笔记

    GIT Windows服务端搭建笔记 所需软件: GIT服务端: Bonobo Git Server,下载最新版 https://bonobogitserver.com/ 一:配置服务端(基于Wind ...

  7. Samba平台搭建和用户自行修改密码环境搭建笔记

    Samba 平台搭建和用户自行修改密码环境搭建笔记 系统:CentOS  release  6.5 (Final)x86_64 软件: samba                   #服务端 sam ...

  8. 服务器搭建php mysql5_Windows下php5+apache+mysql5 手工搭建笔记

    Windows下php5+apache+mysql5 手工搭建笔记 更新时间:2011年02月15日 01:35:09   作者: php运行环境对于站长们或者初学者来说可以直接用一键包的方式或者直接 ...

  9. 我的ELK搭建笔记(阿里云上部署)

    文章转载:http://www.jianshu.com/p/797073c1913f 仅用作个人学习,收藏 我的 ELK 搭建笔记(基于阿里云) "不是最好的,但一定是有良心的操作记录.&q ...

最新文章

  1. 费米悖论的三十种解释
  2. SqlHelper++
  3. 迭代最近点(Iterative Closest Point, ICP)算法及matlab实现
  4. 入职新公司,如何快速上手公司业务?
  5. java se基础巩固实例,Java SE基础巩固(十五):lambda表达式
  6. findViewById中NullPointerException的错误
  7. 企业级WLAN市场格局
  8. 区块链 数据读权限 设计方案
  9. ios蓝牙开发错误总结
  10. CGLIB动态代理模式详解
  11. winform日历控件
  12. CAN网络基础知识_20220727
  13. qqpcmgr_docpro 这个隐藏文件无法删除的问题解决方法
  14. OpenLayers 静态图(雷达拼图)叠加
  15. 用Express重写前面的记事本
  16. c++,数组与指针的差别
  17. 逻辑值分类True False
  18. /proc/uptime文件中的内容
  19. 【深入浅出Java并发编程指南】「难点 - 核心 - 遗漏」线程状态流转及生命周期的技术指南(知识点串烧)
  20. 计算机的软件教学设计七年级,计算机软件系统教学设计.doc

热门文章

  1. asp.net接受表单验证格式后再提交数据_看滴普科技大前端如何玩转el-form-renderer 表单渲染器1.14.0
  2. 简述HTML语言概念,HTML语言的基本概念和基本格式.doc
  3. cognos报表导出excel_有了这个报表工具,一键生成自定义的各种报表,还可以导出Excel...
  4. linux guide编译器,GUIDE编译器-GUIDE编程工具-GUIDE编译器下载 v1.0.2官方版-完美下载...
  5. java http url 编码_Java中的HTTP URL地址编码
  6. excel分段排序_学会这个神操作,报表填报不再五花八门,效率远超Excel
  7. android 按钮顶级效果_Android 源码之button高亮效果
  8. php电商网站开发流程图,php网上购物平台设计+ER图+流程图.doc
  9. matlab guide对话框+滑动条+弹出式菜单+列表框的使用
  10. oracle pr,PRMSCAN ORACLE碎片扫描合并工具