lamp

来源:互联网 发布:ubuntu挂载硬盘到data 编辑:程序博客网 时间:2024/04/30 18:36

http://www.centos.bz/lamp/


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

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

centos安装php插件就是yum install php-*

yum install php-gd 安装图形支持

也可以通过光驱iso安装

mount /dev/cdrom /mnt挂载光驱到mnt

rpm -ivh /mnt/centos/httpd ****.rpm 安装ISO里的包

测试环境

rpm -qa |grep mysql

rpm -qa |grep httpd

rpm -qa |grep php

2. 配置开机启动服务

/sbin/chkconfig httpd on             [设置apache服务器httpd服务开机启动]

/sbin/chkconfig --add mysqld         [在服务清单中添加mysql服务]

/sbin/chkconfig mysqld on             [设置mysql服务开机启动]

/sbin/service httpd start             [启动httpd服务,与开机启动无关]

/sbin/service mysqld start           [启动mysql服务,与开机无关]

3.设置mysql数据库root帐号密码。

mysqladmin -u root password 'newpassword'           [引号内填密码]

4. 让mysql数据库更安全

mysql -u root -p

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

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

mysql> FLUSH PRIVILEGES;                               [重载权限]

5. 按照以上的安装方式, 配置出来的默认站点目录为/var/www/html/

新建一个php脚本:

6. 新建一个数据库,添加一个数据库用户,设置用户权限。写个php脚本测试一下数据库连接吧。

mysql> CREATE DATABASE my_db;

mysql> GRANT ALL PRIVILEGES ON my_db.* TO 'user'@'localhost' IDENTIFIED BY 'password';


//安装apache扩展

yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql

//安装php的扩展

yum install php-gd

yum -y install php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc

//安装mysql扩展

yum -y install mysql-connector-odbc mysql-devel libdbi-dbd-mysql

[root@soft bin]# mysql

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

""mysql dead but subsys locked

解决办法如下:

[root@soft mysql-4.1.19]# rm -fr /var/lib/mysql/*

[root@soft mysql-4.1.19]# rm /var/lock/subsys/mysql

rm: remove regular empty file `/var/lock/subsys/mysqld'? yes

shell> killall mysqld

shell> service mysqld start

[root@soft mysql-4.1.19]# /etc/rc.d/init.d/mysqld status

mysqld (pid 5457) is running...

###数据库运行正常;

一、两个重要目录:

  Apache有两个重要的目录:1、配置目录 /etc/httpd/conf;2、文档目录 /var/www:

  

  二、两种配置模式:

  Apache在Fedora下的两种配置方式:文本模式(终端命令行)和图形化配置。两者各有优势:图形化下配置,更容易上手,在文本模式下直接编辑httpd.conf文件,自由性更强些、更直接。

  三、Apache服务的启动与关闭

  Apache服务的停止、启动、关闭可以通过两种模式下进行操作:文本(终端)模式下和图形化界面。

  四、终端下的操作

  如果你想用Linux作为WWW服务器,我建议不要安装图形界面(即X window、KDE或GNOME桌面),很显然不安装这些程序,会显著提高系统的性能,易操作性和美丽的界面是要付出代价。我认为Linux的精髓在于命令行的丰富。Linux的命令可以完成所有任务。

  1、Apache的启动、重启、停止服务:

     cd /etc/init.d命令切换到 /etc/init.d目录,运行如下命令:

     ./httpd start //启动Apache服务

     ./httpd restart //重新启动Apache服务

     ./httpd stop //停止Apache服务

  开机自动启动Apache服务

  cd /sbin命令切换到/sbin目录,运行chkconfig命令,参数:./chkconfig --level 5 httpd on

  ./chkconfig --list可以检查一下httpd开机是否自动启动,如果5:启动,表示开机自动启动。

  2、配置

  cd /etc/httpd/conf命令切换到目录/etc/httpd/conf,用vi编辑器打开、编辑httpd.conf配置,在配置之前,为了防止配置出错,先备份


<?php

phpinfo();

?>

保存为info.php放到网站目录

然后输入http://ip/info.php看看测试环境


配置防火墙4添加允许访问HTTP、FTP端口

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

重启iptables: service iptables restart

安装phpMyAdmin)

进入phpMyAdmin官方下载(不要最新版本,下phpMyAdmin 2.11.9.5就行了,3.1以上需php 5.2以上),上传到你的网站目录下,然后进行配置。只需几步即可搞定。

I.

config.sample.inc.php更名为config.inc.php;

II.

打开config.inc.php文件,进行以下修改:

// $cfg['Servers'][$i]['controluser'] = ‘pma’;

// $cfg['Servers'][$i]['controlpass'] = ‘pmapass’;

// $cfg['Servers'][$i]['pmadb'] = ‘phpmyadmin’;

// $cfg['Servers'][$i]['bookmarktable'] = ‘pma_bookmark’;

// $cfg['Servers'][$i]['relation'] = ‘pma_relation’;

// $cfg['Servers'][$i]['table_info'] = ‘pma_table_info’;

// $cfg['Servers'][$i]['table_coords'] = ‘pma_table_coords’;

// $cfg['Servers'][$i]['pdf_pages'] = ‘pma_pdf_pages’;

// $cfg['Servers'][$i]['column_info'] = ‘pma_column_info’;

// $cfg['Servers'][$i]['history'] = ‘pma_history’;

// $cfg['Servers'][$i]['designer_coords'] = ‘pma_designer_coords’

去掉每行前面的//;

II.

$cfg['blowfish_secret'] = ”; |修改为| $cfg['blowfish_secret'] = ‘http’

V.

$cfg['Servers'][$i]['controluser'] = ‘pma’; |把’pma’修改为你的帐号|$cfg['Servers'][$i]['controlpass'] = ‘pmapass’; |把’pmapass设置为你的mysql登录密码|

V.

V. $cfg['blowfish_secret'] = ”; | 添加短语密码例如:$cfg['blowfish_secret'] = ‘onohot’

原创粉丝点击