LAMP平台搭建指南

第一步 安装MYSQL
解压

src]# tar vxzf mysql-6.0.4-alpha.tar.gz

把 mysql-6.0.4-alpha 移动到 /usr/local/src 下
mv mysql-6.0.4-alpha /usr/local/src

进入目录 cd mysql-6.0.4-alpha
\q

]# ./configure --sysconfdir=/etc 注意没有空格的

出现一个错误:
checking for termcap functions library... configure: error: No curses/termcap library found

正确的解决做法应该是
yum -y install ncurses-devel

稍等, 网络不是很快,而且更新的东西也不少

还有一些更新地址出现time out 超时的情况,
不过它会(Trying other mirror)自动换另外一个镜像地址,挺方便。

Running Transaction
Installing: ncurses-devel ######################### [1/1]

Installed: ncurses-devel.i386 0:5.5-24.20060715
Complete!

wget https://www.360docs.net/doc/0615202891.html,/pub/gnu/ncurses/ncurses-5.6.tar.gz
tar zxvf ncurses-5.6.tar.gz
cd ncurses-5.6
./configure --prefix=/usr --with-shared --without-debug
make
make install clean

安装完成。

====================
mak
再次

]# ./configure --sysconfdir=/etc

就成功了。Thank you for choosing MySQL!

]#make

make 的时间也是比较长,要等等。

好了, 下面进行安装
]#make install

安装完了之后,我们拷贝一个配置文件,当作以后mysql的配置文件
]# cp /usr/local/share/mysql/https://www.360docs.net/doc/0615202891.html,f /etc/https://www.360docs.net/doc/0615202891.html,f

# useradd -d /usr/local/var mysql
# su - mysql
$ /usr/local/bin/mysql_install_db


如果报
[mysql@localhost ~]$ /usr/local/bin/mysql_install_db
Installing MySQL system tables...
090408 0:29:16 [ERROR] /usr/local/libexec/mysqld: unknown option '--skip-federated'
090408 0:29:16 [ERROR] Aborting

090408 0:29:17 [Note] /usr/local/libexec/mysqld: Shutdown complete

进入https://www.360docs.net/doc/0615202891.html,f 文件将#skip-federated 注释掉即可。




启动
[mysql@localhost var]$ /usr/local/bin/mysqld_safe &

按多几下回车就可以了

测试

] netstat -tnl 查看端口, 看到 3306 就是mysql 的默认端口,
显示3306端口表示成功启动了mysql

登陆上去
[mysql@localhost local]$ mysql -uroot


mysql> show databases; 这是显示所有数据库命令

成功的话, 出现
mysql>
mysql>\s

mysql>\q 这是退出命令

好下面做另外的修改,就是当启动 CentOS5.1 Linux 时候,mysql6.0也自动启动的问题

] su - 我们要用管理员身份才可以 进行下面的操作

]# echo "/usr/local/bin/mysqld_safe &" >> /etc/rc.local

]# more /etc/rc.local 查看是否添加成功。


】#cp /usr/local/share/mysql/mysql.server /etc/init.d/mysqld

]# shutdown -r now 重启Linux 看看 是否成
第二步 安装APACHE



]# tar xjvf httpd.tar.bz2

进入 httpd-2.2.8 目录

]# cd httpd-2.2.8

httpd-2.2.8]# ./configure --sysconfdir=/etc --enable-ssl --enable-modules

出现一个错误:
checking whether to enable mod_ssl... checking dependencies
checking for SSL/TLS to

olkit base... none
checking for OpenSSL version... checking openssl/opensslv.h usability... no
checking openssl/opensslv.h presence... no
checking for openssl/opensslv.h... no
checking openssl/ssl.h usability... no
checking openssl/ssl.h presence... no
checking for openssl/ssl.h... no
no OpenSSL headers found
checking for SSL-C version... checking sslc.h usability... no
checking sslc.h presence... no
checking for sslc.h... no
no SSL-C headers found
configure: error: ...No recognized SSL/TLS toolkit detected

========================================

解决办法:安装 openssl

# yum -y install openssl-devel

