热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

CentOS5.6快速搭建LAMP

在虚拟机下安装了个CentOS,5.6版本的。利用NAT模式与宿主pc共享上网!当然可以采用编译源码的方式搭建lamp。这里只是介绍快速搭建php开发框架的方法。其实也没什么,主要是是是使用linux的yum来在线安装。如果上不了网请查找编译源码搭建lamp的文章。网上
在虚拟机下安装了个CentOS,5.6版本的。利用NAT模式与宿主pc共享上网!    

当然可以采用编译源码的方式搭建lamp。这里只是介绍快速搭建php开发框架的方法。其实也没什么,主要是是是使用linux的yum来在线安装。如果上不了网请查找编译源码搭建lamp的文章。网上N多的哈^_^ 

   1.安装mysql数据库

     命令行下:yum -y install mysql mysql-server    

     Setting up Install Process
     Setting up repositories... ....

     ....................................................

     Installed: mysql-server.i386 0:4.1.20-1.RHEL4.1
     Dependency Installed: mysql.i386 0:4.1.20-1.RHEL4.1 perl-DBD-MySQL.i386 0:2.9004-3.1 perl-DBI.i386 0:1.40-8
     Complete!

    安装完毕,配置mysql:

   命令行下:vi /etc/my.cnf        提示:红色字为添加的行,主要是设置数据库默认的字符集为utf8

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
default-character-set = utf8
# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
# symbolic-links=0

[mysql]

default-character-set = utf8

 保存退出后,设置mysql服务随系统自启动,

命令行下:chkconfig mysqld on

       可以通过chkconfig --list mysqld 查看设置状态,显示 mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off,2~5显示On就可以了。
 

  启动mysql服务, /etc/rc.d.init.d/mysqld start

      Initializing MySQL database:         [ OK ]
      Starting MySQL:              [ OK ]

 

可以登录mysql进行测试:mysql -u -root                     *(默认root的密码是空的)

出现提示符“mysql〉”后,设置root的密码。

以下动作出于安全考虑:

命令行下:mysql> use  mysql;

                    mysql> set password for root@localhost = password('你的密码');

                    mysql> set password for root@localhost.localdomain=password('你的密码');

删除匿名用户: mysql> delete from user where user='';     

删除测试数据库: mysql> drop database test; 

至此,mysql数据安装完成,可以用sql操作mysql测试。

2.安装apache

命令行下:yum -y install apache

Setting up Install Process
Setting up repositories

....................................

Complete!

接下来配置apache,编辑Apache的配置文件,命令行下:vi /etc/httpd/conf/httpd.conf

#
# Don't give away too much information about all the subcomponents
# we are running. Comment out this line if you don't mind remote sites
# finding out what major optional modules you are running
ServerTokens OS  ← 找到这一行,将“OS”改为“Prod”(在出现错误页的时候不显示服务器操作系统的名称)
 ↓
ServerTokens Prod   ← 变为此状态

#
# Optionally add a line containing the server version and virtual host
# name to server-generated pages (internal error documents, FTP directory
# listings, mod_status and mod_info output etc., but not CGI generated
# documents or custom error documents).
# Set to "EMail" to also include a mailto: link to the ServerAdmin.
# Set to one of: On | Off | EMail
#
ServerSignature On  ← 找到这一行,将“On”改为“Off”
 ↓
ServerSignature Off  ← 在错误页中不显示Apache的版本

#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If this is not set to valid DNS name for your host, server-generated
# redirections will not work. See also the UseCanonicalName directive.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
# You will have to access it by its address anyway, and this will make
# redirections work in a sensible way.
#
#ServerName new.host.name:80  ← 修改主机名
 ↓
ServerName www.linuxidc.com:80  ← 根据实际情况修改,端口号保持默认的80

#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs-2.0/mod/core.html#options
# for more information.
#

DirectoryIndex index.html index.html.var       ←找到这一行,

DirectoryIndex index.html index.php               ← 添加默认index.php文件


