LAMP:Linux + Apache + MySQL + PHP
WAMP:Windows + Apache + MySQL + PHP
安装顺序:首先MySQL,然后Apache,最后PHP
二 搭建LAMP 第一步,安装MySQL
--1.安装Development tools和ncurses-devel
[root@serv01 ~]# yum grouplist|grep Devel
Additional Development
Desktop Platform Development
Development tools
Server Platform Development
[root@serv01 ~]# yum groupinstall"Development tools" -y
[root@serv01 ~]# yum install ncurses-devel-y
--2.解压
[root@serv01 ~]# tar -xf mysql-5.1.58.tar.gz-C /usr/src/
#文件错误,重新拷贝
[root@serv01 ~]# tar -xf mysql-5.1.58.tar.gz-C /usr/src/
tar: Skipping to next header
tar: Exiting with failure status due toprevious errors
[root@serv01 ~]# cd /usr/src/mysql-5.1.58/
#帮助文件
[root@serv01 ~]#./configure —help
--3.配置
[root@serv01 mysql-5.1.58]# ./configure--prefix=/usr/local/mysql --with-extra-charsets=gbk,gb2312—with-plugins=partition,innobase,innodb_plugin,myisam
--4.编译
[root@serv01 mysql-5.1.58]# make
--5.安装
[root@serv01 mysql-5.1.58]# make install
--6.拷贝配置文件和执行脚本
[root@serv02 mysql-5.1.58]# cpsupport-files/my-medium.cnf /etc/my.cnf
cp: overwrite `/etc/my.cnf'? y
[root@serv02 mysql-5.1.58]# cpsupport-files/mysql.server /etc/init.d/mysqld
[root@serv02 mysql-5.1.58]# chmod a+x/etc/init.d/mysqld
[root@serv02 mysql-5.1.58]# ls -l/etc/init.d/mysqld
-rwxr-xr-x. 1 root root 12302 Aug 15 23:36/etc/init.d/mysqld
--7.创建数据文件的存放路径,并修改my.cnf和mysqld文件
[root@serv02 mysql-5.1.58]# mkdir /usr/local/mysql/data
[root@serv02 mysql-5.1.58]# vim /etc/my.cnf
[root@serv02 mysql-5.1.58]# grep"^datadir" /etc/my.cnf -n
27:datadir =/usr/local/mysql/data
[root@serv02 mysql-5.1.58]# vim/etc/init.d/mysqld
[root@serv02 mysql-5.1.58]# sed"46,47p" /etc/init.d/mysqld -n
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
--8.新增用户,并加入MySQL的用户
[root@serv02 mysql-5.1.58]# groupadd mysql
[root@serv02 mysql-5.1.58]# useradd -g mysqlmysql
[root@serv02 mysql-5.1.58]#./scripts/mysql_install_db --user=mysql
--9.启动MySQL,进入/usr/local/mysql/bin/,执行mysql,查询MySQL版本
[root@serv02 mysql-5.1.58]#/etc/init.d/mysqld start
Starting MySQL. SUCCESS!
[root@serv02 mysql-5.1.58]# cd/usr/local/mysql/bin/
[root@serv02 bin]# ./mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.58-log Sourcedistribution
Copyright (c) 2000, 2010, Oracle and/or itsaffiliates. All rights reserved.
This software comes with ABSOLUTELY NOWARRANTY. This is free software,
and you are welcome to modify andredistribute it under the GPL v2 license
Type 'help;' or '\h' for help. Type '\c' toclear the current input statement.
mysql> select version();
+------------+
| version() |
+------------+
| 5.1.58-log |
+------------+
1 row in set (0.00 sec)
mysql> create database larry defaultcharset utf8;
Query OK, 1 row affected (0.00 sec)
mysql> use larry;
Database changed
mysql> show tables;
Empty set (0.00 sec)
mysql> create table t_user(id int(11)primary key auto_increment, name varchar(20));
Query OK, 0 rows affected (0.01 sec)
mysql> insert into t_user(name)values('larrywen');
Query OK, 1 row affected (0.00 sec)
mysql> insert into t_user(name)values('justdb');
Query OK, 1 row affected (0.00 sec)
mysql> insert into t_user(name)values('wgb');
Query OK, 1 row affected (0.00 sec)
mysql> select * from t_user;
+----+----------+
| id | name |
+----+----------+
| 1 |larrywen |
| 2 |justdb |
| 3 |wgb |
+----+----------+
3 rows in set (0.00 sec)
mysql> create table t_log(id int(11)primary key auto_increment, content varchar(20), t_user_id int(11), constraintfk_larry_t_log_usr_id foreign key(t_user_id) references t_user(id));
Query OK, 0 rows affected (0.01 sec)
mysql> insert into t_log(content,t_user_id) values('Logining System', 1);
Query OK, 1 row affected (0.01 sec)
mysql> select * from t_log;
+----+-----------------+-----------+
| id | content | t_user_id |
+----+-----------------+-----------+
| 1 |Logining System | 1 |
+----+-----------------+-----------+
1 row in set (0.00 sec)
mysql> exit
Bye
--10.修改mysql目录的所有者和组拥有者
[root@serv02 mysql-5.1.58]# cd/usr/local/mysql
[root@serv02 mysql]# chown -R mysql .
[root@serv02 mysql]# chgrp -R mysql .
推荐阅读:
Ubuntu下搭建属于自己的wiki与论坛(图)
Ubuntu 13.04 安装 LAMP\Vsftpd\Webmin\phpMyAdmin 服务及设置
CentOS 5.9下编译安装LAMP(Apache 2.2.44+MySQL 5.6.10+PHP 5.4.12)
RedHat 5.4下Web服务器架构之源码构建LAMP环境及应用PHPWind
LAMP源码环境搭建WEB服务器Linux+Apache+MySQL+PHP