大纲
1.安装gcc编译器
1
2
3
4
5
6
7
8
9
10
|
Mount
/dev/cdrom
/media
vi
/etc/yum
.repos.d
/CentOS-Media
.repo
[c5-media]
name=CentOS-$releasever - Media
baseurl=
file
:
///media
//
修改为光盘挂载点
enabled=1
//
改为1意为启用
gpgcheck=0
gpgkey=
file
:
///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
|
1
2
3
4
|
Vi
/etc/bashrc
alias
yum=
"yum --disablerepo=\* --enablerepo=c5-media"
3)依次安装gcc、gcc-c++
Yum -y
install
gcc*
|
1
2
3
4
5
6
7
|
下载前需关闭启动的服务,如httpd、mysqld
service httpd stop
service mysqld stop
卸载RPM包的Apache、MySQL、PHP
yum remove httpd
yum remove mysql
建议使用rpm –e http-1.2.3.rpm --nodeps (截断这个rpm包的依赖性)
|
1
2
3
|
1
)关闭SELinux
vi /etc/selinux/config
SELINUX=disabled
|
1
2
|
iptables -F * 如果没有禁用防火墙,默认80端口禁止访问
service iptables save 防火墙策略写到
/etc/sysconfig/iptables
,以后计算机重启再加载这个文件时,防火墙策略就会永久清空.
|
1
2
3
4
|
cd
/lamp/libxml2-2
.6.30
.
/configure
--prefix=
/usr/local/libxml2/
make
make
install
|
1
2
3
4
|
cd
/lamp/libmcrypt-2
.5.8
.
/configure
--prefix=
/usr/local/libmcrypt/
make
make
install
|
1
2
3
4
|
cd
/lamp/libmcrypt-2
.5.8
/libltdl
.
/configure
--
enable
-ltdl-
install
make
make
install
|
1
2
3
4
|
cd
/lamp/zlib-1
.2.3
.
/configure
make
make
install
|
1
2
3
4
|
cd
/lamp/libpng-1
.2.31
.
/configure
--prefix=
/usr/local/libpng/
make
make
install
|
1
2
3
4
5
6
7
8
9
10
|
mkdir
/usr/local/jpeg6
mkdir
/usr/local/jpeg6/bin
mkdir
/usr/local/jpeg6/lib
mkdir
/usr/local/jpeg6/include
mkdir
-p
/usr/local/jpeg6/man/man1
cd
/lamp/jpeg-6b
.
/configure
--prefix=
/usr/local/jpeg6/
--
enable
-shared --
enable
-static
make
make
install
--
enable
-shared与--
enable
-static 参数分别为建立共享库和静态库使用的libtool
|
1
2
3
4
|
cd
/lamp/freetype-2
.3.5
.
/configure
--prefix=
/usr/local/freetype/
make
make
install
|
1
2
3
4
|
cd
/lamp/autoconf-2
.61
.
/configure
make
make
install
|
1
2
3
4
5
6
7
8
9
10
11
12
|
mkdir
/usr/local/gd2
cd
/lamp/gd-2
.0.35
#png错误,修改方法:
vi
gd_png.c
把
#include “png.h”替换
#include "/usr/local/libpng/include/png.h"
.
/configure
--prefix=
/usr/local/gd2/
--with-jpeg=
/usr/local/jpeg6/
--with-freetype=
/usr/local/freetype/
--with-png=
/usr/local/libpng/
Make
#如果出现错误,把上面的两步重新执行一次.
make
install
若前面配置zlib时没有指定安装目录,gd配置时不要添加--with-zlib=
/usr/local/zlib/
参数
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
cd
/lamp/httpd-2
.2.9
.
/configure
--prefix=
/usr/local/apache2/
--sysconfdir=
/usr/local/apache2/etc/
--with-included-apr --
enable
-so --
enable
-deflate=shared --
enable
-expires=shared --
enable
-rewrite=shared
make
make
install
启动Apache测试:
/usr/local/apache2/bin/apachectl
restart
查看进程:
ps
-
le
|
grep
httpd
查看apache模块:
/usr/local/apache2/bin/apachectl
–h
#share 动态模块或动态库文件
Php5 rewrite
#static 静态模块或表态库文件
Server-status
Userdir
Virtual host
测试:
http:
//localhost/index
.html
“it works”
设置Apache随机启动
Vi
/etc/rc
.
local
/usr/local/apache2/bin/apachectl
restart
|
1
2
3
4
5
6
7
|
1.yum –y
install
ncurses*
2.源代码编译:
cd
/lamp/ncurses-5
.6
.
/configure
--with-shared --without-debug --without-ada --
enable
-overwrite
make
make
install
若不安装ncurses编译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
|
useradd
mysql
添加用户组mysql ,将mysql用户默认组设置为mysql用户组
cd
/lamp/mysql-5
.0.41
.
/configure
--prefix=
/usr/local/mysql
--without-debug --
enable
-thread-safe-client --with-pthread --
enable
-assembler --
enable
-profiling --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --with-extra-charsets=all --with-plugins=all --with-mysqld-user=mysql --without-embedded-server --with-server-suffix=-community --with-unix-socket-path=
/tmp/mysql
.sock
make
make
install
--with-extra-charsets=all参数为安装所有字符集
#如果不行的话,make clean 后再make ;make install,这样去试一下,默认是不支持innodb存储引擎的.其中--with-plugins=all可以把innodb加载进来.
1.
cp
/usr/local/mysql/share/mysql/my-medium
.cnf
/etc/my
.cnf
修改mysql配置文件
1.[client]
default-character-
set
=utf8
#客户端字符集
#连接字符集
2.[ mysqld]
character-
set
-server = utf8
#服务器字符集
#数据库字符集
collation-server = utf8_general_ci
#服务器,库,表的校验字符集
#default-storage-engine=innodb
#把默认的表引擎改为innodb
生成MySQL配置文件
Setfacl –m u:mysql:rwx –R
/usr/local/mysql
Setfacl –m d:u:mysql:rwx –R
/usr/local/mysql
用acl来让mysql用户对
/usr/local/mysql
有所有权限
/usr/local/mysql/bin/mysql_install_db
--user=mysql
创建数据库授权表
启动MySQL服务
1.用原本源代码的方式去使用和启动mysql
/usr/local/mysql/bin/mysqld_safe
--user=mysql &
2.重启以后还要生效:
Vi
/etc/rc
.
local
/usr/local/mysql/bin/mysqld_safe
--user=mysql &
4.
/usr/local/mysql/bin/mysqladmin
-uroot password kkk
#给mysql用户root加密码.密码为kkk
/usr/local/mysql/bin/mysql
-u root -pkkk
test
mysql>show databases;
mysql>use
test
mysql>show tables;
#进入mysql以后用set来改密码.
mysql>
exit
登录MySQL客户端控制台设置指定root密码
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
编译前确保系统已经安装了libtool和libtool-ltdl软件包,若没有安装使用yum或rpm安装下:
yum
install
libtool*
yum
install
libtool-ltdl*
cd
/lamp/php-5
.2.6
.
/configure
--prefix=
/usr/local/php/
--with-config-
file
-path=
/usr/local/php/etc/
--with-apxs2=
/usr/local/apache2/bin/apxs
--with-mysql=
/usr/local/mysql/
--with-libxml-
dir
=
/usr/local/libxml2/
--with-jpeg-
dir
=
/usr/local/jpeg6/
--with-png-
dir
=
/usr/local/libpng/
--with-freetype-
dir
=
/usr/local/freetype/
--with-gd=
/usr/local/gd2/
--with-mcrypt=
/usr/local/libmcrypt/
--with-mysqli=
/usr/local/mysql/bin/mysql_config
--
enable
-soap --
enable
-mbstring=all --
enable
-sockets
若前面配置zlib时没有指定安装目录,PHP配置时不要添加--with-zlib-
dir
=
/usr/local/zlib/
参数
make
make
install
生成php.ini(php的配置文件)
cp
/lamp/php-5
.2.6
/php
.ini-dist
/usr/local/php/etc/php
.ini
测试apache与php的连通性,看apache是否能解析php文件
让apache支持php代码 :
vi
/usr/local/apache2/etc/httpd
.conf
AddType application
/x-httpd-php
.php .phps
重启Apache服务:
/usr/local/apache2/bin/apachectl
restart
测试:
vi
/usr/local/apache2/htdocs/test
.php
<?php
phpinfo();
?>
通过浏览器测试:
http:
//localhost/test
.php
|
1
2
3
4
5
|
tar
zxvf memcache-2.2.5.tgz
cd
memcache-2.2.5
/usr/local/php/bin/phpize
.
/configure
--with-php-config=
/usr/local/php/bin/php-config
make
&&
make
install
|
1
2
3
4
5
6
7
8
9
10
11
|
tar
zxvf
/lamp/PDO_MYSQL-1
.0.2.tgz
cd
/lamp/PDO_MYSQL-1
.0.2/
/usr/local/php/bin/phpize
.
/configure
--with-php-config=
/usr/local/php/bin/php-config
--with-pdo-mysql=
/usr/local/mysql
make
&&
make
install
修改php.ini
extension_dir =
"/usr/local/php//lib/php/extensions/no-debug-non-zts-20060613/"
extension=
"memcache.so"
;
extension=
"pdo_mysql.so"
;
修改php文件生效:
/usr/local/apache2/bin/apachectl
restart
|
1
2
|
cd
/lamp/ZendOptimizer-3
.2.6-linux-glibc21-i386
.
/install
.sh
|
10、安装memcache服务器软件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
http:
//memcached
.googlecode.com
/files/memcached-1
.4.10.
tar
.gz
首先安装依赖包libevent
yum –y
install
libevent*
#主包已经安装,别忘记安装libevent-devel*,不然./configure过不去
Tar xzf
/lamp/memcached-1
.4.10.
tar
.gz
Cd
/lamp/memcached-1
.4.10
.
/configure
--prefix=
/usr/local/memcache
Make &&
make
install
Useradd memcache
#因为系统不能用root运行memcache软件
/usr/local/memcache/bin/memcached
-umemcache &
#后台运行
Netstat –tunpl|
grep
:11211
telnet 192.168.10.1 11211
stats
写入自启动:
Vi
/etc/rc
.
local
/usr/local/memcache/bin/memcached
-umemcache &
#如何杀掉后台进程,用kill %1,查看进程用jobs
|