CentOS LAMP配置手册

教程发布:风哥 教程分类:ITPUX技术网 更新日期:2022-02-12 浏览学习:384

CentOS LAMP配置手册
用过LAMP的人们都知道,LAMP是由Linux+Apache+Mysql+Perl/PHP/Python 一起组成的,如何在CentOS 下配置LAMP是初学者应该学习的今天用yum方法搭建起了个CentOS LAMP环境,中间遇到了很多问题,经过google和各位前辈的帮助,终于将环境搭建起来,现在把完整的步骤记录下来:一、换源,sohu的相当好用。备份CentOS-Base.repoview 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 systemdeveloped by Lance Davis for CentOS.# The mirror system uses the connecting IPaddress of the client and the# update status of each mirror to pickmirrors that are updated to and# geographically close to the client. Youshould use this for CentOS updates# unless you are manually picking othermirrors.[base]name=CentOS-$releasever - Basebaseurl=http://mirrors.sohu.com/centos/$releasever/os/$basearch/gpgcheck=1gpgkey=http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-5#released updates[updates]name=CentOS-$releasever - Updatesbaseurl=http://mirrors.sohu.com/centos/$releasever/updates/$basearch/gpgcheck=1gpgkey=http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-5#packages used/produced in the build butnot released[addons]name=CentOS-$releasever - Addonsbaseurl=http://mirrors.sohu.com/centos/$releasever/addons/$basearch/gpgcheck=1gpgkey=http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-5#additional packages that may be useful[extras]name=CentOS-$releasever - Extrasbaseurl=http://mirrors.sohu.com/centos/$releasever/extras/$basearch/gpgcheck=1gpgkey=http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-5#additional packages that extendfunctionality of existing packages[centosplus]name=CentOS-$releasever - Plusbaseurl=http://mirrors.sohu.com/centos/$releasever/centosplus/$basearch/gpgcheck=1enabled=0gpgkey=http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-5二、更新一下系统view sourceprint?#yum -y update三、安装Apacheview sourceprint?#yum install httpd安装完成后,用view sourceprint?/etc/init.d/httpd start启动apache设为开机启动view sourceprint?#chkconfig httpd on四、安装MYSQLview sourceprint?#yum install mysqlmysql-server同样,完成后,用view sourceprint?/etc/init.d/mysqld start启动mysql设置MYSQL密码view sourceprint?#/usr/bin/mysqladmin -uroot -h localhost password '新密码'#mysql -u root –p #进入MYSQL,#Enter Password: # [输入密码即可]更新MYSQL密码view sourceprint?mysql> USE mysql;mysql> UPDATE user SETPassword=PASSWORD('newpassword') WHERE user='root';mysql> FLUSH PRIVILEGES;允许远程登录view sourceprint?mysql>GRANT ALLPRIVILEGES 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五、安装PHPview sourceprint?#yum install php php-mysqlphp-common php-gd php-mbstring php-mcrypt php-devel php-xml libmcryptview sourceprint?#/etc/init.d/httpd start [运行HTTPD]六、测试一下在/var/www/html/新建个test.php文件,将以下内容写入,然后保存。view sourceprint?phpinfo();?>然后在客户端浏览器里打开http://IP/test.php,若能成功显示,则表示安装成功。至此,安装完毕。感慨,YUM真是太好用了。

本文标签:
本文标题:CentOS LAMP配置手册
网站声明:本文由风哥整理发布,转载请保留此段声明,本站所有内容将不对其使用后果做任何承诺,请读者谨慎使用!
【上一篇】
【下一篇】