Options Indexes FollowSymLinks  ← 找到这一行,删除“Indexes”,并添加“Includes”、“ExecCGI”
 ↓
Options Includes ExecCGI FollowSymLinks  ← 允许服务器执行CGI及SSI

#
# AddHandler allows you to map certain file extensions to "handlers":
# actions unrelated to filetype. These can be either built into the server
# or added with the Action directive (see below)
#
# To use CGI scripts outside of ScriptAliased directories:
# (You will also need to add "ExecCGI" to the "Options" directive.)
#
#AddHandler cgi-script .cgi  ← 找到这一行,去掉行首的“#”,并在行尾添加“.pl”
 ↓
AddHandler cgi-script .cgi .pl  ← 允许扩展名为.pl的CGI脚本运行

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None  ← 找到这一行,将“None”改为“All”
 ↓
AllowOverride All  ← 变为此状态,允许.htaccess

#
# Specify a default charset for all pages sent out. This is
# always a good idea and opens the door for future internationalisation
# of your web site, should you ever want it. Specifying it as
# a default does little harm; as the standard dictates that a page
# is in iso-8859-1 (latin1) unless specified otherwise i.e. you
# are merely stating the obvious. There are also some security
# reasons in browsers, related to Javascript and URL parsing
# which encourage you to always set a default char set.
#
AddDefaultCharset UTF-8  ← 找到这一行,在行首添加“#”
 ↓
#AddDefaultCharset UTF-8  ← 不使用UTF-8作为网页的默认编码
AddDefaultCharset GB2312  ← 并接着添加这一行(添加GB2312为默认编码)

  ← 找到这一个标签,并在标签中更改相应选项
  Options Indexes MultiViews  ← 找到这一行,将“Indexes”删除
    ↓
  Options MultiViews   ← 变为此状态(不在浏览器上显示树状目录结构)
AllowOverride None
Order allow,deny
Allow from all

命令行下:  chkconfig httpd on  ← 设置HTTP服务自启动

                     chkconfig --list httpd
                     httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off  
← 确认2--5为on的状态就OK

                      /etc/rc.d/init.d/httpd start  ← 启动HTTP服务
                     Starting httpd:              [ OK ] ← 启动成功会出现OK

在浏览器浏览http://127.0.0.1  就可以看到测试页面出现,表示安装成功。