下面是我的yum配置:
1,修改 /etc/yum.repos.d/rhel-debuginfo.repo 为如下内容
[Cluster]
name=Red Hat Enterprise Linux $releasever - $basearch - Cluster
baseurl=ftp://192.168.10.104/pub/Cluster
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[ClusterStorage]
name=Red Hat Enterprise Linux $releasever - $basearch - ClusterStorage
baseurl=ftp://192.168.10.104/pub/ClusterStorage
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[Server]
name=Red Hat Enterprise Linux $releasever - $basearch - Server
baseurl=ftp://192.168.10.104/pub/Server
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[VT]
name=Red Hat Enterprise Linux $releasever - $basearch - VT
baseurl=ftp://192.168.10.104/pub/VT
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release


# yum -y install openssl-devel


这样再 configure 就不会出现错误了, 生成makefile
httpd-2.2.8]# ./configure --sysconfdir=/etc --enable-ssl --enable-modules
下面进行编译
httpd-2.2.8]# make
安装
httpd-2.2.8]# make install

这样 apache 2.2.8 就安装完成了,

启动服务
]# /usr/local/apache2/bin/apachectl start &

测试访问 查看一下端口
]# netstat -tnl

看, 打开了 80 端口了,说明apache 正常启动了

我们在 window 上访问一下。
Linux 上的 ip 地址是 192.168.1.118

看 显示页面 It works! 成功访问了

默认首页目录 /usr/local/apache2/htdocs/index.html

随着 CentOS5.1 Linux 启动时候 自动启动 apache
]# echo "/usr/local/apache2/bin/apachectl start &" >> /etc/rc.local


第三步,配置ssl ,安装GD 。


解压缩

#tar xvzf ssl.ca-0.1.tar.gz

进入目录
#cd ssl.ca-0.1

开始生成证书

[root@localhost ssl.ca-0.1]# ./new-root-ca.sh (生成根证书)

No Root CA key round. Generating one
Generating RSA private key, 1024 bit long modulus
............................++++++
...........++++++
e is 65537 (0x10001)
Enter pass phrase for ca.key:1234 (输入一个密码,最少4位)
Verifying - Enter pass phrase for ca.key:1234 (再输入一次密码,跟刚才的一样)

Self-sign the root CA...(签署根证书)
Enter pass phrase for ca.key:1234(输入刚刚设置的密码)
You are about to

be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----(下面开始签署)
Country Name (2 letter code) [MY]:CN
State or Province Name (full name) [Perak]:China
Locality Name (eg, city) [Sitiawan]:Guangzhou
Organization Name (eg, company) [My Directory Sdn Bhd]:https://www.360docs.net/doc/0615202891.html,
Organizational Unit Name (eg, section) [Certification Services Division]:17rumen
Common Name (eg, MD Root CA) []:name1
Email Address []:17rumen@https://www.360docs.net/doc/0615202891.html,

这样就生成了ca.key和ca.crt两个文件,


[root@localhost ssl.ca-0.1]# ls ca* 查看一下是否存在
ca.crt ca.key


--------------------------------------

下面还要为服务器生成一个证书,也就是要部署到apache的证书:

[root@localhost ssl.ca-0.1]# ./new-server-cert.sh server (这个证书的名字是server,当然,你也可以随便写)
No server.key round. Generating one
Generating RSA private key, 1024 bit long modulus
.....++++++
.....++++++
e is 65537 (0x10001)

Fill in certificate data
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [MY]:CN
State or Province Name (full name) [Perak]:China
Locality Name (eg, city) [Sitiawan]:Guangzhou
Organization Name (eg, company) [My Directory Sdn Bhd]:https://www.360docs.net/doc/0615202891.html,
Organizational Unit Name (eg, section) [Secure Web Server]:17rumen
Common Name (eg, https://www.360docs.net/doc/0615202891.html,) []:name2
Email Address []:17rumen@https://www.360docs.net/doc/0615202891.html,

You may now run ./sign-server-cert.sh to get it signed


这样就生成了server.csr和server.key这两个文件。

]# ls server* 同样查看一下是否存在

====================================

必须签署一下才能使用的:

