1.下载软件
1
2
3
4
5
|
[root@RHEL src]
# cd /usr/local/src/
[root@RHEL src]
# wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.50.tar.gz/from/http://ftp.iij.ad.jp/pub/db/mysql/
[root@RHEL src]
# wget http://jp.php.net/get/php-5.2.14.tar.bz2/from/this/mirror
[root@RHEL src]
# wget http://ftp.riken.jp/net/apache//httpd/httpd-2.2.16.tar.gz
[root@RHEL src]
# wget http://downloads.sourceforge.net/project/phpmyadmin/phpMyAdmin/3.3.7/phpMyAdmin-3.3.7-all-languages.tar.bz2
|
2.安装配置mysql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
2.1.编译安装
[root@RHEL src]
# tar -xzvf mysql-5.1.50.tar.gz
[root@RHEL src]
# cd mysql-5.1.50
[root@RHEL mysql-5.1.50]
# more INSTALL-SOURCE
2.3.1. Source Installation Overview
The basic commands that you must execute to
install
a MySQL
source
distribution are:
shell> groupadd mysql
shell>
useradd
-g mysql mysql (一会我们修改一下 不让mysql用户能登录系统)
shell> gunzip < mysql-VERSION.
tar
.gz |
tar
-xvf - (我已经解压了 这步省略)
shell>
cd
mysql-VERSION (我们已经进入解压目录了)
shell> .
/configure
--prefix=
/usr/local/mysql
shell>
make
shell>
make
install
shell>
cp
support-files
/my-medium
.cnf
/etc/my
.cnf
shell>
cd
/usr/local/mysql
shell>
chown
-R mysql .
shell>
chgrp
-R mysql .
shell> bin
/mysql_install_db
--user=mysql
shell>
chown
-R root .
shell>
chown
-R mysql var
shell> bin
/mysqld_safe
--user=mysql &
[root@RHEL mysql-5.1.50]
# groupadd mysql
[root@RHEL mysql-5.1.50]
# useradd -g mysql -s /bin/false mysql
[root@RHEL mysql-5.1.50]
# ./configure --prefix=/usr/local/mysql
......
checking
for
termcap functions library... configure: error: No curses
/termcap
library found
......
OOPS!出错了!
[root@RHEL mysql-5.1.50]
# yum -y install ncurses-devel
(rpm下载地址http:
//ftp
.sjtu.edu.cn
/centos/5
.5
/os/i386/CentOS/ncurses-devel-5
.5-24.20060715.i386.rpm)
[root@RHEL mysql-5.1.50]
# ./configure --prefix=/usr/local/mysql
[root@RHEL mysql-5.1.50]
# make
[root@RHEL mysql-5.1.50]
# make install
[root@RHEL mysql-5.1.50]
# cd /usr/local/mysql
[root@RHEL mysql]
# chown -R mysql .
[root@RHEL mysql]
# chgrp -R mysql .
[root@RHEL mysql]
# bin/mysql_install_db --user=mysql
[root@RHEL mysql]
# chown -R root .
[root@RHEL mysql]
# chown -R mysql var
[root@RHEL mysql]
# bin/mysqld_safe --user=mysql &
2.2.确认mysql状态 并修改密码
[root@RHEL mysql]
# ps -ef | grep mysql
[root@RHEL mysql]
# /usr/local/mysql/bin/mysqladmin -u root password 'mysql'
[root@RHEL mysql]
# /usr/local/mysql/bin/mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection
id
is 2
Server version: 5.1.50 Source distribution
Copyright (c) 2000, 2010, Oracle and
/or
its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is
free
software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type
'help;'
or
'\h'
for
help. Type
'\c'
to
clear
the current input statement.
mysql>
2.3.使用官方提供的启动脚本并添加开机启动
[root@RHEL mysql]
# cp share/mysql/mysql.server /etc/init.d/mysqld
[root@RHEL mysql]
# /etc/init.d/mysqld stop
Shutting down MySQL100909 20:06:48 mysqld_safe mysqld from pid
file
/usr/local/mysql/var/RHEL
.pid ended
[确定]
[1]+ Done bin
/mysqld_safe
--user=mysql
[root@RHEL mysql]
# /etc/init.d/mysqld start
Starting MySQL. [确定]
[root@RHEL mysql]
# /sbin/chkconfig --add mysqld
[root@RHEL mysql]
# /sbin/chkconfig mysqld on
|
3.安装apache2.2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
3.1.编译安装
[root@RHEL mysql]
# cd /usr/local/src/
[root@RHEL src]
# tar -xzvf httpd-2.2.16.tar.gz
[root@RHEL src]
# cd httpd-2.2.16
[root@RHEL httpd-2.2.16]
# more INSTALL
Quick Start - Unix
------------------
For complete installation documentation, see [ht]docs
/manual/install
.html or
http:
//httpd
.apache.org
/docs/2
.2
/install
.html
$ .
/configure
--prefix=PREFIX
$
make
$
make
install
$ PREFIX
/bin/apachectl
start
NOTES: * Replace PREFIX with the filesystem path under
which
Apache should be installed. A typical installation
might use
"/usr/local/apache2"
for
PREFIX (without the
quotes).
*在他说的最简单的安装方式上 我们加2个编译参数
*--
enable
-rewrite rule based URL manipulation
*--
enable
-so DSO capability
[root@RHEL httpd-2.2.16]
# ./configure --prefix=/usr/local/apache2 --enable-rewrite --enable-so
[root@RHEL httpd-2.2.16]
# make
[root@RHEL httpd-2.2.16]
# make install
3.2.建立apache专用用户
[root@RHEL httpd-2.2.16]
# groupadd apache
[root@RHEL httpd-2.2.16]
# useradd -g apache -M -s /sbin/nologin apache
[root@RHEL httpd-2.2.16]
# vi /usr/local/apache2/conf/httpd.conf
找到如下2句 并在行头加
#号注释掉
User daemon
Group daemon
追加如下2句
User apache
Group apache
3.3.启动状态确认
[root@RHEL httpd-2.2.16]
# /usr/local/apache2/bin/apachectl start
[root@RHEL httpd-2.2.16]
# lsof -i:80
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
httpd 14125 root 3u IPv6 194322 TCP *:http (LISTEN)
httpd 14354 apache 3u IPv6 194322 TCP *:http (LISTEN)
httpd 14355 apache 3u IPv6 194322 TCP *:http (LISTEN)
httpd 14356 apache 3u IPv6 194322 TCP *:http (LISTEN)
httpd 14357 apache 3u IPv6 194322 TCP *:http (LISTEN)
httpd 14358 apache 3u IPv6 194322 TCP *:http (LISTEN)
[root@RHEL httpd-2.2.16]
# curl http://localhost (你可以在浏览器里输入http://ip测试)
<html><body><h1>It works!<
/h1
><
/body
><
/html
>
|
*通过apachectl就可以方便的启动关闭apache了 我就不做启动脚本了
*如果你需要你可以上网搜一下 或者参照/etc/init.d/下的其他脚本 在apachectl的基础上修改一个
*或者 你可以再/etc/rc.local里追加一句来让apache开机启动/usr/local/apache2/bin/apachectl start
4.源码编译安装php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
4.1.编译安装
root@RHEL httpd-2.2.16]
# cd /usr/local/src/
[root@RHEL src]
# tar -jxvf php-5.2.14.tar.bz2
[root@RHEL src]
# cd php-5.2.14
[root@RHEL php-5.2.14]
# more INSTALL
Apache 2.0 on Unix systems
·.......
You are highly encouraged to take a
look
at the Apache Documentation to
get a basic understanding of the Apache 2.0 Server.
......
Example 2-4. Installation Instructions (Apache 2 Shared Module Version)
1.
gzip
-d httpd-2_0_NN.
tar
.gz
2.
tar
xvf httpd-2_0_NN.
tar
3. gunzip php-NN.
tar
.gz
4.
tar
-xvf php-NN.
tar
5.
cd
httpd-2_0_NN
6. .
/configure
--
enable
-so
7.
make
8.
make
install
Now you have Apache 2.0.NN available under
/usr/local/apache2
,
configured with loadable module support and the standard MPM prefork.
To
test
the installation use your normal procedure
for
starting
the Apache server, e.g.:
/usr/local/apache2/bin/apachectl
start
and stop the server to go on with the configuration
for
PHP:
/usr/local/apache2/bin/apachectl
stop.
9.
cd
..
/php-NN
10. .
/configure
--with-apxs2=
/usr/local/apache2/bin/apxs
--with-mysql (一会我们指定一下mysql的安装路径)
11.
make
12.
make
install
.......
13. Setup your php.ini
cp
php.ini-dist
/usr/local/lib/php
.ini
.......
14. Edit your httpd.conf to load the PHP module.
......
For PHP 5:
LoadModule php5_module modules
/libphp5
.so
15. Tell Apache to parse certain extensions as PHP.
......
AddType application
/x-httpd-php
.php .phtml
It's also common to setup the .phps extension to show highlighted PHP
source
, this can be
done
with:
AddType application
/x-httpd-php-source
.phps
16. Use your normal procedure
for
starting the Apache server, e.g.:
/usr/local/apache2/bin/apachectl
start
......
[root@RHEL php-5.2.14]
# ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql
......
configure: error: xml2-config not found. Please check your libxml2 installation.
......
OOPS!出错了!
[root@RHEL php-5.2.14]
# yum -y install libxml2-devel
(我的情况 安装libxml2-devel的时候 依赖于zlib-devel)
(rpm下载地址 http:
//ftp
.sjtu.edu.cn
/centos/5
.5
/os/i386/CentOS/zlib-devel-1
.2.3-3.i386.rpm)
(rpm下载地址 http:
//ftp
.sjtu.edu.cn
/centos/5
.5
/os/i386/CentOS/libxml2-devel-2
.6.26-2.1.2.8.i386.rpm)
[root@RHEL php-5.2.14]
# ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql
[root@RHEL php-5.2.14]
# make
[root@RHEL php-5.2.14]
# make install
[root@RHEL php-5.2.14]
# cp php.ini-dist /usr/local/lib/php.ini
[root@RHEL php-5.2.14]
# vi /usr/local/apache2/conf/httpd.conf
在内容里搜一下是否有libphp5.so
我的情况 已经有了 如果没有追加下面那句前面不带
#的
# LoadModule foo_module modules/mod_foo.so
LoadModule php5_module modules
/libphp5
.so
#
再搜索AddType关键字 在那附近追加如下一句
AddType application
/x-httpd-php
.php .phtml
再搜索下面一段 把第二句DirectoryIndex的后面追加index.php
<IfModule dir_module>
DirectoryIndex index.html index.php
<
/IfModule
>
4.1.2测试php网页
[root@RHEL php-5.2.14]
# cd /usr/local/apache2/htdocs/
[root@RHEL htdocs]
# vi index.php
输入内容
<?php
phpinfo();
?>
[root@RHEL php-5.2.14]
# /usr/local/apache2/bin/apachectl restart
[root@RHEL mysql]
# curl -I http://localhost/index.php
或者你在你的浏览器里输入http:
//yourip/index
.php
4.1.3测试php和mysql连接
[root@RHEL htdocs]
# vi phpmysql.php
输入内容
<?php
mysql_connect(
"localhost"
,
"root"
,
"mysql"
) or die(
"MySQL First Test:Failed"
);
echo
"MySQL First Test:Success"
;
?>
因为我们编译php的时候没有加--with-mysqli选项 所以不支持mysqli扩展
[root@RHEL htdocs]
# curl http://localhost/phpmysql.php
MySQL First Test:Success
好了 我这里成功了
你可以再浏览器里输入http:
//ip/phpmysql
.php
|
5.安装配置phpMyAdmin
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
5.1.配置phpMyAdmin
[root@RHEL mysql]
# cd /usr/local/src/
[root@RHEL src]
# tar -jxvf phpMyAdmin-3.3.7-all-languages.tar.bz2
我们把phpMyAdmin配置到
/var/www/
下 命名为phpMyAdmin
[root@RHEL src]
# test -d /var/www || mkdir -p /var/www
[root@RHEL src]
# mv phpMyAdmin-3.3.7-all-languages /var/www/phpMyAdmin
[root@RHEL src]
# cp /var/www/phpMyAdmin/config.sample.inc.php /var/www/phpMyAdmin/config.inc.php
[root@RHEL src]
# chmod 660 /var/www/phpMyAdmin/config.inc.php
[root@RHEL src]
# vi /var/www/phpMyAdmin/config.inc.php
追加$cfg[
'Lang'
] =
'zh-utf-8'
;
----------可选设置 为phpMyAdmin设置50位的短语密码---------
------推荐你设置 但是要使用mkpasswd命令 你需要安装expect包
[root@RHEL src]
# mkpasswd -l 50
clecXjgn7Hg%whkyajmmq8zisgzceinvcuqnwhbxlwapnzemwm
复制产生的短语密码
[root@RHEL src]
# vi /var/www/phpMyAdmin/config.inc.php
找到如下参数
$cfg[
'blowfish_secret'
] =
'clecXjgn7Hg%whkyajmmq8zisgzceinvcuqnwhbxlwapnzemwm'
----------------------可选设置 结束-----------------------
[root@RHEL src]
# chown -R root.apache /var/www/phpMyAdmin
[root@RHEL src]
# cd /usr/local/apache2/conf/
[root@RHEL conf]
# vi extra/phpmyadmin.conf
加入内容
Alias
/phpMyAdmin
/var/www/phpMyAdmin
<Location
/phpMyAdmin
>
Order deny,allow
Deny from all
Allow from 127.0.0.1
Allow from 10.110.108.55
//
这里改成你实际允许访问的ip
<
/Location
>
[root@RHEL conf]
# vi httpd.conf
追加
Include conf
/extra/phpmyadmin
.conf
[root@RHEL conf]
# /usr/local/apache2/bin/apachectl restart
5.2.测试 在浏览器输入下面的网址
http:
//ip/phpMyAdmin/
输入我们前面设置的mysql用户名root 和密码mysql
Enjoy!
|
注:
本文测试环境RHEL5.5,同样适合于CentOS5.5。
本文适合新手学习安装,不适合生产环境。