centos apache2 php mysql_在CentOS 5.5安装 Apache2 和 PHP5 及 MySQL

LAMP是linux 、apache、mysql、php5的简写,这篇教程主要说的是如何把apache 安装在Centos 5.5 服务器上,并使用PHP5编写支持(mod_php)和MySQL的支持。

我不敢保证这个方法对你也试用

1 注释

在这一课中,我使用的主机名称server1.example.com与服务器的IP地址192.168.0.100。这些设置可能是不同的,所以你必须取代它们在适当的地方。

2 安装mysql5.0,安装msql,我们这样做,

yum install mysql mysql-server

然后我们创建系统启动链接为MySQL(以便MySQL开始自动每当系统开机),然后我们开启mysql 服务。

chkconfig --levels 235 mysqld on

/etc/init.d/mysqld start

设置MySQL根帐户密码。

mysql_secure_installation

[root@server1 ~]# 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, we'll need the current

password for the root user.  If you've just installed MySQL, and

you haven't 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] 

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] 

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] 

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] 

... 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] 

Cleaning up...

All done!  If you've completed all of the above steps, your MySQL

installation should now be secure.

Thanks for using MySQL!

[root@server1 ~]#

3 安装apache 2.0

Apache2是可作为一个CentOS包裹,因此我们能像这样安装它.

yum install httpd

现在配置你的Apache2 系统启动时间。

chkconfig --levels 235 httpd on

重新启动Apache

/etc/init.d/httpd start

现在直接输入浏览器你应该看到下面的页面。

1.png

Apache 默认主页面Centos 5.5 /var/www/html下面,配置文件在 /etc/httpd/conf/httpd.conf中,额外配置的一些文件在 /etc/httpd/conf.d/目录中。

4 安装php5

我们安装模式可以参考安装Apache安装方法。

yum install php

我们也必须重启Apache .

/etc/init.d/httpd restart

这个系统web页面配置的主页面放在/var/www/html目录下,现在我们创建一个小的php程序【info.php】放在主配置页面下,然后在浏览器输入,请看下面的图,这个php程序可以显示php 的许多信息。

vi /var/www/html/info.php

vi /var/www/html/info.php

phpinfo();

?>

在浏览器输入以下信息注;ip 地址为你本机所设置的ip .

2.png

正如图上所见,php5 工作正常,如果你下拉列表可以看到所有程序都是使用php5 显示,我们看到mysql 没有在表里,说明我们还没编写mysql在php5 支持。

6 得到mysql支持php,我们可以安装php-mysql 文件,安装其他一些使用PHP5编写模块的应用程序.你能看到的php5模块是这个样的:

yum search php

安装需要的一些环境,安装是这样的。

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

现在重启apache 2 .

/etc/init.d/httpd restart

重启后,在浏览器输入http://192.168.0.100/info.php ,刷新就可以看到下图,其中有许多新的模块,其中就有MySql模块。

3.png

7 phpmyadmin

phpmyadmin 是信息管理页面,通过该你可以管理你的MySQL数据库。

首先我们通过官方页面下载

On x86_64 systems:

wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.x86_64.rpm

rpm -Uhv rpmforge-release-0.5.1-1.el5.rf.x86_64.rpm

On i386 systems:

wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.i386.rpm

rpm -Uhv rpmforge-release-0.5.1-1.el5.rf.i386.rpm

现在可以安装phpmyadmin:

yum install phpmyadmin

现在我们配置apache,我们改变apache中phpadmin 容许从主机连接,

vi /etc/httpd/conf.d/phpmyadmin.conf

#

# Web application to manage MySQL

#

#

# Order Deny,Allow

# Deny from all

# Allow from 127.0.0.1

#

Alias /phpmyadmin /usr/share/phpmyadmin

Alias /phpMyAdmin /usr/share/phpmyadmin

Alias /mysqladmin /usr/share/phpmyadmin

现在我们改变phpMyAdmin 的终端认证

vi /usr/share/phpmyadmin/config.inc.php

[...]

/* Authentication type */

$cfg['Servers'][$i]['auth_type'] = 'http';

[...]

重启apache :

/etc/init.d/httpd restart

然后你就可以phpadmin下http://192.168.0.100/phpmyadmin/http://192.168.0.100/phpmyadmin/:

4.png

官网链接:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值