本文将说明安装Apache-2.0.45+php-4.3.1+mysql-4.1.0 for Solaris 9/x86,使用的php能提供最大20M 的文件上载功能,支持 session 。
由于本人将所有软件的源代码放置在目录 /bak 下 ,安装目录为 /usr/local ,下载后的源代码包在/bak目录下,故执行以下操作:
注:1。用记事本打开本文档时,最好取消‘自动换行',以便看清楚每一条命令。
2。本文也是在参看软件文档、论坛网友的帮助下实现的。
环境
--------------
hardware: C900+128MB+nVida16MB+Mator30GB+40xCDROM+rtl8139netcard+1.44MBfloppy
software: Solaris 9 for x86 (Plus OEM 2077MB)
准备工作
---------------
ftp://ftp.sjtu.edu.cn/public/Solaris/sunfreeware/sparc/
首先要安装solaris 9的编译环境,去http://www.sunfreeware.com/下载一下软件:
1.autoconf-2.13-sol9-intel-local.gz
2.automake-1.4-sol9-intel-local.gz
3.bison-1.28-sol9-intel-local.gz
4.gcc-3.2.2-sol9-intel-local.gz
5.gzip-1.3-sol9-intel-local
6.make-3.79.1-sol9-intel-local.gz
7.tar-1.13-sol9-intel-local.gz
8.libgcc-3.2.2-sol9-intel-local.gz
9.ncurse
10.flex-2.5.4-sol9-intel-local.gz
11.sed-4.0-sol9-intel-local.gz
设置环境变量:
vi /etc/profile
PATH=/usr/local/sbin:/usr/local/bin:/usr/ccs/bin:/usr/sbin:/sbin:/bin:/usr/local/mysql/bin:/usr/bin:/usr/dt/bin:/usr/openwin/bin:/usr/ucb
退出重启系统使变量生效,按照下列步骤安装软件:
1.pkgadd -d gzip-1.3-sol9-intel-local
2.gunzip autoconf-2.13-sol9-intel-local.gz
3.gunzip automake-1.4-sol9-intel-local.gz
4.gunzip gcc-3.2.2-sol9-intel-local.gz
5 gunzip bison-1.28-sol9-intel-local.gz
6.pkgadd -d autoconf-2.13-sol9-intel-local
7.pkgadd -d automake-1.4-sol9-intel-local
8.pkgadd -d gcc-3.2.2-sol9-intel-local
9.pkgadd -d make-3.79.1-sol9-intel-local
10.pkgadd -d tar-1.13-sol8-local
pkgadd -d nucrse
pkgadd -d flex
10.gunzip tar-1.13.tar.gz
11.tar xvf tar-1.13.tar
12.cd tar-1.13
13../configure --prefix=/usr/local/gnutar
14. make
15. make install
16. cp /usr/local/gnutar/bin/tar /usr/local/bin/gtar
把libgcc包中所有的文件从/usr/local/lib拷贝到/usr/lib中,可以解决这个问题,其中包含
libgcc_s.so
libstdc++.la
libstdc++.so.5.0.0
libgcc_s.so.1
libstdc++.so
libstdc++.so.5.0.1
libstdc++.a
libstdc++.so.5
libstdc++.so.5.0.2
1、安装
-----------------------------
### 软件下载
分别下载以下软件(均为源代码):
Apache-2.0.45 (www.apache.org)
php-4.3.1 (www.php.net)
mysql-4.1.0 (www.mysql.com)
*************以下内容可编入setup.sh脚本文件中再运行它**************
#### 准备安装 ####
mkdir /bak
mkdir /usr/local/mysql
mkdir /usr/local/apache
# 建立mysql组及用户
groupadd -g 201 mysql
useradd -u 1001 -g mysql -d /export/home/mysql -m -s /bin/tcsh -c "MySQL Administrator" mysql
passwd mysql //设置用户口令
# 复制文件
cp mysql*.gz /bak/
cp httpd*.gz /bak/
cp php*.gz /bak
# 解压缩文件
cd /bak
/usr/local/gnutar/bin/tar -zxvf /bak/mysql-4.1.0.tar.gz
/usr/local/gnutar/bin/tar -zxvf /bak/httpd-2.0.45.tar.gz
/usr/local/gnutar/bin/tar -zxvf /bak/php-4.3.1.tar.gz
#### 安装配置过程 ####
# 安装 mysql-4.1.0
cd /bak/mysql-4.1.0
CC=gcc CFLAGS="-O6" CXX=gcc CXXFLAGS="-O6 -felide-constructors -fno-exceptions -fno-rtti"
./configure --with-as=/usr/ccs/bin/as --with-ld=/usr/ccs/bin/ld --disable-nls --prefix=/usr/local/mysql --with-mysqld-user=mysql --with-charset=gb2312 --with-extra-charsets=all
/usr/local/bin/make
/usr/local/bin/make install
/usr/local/mysql/bin/mysql_install_db
chown -R root /usr/local/mysql
chgrp -R mysql /usr/local/mysql
chown -R mysql /usr/local/mysql/var
chmod 777 /usr/local/mysql/lib/mysql/libmysqlclient.a
cp support-files/my-medium.cnf /etc/my.cnf
# 设置引导文件
cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld
cd /etc/rc3.d
ln -s ../init.d/mysqld S90mysql
ln -s ../init.d/mysqld K90mysql
# load lib
ln -s /usr/local/mysql/include/mysql /usr/include/mysql
ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
echo /usr/lib/mysql >> /etc/ld.so.conf
ldconfig
# 启动数据库
cd /usr/local/mysql/bin
./mysql_safed --user=mysql &
# 连接测试
cd /uca/local/mysql/bin
./mysql -u root
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 1 to server version: 3.23.44
Type 'help;' or 'h' for help. Type 'c' to clear the buffer.
mysql>
##############################################
# mysql 安装完毕
##############################################
### 安装 Apache-2.0.45
cd /bak/httpd-2.0.45
CC=gcc CFLAGS="-O6" CXX=gcc CXXFLAGS="-O6 -felide-constructors -fno-exceptions -fno-rtti"
./configure --disable-nls --with-ld=/usr/ccs/bin/ld --with-as=/usr/ccs/bin/as --prefix=/usr/local/apache --with-charset=gb2312 --with-extra-charsets=all --enable-so --disable-nls
make
make install
# 创建符号连接
cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
ln -s /etc/init.d/httpd /etc/rc3.d/S90http
ln -s /etc/init.d/httpd /etc/rc3.d/K90http
ln -s /usr/local/apache/bin/apachectl /bin/apache
ln -s /usr/local/mysql/bin/mysql /bin/mysql
### 安装php-4.3.1
cd /bak/php-4.3.1
CC=gcc CFLAGS="-O6" CXX=gcc CXXFLAGS="-O6 -felide-constructors -fno-exceptions -fno-rtti"
./configure --with-charset=gb2312 --with-extra-charsets=all --with-mysql=/usr/local/mysql --with-apxs2=/usr/local/apache/bin/apxs --enable-track-vars --enable-force-cgi-redirect --enable-pic --enable-inline-optimiation --enable-memory-limit --enable-bcmath
### ./configure --disable-nls --with-ld=/usr/ccs/bin/ld --with-as=/usr/ccs/bin/as --with-charset=gb2312 --with-extra-charsets=all --with-mysql=/usr/local/mysql --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/apache/conf --enable-track-vars --enable-force-cgi-redirect --enable-pic --enable-inline-optimiation --enable-memory-limit --enable-bcmath --enable-shmop --enable-versioning --enable-calendar --enable-dbx --enable-dio --enable-mcal
make
make install
cp php.ini-dist /usr/local/lib/php.ini
###cp php.ini-dist /usr/local/apache/conf/php.ini
*************以上内容已编入setup.sh脚本文件中**************
### 修改配置文件
----------------------
vi /usr/local/apache/conf/httpd.conf
# 加入以下行(装载php4模块并指定.php 文件)
# LimitRequestBody (指定php处理的请求数据大小,以下指定为 20M)
LoadModule php4_module modules/libphp4.so
SetOutputFilter PHP
SetInputFilter PHP
LimitRequestBody 20971520
#注解以下行(在文本前加#),使apache显示中文,具体原因未知
ForceLanguagePriority Prefer Fallback
AddDefaultCharset ISO-8859-1
#加入默认的引导文件index.php(找到DirectoryIndex,修改如下:)
DirectoryIndex index.php index.html index.html.var
# 设置你的服务器的域名或IP地址及****端口
ServerName 192.168.0.10:80
#指定网站目录(假设为 /apache 目录)
DocumentRoot "/apache"
#把Group改一下,改成
Group=nobody
默认的是Group=-1,在SOLARIS上不行。
###编辑php.ini配置文件
-------------------------
vi /usr/local/apache/conf/php.ini
#找到并修改以下参数
max_execution_time = 600 ;最大运行时间 600 秒
max_input_time = 600 ;最大输出时间 600秒
memory_limit = 20M ;最大内存限制 20M
file_uploads = On ;允许上载文件
upload_max_filesize = 20M ;最大文件大小 20M
post_max_size = 20M ;php可接受的 post 方法大小 20M
session.auto_start = 1 ;session自动启动
### 安全性
-------------------------
提高mysql的安全性
1.修改/etc/init.d/mysqld,使其只****localhost的埠,将如下的一行
$bindir/safe_mysqld --datadir=$datadir --pid-file=$pid_file&
修改为:
$bindir/safe_mysqld --datadir=$datadir --pid-file=$pid_file --bind-address=127.0.0.1&
2.为mysql的root账号设置密码
# /usr/local/mysql/bin/mysqladmin -u root password "root用户的密码"
# /usr/local/mysql/bin/mysqladmin -u root reload
提高apache的安全性
1.新建包含文件目录inc_doc:
# mkdir /usr/lcoa/apache/inc_doc
2.设置PHP初始化文件的搜索路径,使PHP程序在inc_doc目录中搜索包含文件:
# vi /usr/local/apache/conf/php.ini
添加或修改:
include_path="/usr/local/apache/inc_doc"
或添加或修改:
include_path="other/include_doc/path:/usr/local/apache/inc_doc"
### 运行
---------------------
#启动mysql
/usr/local/mysql/bin/safe_mysqld --user=mysql &
#停止mysql
/usr/local/mysql/bin/mysqladmin shutdown
#启动apache
/etc/init.d/httpd start
#停止apache
/etc/init.d/httpd stop
### 测试:
mkdir /apache
echo " /apache/index.php
echo "phpinfo();" >>/apache/index.php
echo "?>" >>/apache/index.php
#生成/apache/index.php 文件
在浏览器上输入 solaris 机器网址,php 的配置信息将显示出来。