[root@localhost ssl.ca-0.1]# ./sign-server-cert.sh server
CA signing: server.csr -> server.crt:
Using configuration from ca.config
Enter pass phrase for ./ca.key:1234(我们开始设置的密码)
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
countryName :PRINTABLE:'CN'
stateOrProvinceName :PRINTABLE:'China'
localityName :PRINTABLE:'Guangzhou'
organizationName :PRINTABLE:'https://www.360docs.net/doc/0615202891.html,'
organizationalUnitName:PRINTABLE:'17rumen'
commonName :PRINTABLE:'name2'
emailAddress :IA5STRING:'17rumen@https://www.360docs.net/doc/0615202891.html,'
Certificate is to be certified until May 4 16:57:31 2009 GMT (365 days)
Sign the certificate? [y/n]:y


1 out of 1 certificate requests certified, comm

it? [y/n]y
Write out database with 1 new entries
Data Base Updated
CA verifying: server.crt <-> CA cert
server.crt: OK

===============================
下面修改一下 apache 的配置 ]# vi /etc/httpd.conf

修改前:
# Secure (SSL/TLS) connections
# Include /etc/extra/httpd-ssl.conf

去掉 # 修改后:
# Secure (SSL/TLS) connections
Include /etc/extra/httpd-ssl.conf

保存 退出


把 server.crt server.key 拷贝到 /etc 目录下

[root@localhost ssl.ca-0.1]# cp server.crt /etc/server.crt

[root@localhost ssl.ca-0.1]# cp server.key /etc/server.key

关闭 apache
[root@localhost ssl.ca-0.1]# /usr/local/apache2/bin/apachectl stop &

再启动 apache
[root@localhost ssl.ca-0.1]# /usr/local/apache2/bin/apachectl start &

]# netstat -tnl

可以看到 除了80 端口,还有一个443端口
443端口即网页浏览端口,主要是用于HTTPS服务,是提供加密和通过安全端口传输的另一种HTTP

我们对比一下来访问服务器的网页

1, 我们按照常见的方式来访问 http://192.168.1.118

2, 我们使用ssl加密的方式来访问 https://192.168.1.118

看到了吧,弹出一个 安全警告,

我们查看一下 证书,证书这里有些内容使我们刚才设置的

我们点击 是

可以看到浏览器 下面多了一个锁的东西, 把鼠标放过去,显示
可靠的SSL(128 位)


安装GD
我们先安装ncurses-5.6.tar.gz,安装gd库会用到的

去下载一个ncurses-5.6.tar.gz
也可以到我们站点下载:https://www.360docs.net/doc/0615202891.html,/download/tools/ncurses-5.6.7z
解压密码:https://www.360docs.net/doc/0615202891.html,

把 ncurses-5.6.tar.gz 放入 webserv 目录, 看上去像我现在这样。

然后我们在Linux上用 wget http://192.168.1.107:2000/ncurses-5.6.tar.gz 下载在window的文件

解压操作
tar zxvf ncurses-5.6.tar.gz
进入目录
cd ncurses-5.6
生成 makefile文件,再进一步编译
./configure --prefix=/usr --with-shared --without-debug
编译,编译时间稍微长些,稍等
make
编译好最后就是安装了
make install

==================================

下面才开始安装 GD库,安装gd库成功与否,与下面的安装顺序有一定的关系
我们就一步步来演示安装, 下面所有用到的文件,可以到
https://www.360docs.net/doc/0615202891.html,/download/tools/gd-all-17rumen.7z 下载
解压密码:https://www.360docs.net/doc/0615202891.html,
解压后就下面所用到的所有文件都在这里了,省得大家到处找,浪费不必要的时间

把全部的文件 都放进 webserv 目录下

1:安装zlib2
同样, 在Linux下使用 wget 来下载文件
tar zxvf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure --prefix=/usr/local/zlib
make
make install

---------------------------------

2:安装PNG

tar zxvf libpng-1.2.26.tar.gz
cd libpng-1.2.26

cp scripts/makefile.linux ./makefile
./configure --prefix=/usr/local/libpng

make
make install


---------------------------------

3:安装ttf

( ttf 是字体的支持 )


tar zxvf freetype-2.3.5.tar.gz
cd freetype-2.3.5
./configure --prefix=/usr/local/freetype

make
make install

---------------------------------

4:安装JPEG6


tar zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b

