CentOS LAMP配置手册
创始人
2024-07-23 16:41:44
0

 

LAMP 

图-LAMP

  今天用yum方法搭建起了个CentOS LAMP环境,中间遇到了很多问题,经过google和各位前辈的帮助,终于将环境搭建起来,现在把完整的步骤记录下来:

  一、换源,sohu的相当好用。

  备份CentOS-Base.repo

  view sourceprint?cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak

  替换源

  用vi打开CentOS-Base.repo,并将内容清空,然后将下面的内容复制进去,并保存。

  view sourceprint?# CentOS-Base.repo

  #

  # This file uses a new mirrorlist system developed by Lance Davis for CentOS.

  # The mirror system uses the connecting IP address of the client and the

  # update status of each mirror to pick mirrors that are updated to and

  # geographically close to the client. You should use this for CentOS updates

  # unless you are manually picking other mirrors.

  [base]

  name=CentOS-$releasever - Base

  baseurl=http://mirrors.sohu.com/centos/$releasever/os/$basearch/

  gpgcheck=1

  gpgkey=http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-5

  #released updates

  [updates]

  name=CentOS-$releasever - Updates

  baseurl=http://mirrors.sohu.com/centos/$releasever/updates/$basearch/

  gpgcheck=1

  gpgkey=http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-5

  #packages used/produced in the build but not released

  [addons]

  name=CentOS-$releasever - Addons

  baseurl=http://mirrors.sohu.com/centos/$releasever/addons/$basearch/

  gpgcheck=1

  gpgkey=http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-5

  #additional packages that may be useful

  [extras]

  name=CentOS-$releasever - Extras

  baseurl=http://mirrors.sohu.com/centos/$releasever/extras/$basearch/

  gpgcheck=1

  gpgkey=http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-5

  #additional packages that extend functionality of existing packages

  [centosplus]

  name=CentOS-$releasever - Plus

  baseurl=http://mirrors.sohu.com/centos/$releasever/centosplus/$basearch/

  gpgcheck=1

  enabled=0

  gpgkey=http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-5

#p#

 

  二、更新一下系统

  view sourceprint?#yum -y update

  三、安装Apache

  view sourceprint?#yum install httpd

  安装完成后,用

  view sourceprint?/etc/init.d/httpd start

  启动apache

  设为开机启动

  view sourceprint?#chkconfig httpd on

  四、安装MYSQL

  view sourceprint?#yum install mysql mysql-server

  同样,完成后,用

  view sourceprint?/etc/init.d/mysqld start

  启动mysql

  设置MYSQL密码

  view sourceprint?#/usr/bin/mysqladmin -u root -h localhost password '新密码'

  #mysql -u root –p #进入MYSQL,

  #Enter Password: # [输入密码即可]

  更新MYSQL密码

  view sourceprint?mysql> USE mysql;

  mysql> UPDATE user SET Password=PASSWORD('newpassword') WHERE user='root';

  mysql> FLUSH PRIVILEGES;

  允许远程登录

  view sourceprint?mysql>GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;

  完成后就能用mysql-front远程管理mysql了。

  让MYSQL数据库更安全

  view sourceprint?mysql -u root -p [此时会要求你输入刚刚设置的密码,输入后回车即可

  mysql> DROP DATABASE test;     [删除test数据库]

  mysql> DELETE FROM mysql.user WHERE user =’’;       [删除匿名帐户]

  mysql> FLUSH PRIVILEGES;     [重载权限]

  mysql> exit;                            [退出MYSQL]

  设为开机启动

  view sourceprint?#chkconfig mysqld on

#p#

  五、安装PHP

  view sourceprint?#yum install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml libmcrypt

  view sourceprint?#/etc/init.d/httpd start [运行HTTPD]

  六、测试一下

  在/var/www/html/新建个test.php文件,将以下内容写入,然后保存。

  view sourceprint?

  phpinfo();

  ?>

  然后在客户端浏览器里打开http://IP/test.php,若能成功显示,则表示安装成功。

  至此,安装完毕。感慨,YUM真是太好用了。

通过文章的介绍,我们应该都能掌握CentOS LAMP配置技巧,在以后的构建过程中就简单多了!

【编辑推荐】

  1. 简单的在 ubuntu 下安装lamp
  2. 搭建LAMP测试平台
  3. LAMP架构——我的工作心得
  4. LAMP攻略之MySQL常用语法语句
  5. LAMP攻略之PHP执行sql语句的写法
  6. LAMP攻略之MySQL数据库结构和数据导出及导入
  7. LAMP攻略之MySQL索引

 

 

 

相关内容

热门资讯

如何允许远程连接到MySQL数... [[277004]]【51CTO.com快译】默认情况下,MySQL服务器仅侦听来自localhos...
如何利用交换机和端口设置来管理... 在网络管理中,总是有些人让管理员头疼。下面我们就将介绍一下一个网管员利用交换机以及端口设置等来进行D...
各种千兆交换机的数据接口类型详... 千兆交换机有很多值得学习的地方,这里我们主要介绍各种千兆交换机的数据接口类型,作为局域网的主要连接设...
施耐德电气数据中心整体解决方案... 近日,全球能效管理专家施耐德电气正式启动大型体验活动“能效中国行——2012卡车巡展”,作为该活动的...
Windows恶意软件20年“... 在Windows的早期年代,病毒游走于系统之间,偶尔删除文件(但被删除的文件几乎都是可恢复的),并弹...
规避非法攻击 用好路由器远程管... 单位在市区不同位置设立了科技服务点,每一个服务点的员工都通过宽带路由器进行共享上网,和单位网络保持联...
范例解读VB.NET获取环境变... VB.NET编程语言的使用范围非常广泛,可以帮助开发人员处理各种程序中的需求,而且还能对移动设备进行...
20个非常棒的扁平设计免费资源 Apple设备的平面图标PSD免费平板UI 平板UI套件24平图标Freen平板UI套件PSD径向平...