推荐阅读
  • 如何实现织梦DedeCms全站伪静态
    本文介绍了如何通过修改织梦DedeCms源代码来实现全站伪静态,以提高管理和SEO效果。全站伪静态可以避免重复URL的问题,同时通过使用mod_rewrite伪静态模块和.htaccess正则表达式,可以更好地适应搜索引擎的需求。文章还提到了一些相关的技术和工具,如Ubuntu、qt编程、tomcat端口、爬虫、php request根目录等。 ... [详细]
  • 本文介绍了在开发Android新闻App时,搭建本地服务器的步骤。通过使用XAMPP软件,可以一键式搭建起开发环境,包括Apache、MySQL、PHP、PERL。在本地服务器上新建数据库和表,并设置相应的属性。最后,给出了创建new表的SQL语句。这个教程适合初学者参考。 ... [详细]
  • 目录浏览漏洞与目录遍历漏洞的危害及修复方法
    本文讨论了目录浏览漏洞与目录遍历漏洞的危害,包括网站结构暴露、隐秘文件访问等。同时介绍了检测方法,如使用漏洞扫描器和搜索关键词。最后提供了针对常见中间件的修复方式,包括关闭目录浏览功能。对于保护网站安全具有一定的参考价值。 ... [详细]
  • 这是原文链接:sendingformdata许多情况下,我们使用表单发送数据到服务器。服务器处理数据并返回响应给用户。这看起来很简单,但是 ... [详细]
  • mac php错误日志配置方法及错误级别修改
    本文介绍了在mac环境下配置php错误日志的方法,包括修改php.ini文件和httpd.conf文件的操作步骤。同时还介绍了如何修改错误级别,以及相应的错误级别参考链接。 ... [详细]
  • 一句话解决高并发的核心原则
    本文介绍了解决高并发的核心原则,即将用户访问请求尽量往前推,避免访问CDN、静态服务器、动态服务器、数据库和存储,从而实现高性能、高并发、高可扩展的网站架构。同时提到了Google的成功案例,以及适用于千万级别PV站和亿级PV网站的架构层次。 ... [详细]
  • 如何提高PHP编程技能及推荐高级教程
    本文介绍了如何提高PHP编程技能的方法,推荐了一些高级教程。学习任何一种编程语言都需要长期的坚持和不懈的努力,本文提醒读者要有足够的耐心和时间投入。通过实践操作学习,可以更好地理解和掌握PHP语言的特异性,特别是单引号和双引号的用法。同时,本文也指出了只走马观花看整体而不深入学习的学习方式无法真正掌握这门语言,建议读者要从整体来考虑局部,培养大局观。最后,本文提醒读者完成一个像模像样的网站需要付出更多的努力和实践。 ... [详细]
  • 一、Hadoop来历Hadoop的思想来源于Google在做搜索引擎的时候出现一个很大的问题就是这么多网页我如何才能以最快的速度来搜索到,由于这个问题Google发明 ... [详细]
  • 本文介绍了Python高级网络编程及TCP/IP协议簇的OSI七层模型。首先简单介绍了七层模型的各层及其封装解封装过程。然后讨论了程序开发中涉及到的网络通信内容,主要包括TCP协议、UDP协议和IPV4协议。最后还介绍了socket编程、聊天socket实现、远程执行命令、上传文件、socketserver及其源码分析等相关内容。 ... [详细]
  • 本文介绍了如何使用php限制数据库插入的条数并显示每次插入数据库之间的数据数目,以及避免重复提交的方法。同时还介绍了如何限制某一个数据库用户的并发连接数,以及设置数据库的连接数和连接超时时间的方法。最后提供了一些关于浏览器在线用户数和数据库连接数量比例的参考值。 ... [详细]
  • 禁止程序接收鼠标事件的工具_VNC Viewer for Mac(远程桌面工具)免费版
    VNCViewerforMac是一款运行在Mac平台上的远程桌面工具,vncviewermac版可以帮助您使用Mac的键盘和鼠标来控制远程计算机,操作简 ... [详细]
  • 本文介绍了使用PHP实现断点续传乱序合并文件的方法和源码。由于网络原因,文件需要分割成多个部分发送,因此无法按顺序接收。文章中提供了merge2.php的源码,通过使用shuffle函数打乱文件读取顺序,实现了乱序合并文件的功能。同时,还介绍了filesize、glob、unlink、fopen等相关函数的使用。阅读本文可以了解如何使用PHP实现断点续传乱序合并文件的具体步骤。 ... [详细]
  • Oracle分析函数first_value()和last_value()的用法及原理
    本文介绍了Oracle分析函数first_value()和last_value()的用法和原理,以及在查询销售记录日期和部门中的应用。通过示例和解释,详细说明了first_value()和last_value()的功能和不同之处。同时,对于last_value()的结果出现不一样的情况进行了解释,并提供了理解last_value()默认统计范围的方法。该文对于使用Oracle分析函数的开发人员和数据库管理员具有参考价值。 ... [详细]
  • 高质量SQL书写的30条建议
    本文提供了30条关于优化SQL的建议,包括避免使用select *,使用具体字段,以及使用limit 1等。这些建议是基于实际开发经验总结出来的,旨在帮助读者优化SQL查询。 ... [详细]
  • 本文介绍了在Windows环境下如何配置php+apache环境,包括下载php7和apache2.4、安装vc2015运行时环境、启动php7和apache2.4等步骤。希望对需要搭建php7环境的读者有一定的参考价值。摘要长度为169字。 ... [详细]
author-avatar
SuperBaby蜜
这个家伙很懒,什么也没留下!
Tags | 热门标签
RankList | 热门文章
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有