在虚拟机下安装了个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为默认编码)

<Directory "/var/www/icons">  ← 找到这一个标签,并在标签中更改相应选项
Options Indexes MultiViews  ← 找到这一行,将“Indexes”删除

Options MultiViews   ← 变为此状态(不在浏览器上显示树状目录结构)
AllowOverride None
Order allow,deny
Allow from all
</Directory>

命令行下:  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  就可以看到测试页面出现,表示安装成功。3.安装php

命令行下:yum -y install php

Setting up Install Process

Setting up repositories
Reading repository metadata in from local files
...............................

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

Installing: php-pear ######################### [2/2]
Installed: php.i386 0:4.3.9-3.15
Dependency Installed: php-pear.i386 0:4.3.9-3.15
Complete!

安装完毕,配置文件位于/etc/php.ini。可以修改配置。

4.测试环境

建立一个php文件,

命令行下:vi  /var/www/html/test.php

输入代码:

<?php 
        $host = 'localhost'; 
        $user = 'root'; 
        $pwd = 'password'; 
        $link = mysql_connect( $host, $user, $pwd ); 
        if( !$link ){

die( '连接失败' ); 
        }else{ 
               echo '连接成功!'; 
        } 
        mysql_close( $link ); 
?> 
保存退出,在浏览器下浏览 http://127.0.0.1/test.php ,可以看到php的相关信息页面。

至此,centos上利用yum在线快速搭建php环境就完成了。

转载于:https://blog.51cto.com/dason/640314

CentOS 5.6 快速搭建LAMP相关推荐

  1. CentOS 6.7快速搭建lamp环境

    安装前要关闭防火墙,防止外网不能访问,这一点很重要,要不然外网访问不了: ①关闭防火墙:service iptables stop ②永久关闭防火墙:chkconfig iptables off ③查 ...

  2. lamp php5.5,CentOS 5.5快速搭建Apache+PHP5+MySQL完美Web服务器(LAMP)

    CentOS 5.5快速搭建Apache+PHP5+MySQL完美Web服务器(LAMP) By sole | Friday, May 13, 2011 在网上看了很多,修改多次,也试验多次,均没有问 ...

  3. centos7快速搭建LAMP

    用yum快速搭建LAMP平台 实验环境: [root@nmserver-7 html]# cat /etc/redhat-release CentOS release 7.3.1611 (AltArc ...

  4. 快速搭建LAMP环境

    快速搭建LAMP环境 Linux+Apache+MySQL+PHP一组常用来搭建动态网站或者服务器的开源软件,本身都是各自独立的程序,但是因为常被放在一起使用,拥有了越来越高的兼容度,共同组成了一个强 ...

  5. 快速搭建LAMP架构

    快速搭建LAMP架构 1.安装apache 2.部署mysql 3.部署php结合apache 4.验证 5.部署一个论坛disuz 1.安装apache [root@localhost ~]# yu ...

  6. CentOS 6.5使用yum快速搭建LAMP环境

    2019独角兽企业重金招聘Python工程师标准>>> 由于这里采用yum方式安装,前提是我们必须配置好yum源.为了加快下载速度,建议使用网易的yum源.参考:CentOS配置网易 ...

  7. 使用yum快速搭建LAMP和配置phpMyAdmin

    使用Linux系统架设网站,LAMP是非常流行的一种解决方案.LAMP组合有着极高的性能,完善的支持体系,灵活的配置方法,但是Lamp架构其本身也越来越臃肿,在Lamp安装完成后最好进行针对硬件的优化 ...

  8. 使用阿里云集成包快速搭建LAMP+FTP教程

    LAMP集成包安装步骤 1.下载开发集成包 下载最新版的阿里云市场提供的WEB开发集成包(内含Apache.Mysql.PHP.vsftpd) #Linux指令wget http://gongdan. ...

  9. CentOS 7.x 快速搭建ARK服务器

    本人菜鸟一枚,最近喜欢上了ark,也找到了2个基友,但是在别的服玩的不是很开心(非人民币玩家,你们懂),刚好有台闲置的拯救者14笔记本,i7-4720HQ.16G内存.128G三星970pro,1T机 ...

最新文章

  1. 常见的网络***有哪些?
  2. opengl库中gl glu glut glaux的区别
  3. [USACO1.2]方块转换 Transformations
  4. POJ 2483 Cows(树状数组)
  5. MyEclipse - 查询使用的JDK版本
  6. LeetCode 1187. 使数组严格递增(DP)*
  7. PID控制器开发笔记之九:基于前馈补偿的PID控制器的实现
  8. 计算机重启是什么原因,电脑自动重启,该怎么办,到底是什么原因,我来详细说明?...
  9. android 驱动(6)---DTS 分析
  10. python123m与n的数学运算_python小白进阶之路三——循环结构入门练习+Random库练习...
  11. 银行业务调度系统学习
  12. nginx proxy_pass和rewrite
  13. 《FLUENT 14.0超级学习手册》—— 导读
  14. ubuntu 刷新频率 如何查看_ubuntu如何调整显示的分辨率和刷新率?
  15. Android实现一个APP只能在一部手机上使用
  16. 简单理解时间同步和时钟同步
  17. 手把手教学linux上扩容和缩减swap分区。
  18. python绘制等值线图_使用python祏rfer绘制等值线图的方式适题。
  19. PHP Laravel 队列技巧:Fail、Retry 或者 Delay
  20. MySQL高级之外键、表关联、数据导入及导出

热门文章

  1. 终于找到你!如何将前端console.log的日志保存成文件?
  2. Java学习优秀网站
  3. RTSP服务器之————rtsp-server(轻量级RTSP / RTP流媒体服务器)
  4. 完美完全卸载Oracle 11g数据库
  5. 如何快速编写并运行Tiny模板语言?
  6. 数据仓库的 RDBMS 性能优化指南
  7. Ajax跨域提交JSON和JSONP
  8. 论接单报价管理与ERP信息化管理的重要性
  9. retain、strong、weak、assign区别
  10. android studio no marked region found along edge Found along top edge