centos yum方式安装apache php mysql (lamp)

| | 2012/07/08 09:15 , mdy
Linux 服务器 , 评论(0) , 阅读(1381) , Via 本站原创
Tags: , ,
1. 更新系统内核到最新.
yum -y update
系统更新后,如果yum安装时提示错误信息,请执行以下命令修复.
rpm –import /etc/pki/rpm-gpg/RPM-GPG-KEY*

2. 安装Apahce, PHP, Mysql, 以及php连接mysql库组件

yum -y install httpd php mysql mysql-server php-mysql

//安装mysql扩展
yum -y install mysql-connector-odbc mysql-devel libdbi-dbd-mysql
//安装php的扩展
yum -y install php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc mod_ssl mod_perl mod_auth_mysql php-mcrypt mysql-devel libdbi-dbd-mysql
//安装apache扩展
yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql

3. 启动服务配置

/sbin/chkconfig httpd on [设置apache为自启动]
/sbin/chkconfig –add mysqld [mysql服务]
/sbin/chkconfig mysqld on [mysqld服务]

/sbin/service httpd start [自启动 httpd 服务]
/sbin/service mysqld restart [自启动mysqld服务]

4.设置mysql数据库root帐号密码。
mysqladmin -u root password “新密码” [引号内填密码]

让mysql数据库更安全

复制内容到剪贴板

代码:

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

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

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

mysql> FLUSH PRIVILEGES; [重载权限]

5. 防火墙配置
a.添加.允许访问端口{21: ftp, 80: http}.
iptables -I RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 21 -j ACCEPT
iptables -I RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT

b.关闭防火墙{不推荐}.
service iptables stop
c.重置加载防火墙
service iptables restart