CentOS6.5快速搭建LAMP环境

1.安装MySQL5,首先我们应该先用下面的命令安装MySQL:

yum install mysql mysql-server

image

image

2.选择Y进行安装:

image

image

3.然后我们需要启动MySQL服务器,运行如下命令:

/etc/init.d/mysqld start

image

4. 为MySQL root帐户设置密码,运行如下命令:

mysql_secure_installation

会出现下面的一系列提示:

[root@centosvm1 yourusername] # mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL

SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, well need the current

password for the root user. If youve just installed MySQL, and

you havent set the root password yet, the password will be blank,

so you should just press enter here.

Enter current password for root (enter for none):这里输入旧密码,由于旧密码为空直接回车即可

OK, successfully used password, moving on…

Setting the root password ensures that nobody can log into the MySQL

root user without the proper authorisation.

Set root password? [Y/n] 回车表示Y

New password: 输入您的新密码

Re-enter new password: 在此输入您的新密码

Password updated successfully!

Reloading privilege tables..

… Success!

By default, a MySQL installation has an anonymous user, allowing anyone

to log into MySQL without having to have a user account created for

them. This is intended only for testing, and to make the installation

go a bit smoother. You should remove them before moving into a

production environment.

Remove anonymous users? [Y/n] 回车表示Y

… Success!

Normally, root should only be allowed to connect from localhost. This

ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] 回车表示Y

… Success!

By default, MySQL comes with a database named test that anyone can

access. This is also intended only for testing, and should be removed

before moving into a production environment.

Remove test database and access to it? [Y/n] 回车表示Y

– Dropping test database…

… Success!

– Removing privileges on test database…

… Success!

Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.

Reload privilege tables now? [Y/n] 回车表示Y

… Success!

Cleaning up…

All done! If youve completed all of the above steps, your MySQL

installation should now be secure.

Thanks for using MySQL!

[root@centosvm1 yourusername] #

至此MySQL用户设置完成。

5. 安装Apache2,执行如下命令:

yum install httpd

image

6. 输入Y进行确认安装:

image

7. 执行如下命令启动Apache:

/etc/init.d/httpd start

image

Note: Apache的默认文档根目录是在CentOS上的/var/www/html 目录 ,配置文件是/etc/httpd/conf/httpd.conf。配置存储在的/etc/httpd/conf.d/目录。

8. 安装PHP 5,我们可以用下面的命令来安装PHP5

yum install php

image

9. 输入Y确认安装:

image

10. 安装完成后使用如下命令重启Apache:

/etc/init.d/httpd restart

image

11. 接下来我们要在/var/www/html中创建一个Info.php页面来测试PHP环境是否正常,运行如下命令:

nano /var/www/html/info.php

12. 进入编辑状态后输入以下内容:

<?php
phpinfo();
?>

12. 让PHP 5获得MySOL的支持,运行如下命令:

yum search php

image

13. 再运行如下命令安装必要组件:

yum install php-mysql php-gd php-imap php-ldap php-mbstring php-odbc php-pear php-xml php-xmlrpc

image

14. 输入Y进行安装:

image

15. 运行如下命令重新启动Apache:

/etc/init.d/httpd restart

image

16. 访问http://xxxx/info.php,并查看MySQL模块支持。

一条命令安装:

yum -y install mysql mysql-server httpd php php-mysql php-gd php-imap php-ldap php-mbstring php-odbc php-pear php-xml php-xmlrpc php-mcrypt libjpeg*
上一篇
下一篇