mkdir -pv /usr/local/libjpeg/{,bin,lib,include,man/man1,man1}
上面这个命令具体是实现这样的:
mkdir: created directory `/usr/local/libjpeg'
mkdir: created directory `/usr/local/libjpeg/bin'
mkdir: created directory `/usr/local/libjpeg/lib'
mkdir: created directory `/usr/local/libjpeg/include'
mkdir: created directory `/usr/local/libjpeg/man'
mkdir: created directory `/usr/local/libjpeg/man/man1'
mkdir: created directory `/usr/local/libjpeg/man1'
可以说是一个小小的bug吧,要我们手动建立这些目录,否则configure时候会说找不到目录。

./configure --prefix=/usr/local/libjpeg --enable-shared --enable-static

make
make install

---------------------------------

5:安装 libxml2

tar zxvf libxml2-2.6.31.tar.gz
cd libxml2-2.6.31
./configure --prefix=/usr/local/libxml2

make
这一步make 操作 时间相对也会比较长,呵呵

make install

cp xml2-config /usr/bin

---------------------------------

6:安装 libmcrypt-2.5.7.tar.gz

tar zxvf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7

./configure
make
make install

---------------------------------

7:安装Fontconfig

tar -zxvf fontconfig-2.4.2.tar.gz
cd fontconfig-2.4.2

可以看到, 参数比较长, 我建议用记事本的朋友不要选择 自动换行。
看我操作, 自动换行 复制过去执行有时会出错。去掉 自动换行
./configure --prefix=/usr/local/fontconfig --with-freetype-config=/usr/local/freetype/bin/freetype-config

这里显示一个错误信息:
checking for LIBXML2... configure: error: Package requirements (libxml-2.0 >= 2.6) were not met:

No package 'libxml-2.0' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables LIBXML2_CFLAGS
and LIBXML2_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

但是我们在上面其实已经安装上 libxml2 了的,这里只是一个 环境变量没有设置好而已。

解决办法: 确定 /usr/local/libxml2/lib/pkgconfig 目录下有 libxml-2.0.pc

export PKG_CONFIG_PATH=/usr/local/libxml2/lib/pkgconfig:$PKG_CONFIG_PATH

再次生成 makefile , 这样就成功了

./configure --prefix=/usr/local/fontconfig --with-freetype-config=/usr/local/freetype/bin/freetype-config
好了吧,没有出现那个错误了。

make
make install

---------------------------------

8:安装GD库,我们把这一步放在最后面

tar zxvf gd-2.0.35.tar.gz
cd gd-2.0.35
./configure --prefix=/usr/local/libgd --with-png=/usr/local/libpng --with-freetype=/usr/local/freetype --with-jpeg=/usr/local/li

bjpeg --with-fontconfig=/usr/local/fontconfig

看到下面的信息, 呵呵 很多都显示支持了
Support for PNG library: yes
Support for JPEG library: yes
Support for Freetype 2.x library: yes
Support for Fontconfig library: yes
Support for Xpm library: no
Support for pthreads: yes


make
make install

好了, 到这里为止 安装GD库全部过程演示完了,
这样还是不是很好的感觉出来,等我们下一节视频-
就是把 php5.2.6也装上了,那么才知道 php 支持了 gif jpg png wbmp xml ttf字体



四,安装PHP

tar zxvf php-5.2.6.tar.gz

cd php-5.2.6

这里要提醒大家注意:你如果用记事本,去掉 自动换行 再复制

这里的 路径例如: apache mysql gd jpeg freetype 等等的路径 根据自己安装的来写,如果你
一直按照我以前视频的来安装的话,那就复制我的都没有问题了。

# ./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local --with-gd --enable-gd-native-ttf --with-ttf --enable-gd-jis-conv --with-freetype-dir=/usr/local/freetype --with-jpeg-dir=/usr/local/libjpeg --with-png-dir=/usr/local/libpng --with-libxml-dir=/usr/local/libxml2 --with-zlib-dir=/usr/local/zlib --enable-xml --enable-mbstring --enable-sockets

Thank you for using PHP.
表示没有问题了,看到这句话。
下面开始编译, 编译用的时间相对比较长,稍等

make
好了,编译完成了,提示我们 make test , 这里我就不做这一步测试操作了,省点时间。
make test

make install

下面这个是拷贝一个php的配置文件,作为以后我们修改php的ini文件
cp php.ini-dist /usr/local/php5/lib/php.ini

下面修改 apache 配置文件 httpd.conf 加入对php的支持
vi /etc/httpd.conf

加入:

AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps

然后重启 apache
/usr/local/apache2/bin/apachectl stop &

这里出现一个错误:
httpd: Syntax error on line 53 of /etc/httpd.conf: Cannot load /usr/local/apache2/modules/libphp5.so into server: /usr/local/apache2/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied

解决办法:关闭 SELinux

vi /etc/sysconfig/selinux
屏蔽掉,
#SELINUX=enforcing
然后添加
SELINUX=disabled

重启一下 Linux
shutdown -r now

这样重启就可以了
好, 重启完了, 我们再用 putty 登陆上去

然后我们编写一个 php 文件测试一下, 看看我们装好的php支持哪些东西
下面这个是apache默认的虚拟目录
cd /usr/local/apache2/htdocs
vi test.php

文件内容
phpinfo();
?>

192.168.1.118 这是我Linux上的ip地址,我们在window上访问一下

http://192.168.1.118/test.php
看到下面 这个页面,表示 apache 已经支持 php 了。

gd
GD Support enabled
GD Version 2.0

or higher
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.3.5
GIF Read Support enabled
GIF Create Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled

看到了吧 , 支持东西挺多了, gif jpg png wbmp freetype gd

---------
这是 mysql6 的支持

mysql
MySQL Support enabled
Active Persistent Links 0
Active Links 0
Client API version 6.0.4-alpha
MYSQL_MODULE_TYPE external
MYSQL_SOCKET /tmp/mysql.sock
MYSQL_INCLUDE -I/usr/local/include/mysql
MYSQL_LIBS -L/usr/local/lib/mysql -lmysqlclient

==================================

五、安装 ZendOptimizer3.3.0 和WEBmin


大部分安装支持php的web服务器,都会把ZendOptimizer安装上去

简单介绍下 Zend Optimizer: Zend 最佳优化工具
将 PHP 的核心重新调整,让 PHP 程序执行的效率更快,主要能加快 PHP 代码的
执行速度及降低 CPU 的负担,将反应的时间减少。

Zend Optimizer能给PHP用户带来很多益处,特别是那些运营网站的人。

快速运行PHP程序可以显著降低服务器的CPU负载,并可以减少一半的反应时间,

也就是从访问者点击链接到服务器开始读取页面之间的时间

我们要先下载 ZendOptimizer-3.3.3-linux-glibc21-i386.tar.gz


解压
tar xzvf ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz

进入解压好的目录
cd ZendOptimizer-3.3.0a-linux-glibc21-i386

下面开始安装了
./install

这是个安装界面,看我操作

一直默认 按键盘 的回车 就看到这一步,

这一步就要我们自己写上之前 php 的安装路径了

/usr/local/php5/lib/php.ini 这样写是错误的。

要写的是目录路径
/usr/local/php5/lib 这才正确

然后就一直 按回车, 默认可以了。

提示我们重启 web 服务器。好了,apache 自动重启完了

查看 是否正确安装了 Zend Optimizer

我们编写一个 php 页面来查看

vi testZend.php

phpinfo();
?>

保存退出,

我在window 上访问看一下

This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
with Zend Extension Manager v1.2.2, Copyright (c) 2003-2007, by Zend Technologies
with Zend Optimizer v3.3.0, Copyright (c) 1998-2007, by Zend Technologies

看到这个信息 说明 已经成功 安装 ZendOptimizer 了

还有下面这个信息

Zend Optimizer
Optimization Pass 1 enabled
Optimization Pass 2 enabled
Optimization Pass 3 enabled
Optimization Pass 4 enabled
Optimization Pass 9 enabled
Zend Loader enabled
License Path no value
Obfuscation level 3






六、安装论坛



建立数据库
#mysql


mysql>create database hm;



创建用户


mysql>grant all on hm.* to user1@localhost identified by "pass1";



在数据库改变的时候需

要做


mysql>flush privileges;

mysql> show databases; 这是显示所有数据库命令

成功的话, 出现
mysql>
mysql>\s

mysql>\q 这是退出命令


初始化数据库。



















相关主题
相关文档
最新文档