【原创】Red hat linux服务器简明安装手册(OpenSSL+Mysql+Apache2+PHP)

注意:以下文档链接版本可能发生了变化,可找其它包来源。(已经过了比较严格的测试,确保严谨无误)

一、安装OpenSSL
软件主页:http://www.openssl.org/
1.下载源码包
wget http://www.openssl.org/source/openssl-0.9.7e.tar.gz
2.解压源码包
tar zxvf openssl-0.9.7e.tar.gz
3.配置编译参数
cd openssl-0.9.7e
./config --prefix=/usr
4.编译并安装
make
make install

二、安装Mysql
软件主页:http://www.mysql.com
1.添加mysql 用户及组
groupadd mysql
useradd -g mysql -d /var/lib/mysql -s /sbin/nologin mysql
1.下载源码包
wget http://mysql.ihostunit.com/Download...ql-4.1.7.tar.gz
2.解压源码包
tar zxvf mysql-4.1.7.tar.gz
3.配置编译参数
cd mysql-4.1.7
./configure \
--prefix=/usr \
--localstatedir=/var/lib/mysql \
--enable-local-infile \
--with-openssl \
--with-ndbcluster
4.编译并安装
make
make install
5.初始化数据库
./scripts/mysql_install_db
6.拷贝配置文件到/etc 目录
cp ./support-files/my-small.cnf /etc/my.cnf
7.拷贝自动启动脚本到系统初始化脚本目录并赋予执行权限
cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod +x /etc/rc.d/init.d/mysqld
8.添加mysql 为系统服务
chkconfig --add mysqld
9.更改/var/lib/mysql 及其子目录的属主
chown -R mysql.mysql /var/lib/mysql
10.在/usr/lib 目录建立mysql 共享库的链接
ln -s /usr/lib/mysql/libmysqlclient.so.14.0.0 /usr/lib/libmysqlclient.so
ln -s /usr/lib/mysql/libmysqlclient.so.14.0.0 /usr/lib/libmysqlclient.so.14
ln -s /usr/lib/mysql/libndbclient.so.0.0.0 /usr/lib/libndbclient.so
ln -s /usr/lib/mysql/libndbclient.so.0.0.0 /usr/lib/libndbclient.so.0
11.启动mysql 服务
service mysqld start
12.运行mysql 客户端,为root 用户指定密码及访问许可
mysql -u root
mysql>set password for root@localhost=password('your password');
mysql>use mysql;
mysql>delete from user where user='' ;
mysql>delete from user where host<>'localhost' ;
mysql>flush privileges ;
mysql>\q

三、安装Apache2
软件主页:http://www.apache.org
1.下载源码包
wget http://www.eu.apache.org/dist/httpd/httpd-2.0.52.tar.gz
2.解压源码包
tar zxvf httpd-2.0.52.tar.gz
3.配置编译参数
cd httpd-2.0.52
./configure \
--prefix=/usr/local/apache2 \
--enable-so \
--enable-ssl \
--enable-rewrite \
--enable-deflate \
--enable-cache \
--enable-mem-cache \
--enable-file-cache \
--enable-disk-cache \
--enable-mods-shared=most
4.编译并安装
make
make install
5.生成SSL 证书
mkdir /usr/local/apache2/conf/ssl.crt
mkdir /usr/local/apache2/conf/ssl.key
openssl req -new -out server.csr
openssl rsa -in privkey.pem -out server.key
openssl x509 -in server.csr -out server.crt -req -signkey server.key -days 365
rm .rnd
rm privkey.pem
rm server.csr
mv server.crt /usr/local/apache2/conf/ssl.crt
mv server.key /usr/local/apache2/conf/ssl.key
6.按实际情况修改apache 配置文件:
vi /usr/local/apache2/conf/httpd.conf

四、安装mcrypt 加密库
软件主页:http://sourceforge.net/projects/mcrypt/
http://sourceforge.net/projects/mhash/
1.下载libmcrypt 源码包
wget http://voxel.dl.sourceforge.net/sou...pt-2.5.7.tar.gz
2.解压libmcrypt 源码包
tar zxvf libmcrypt-2.5.7.tar.gz
3.配置编译参数
cd libmcrypt-2.5.7
./configure
4.编译并安装libmcrypt
make
make install
5.下载mhash 源码包
wget http://voxel.dl.sourceforge.net/sou...sh-0.9.1.tar.gz
6.解压mhash 源码包
tar zxvf mhash-0.9.1.tar.gz
7.配置编译参数
cd mhash-0.9.1
./configure
8.编译并安装lmhash
make
make install
9.下载mcrypt 源码包
wget http://unc.dl.sourceforge.net/sourc...pt-2.6.4.tar.gz
10.解压mcrypt 源码包
tar zxvf mcrypt-2.6.4.tar.gz
11.配置编译参数
cd mcrypt-2.6.4
LD_LIBRARY_PATH=/usr/local/lib ./configure
8.编译并安装mcrypt
make
make install

五、安装php
软件主页:http://www.php.net
1.下载源码包
wget http://us2.php.net/distributions/php-5.0.2.tar.gz
2.解压源码包
tar zxvf php-5.0.2.tar.gz
3.配置编译参数
cd php-5.0.2
./configure \
--prefix=/usr \
--with-mysql \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-openssl \
--with-zlib \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-zlib-dir \
--with-ttf \
--with-freetype-dir \
--with-gettext \
--with-curl \
--with-ldap \
--with-mcrypt \
--enable-gd-native-ttf \
--enable-ftp \
--enable-embed \
--enable-fastcgi \
--enable-calendar \
--enable-magic-quotes \
--enable-track-vars \
--enable-sockets \
--enable-sysvsem \
--enable-sysvshm \
--enable-sysvmsg \
--enable-pcntl \
--enable-shmop \
--with-config-file-path=/etc
4.编译并安装
make
make install
5.拷贝配置文件到/etc 目录
cp php.ini-recommended /etc/php.ini
6.配置apache2 支持php
vi /usr/local/apache2/conf/httpd.conf
增加:
LoadModule php5_module /usr/lib/libphp5.so
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps