更新时间: 2011-06-03
服务器版本: FreeBSD 7.3
在网上找了个脚本,经过多次测试和修改,成功率100%
df -k ## 查看分区情况【单位:byte】
df -h ## 查看分区情况【单位:GB】
find . -name "*.log" ## 查找文件
tail -f /usr/local/mysql/data/192.168.245.11.err ## 查看mysql错误日志
killall -HUP nginx ## 结束指定进程
chmod -R 0777 /var/data ## 把 /var/data 里面的所有文件和文件夹都设置为可读写
gd
png
pkgconfig
jpeg
freetype
pkg_add 安装gd时的软件包顺序
#!/bin/sh
###############################################
# 支持网站:http://blog.jiqila.com
# ver 0.1.0
# 适用于 FreeBSD 7.2、8.0,推荐使用 FreeBSD 8.0
# 其中nginx.conf、php.ini以及my.cnf的配置要参考http://blog.jiqila.com/post/157/
###############################################
###############################################
# 国内的服务器,最好先修改一下更新源,以提高下载速度
# 要先修改系统编码格式http://hi.baidu.com/jjxiaoyan/blog/item/9ac2a61efd71b21341341793.html
修改方法如下:
在~/.cshrc 中(位于/root/目录下)加入下面这一行定义pkg_add -r 时的源:
setenv PACKAGESITE ftp://ftp.freebsdchina.org/pub/FreeBSD/ports/i386/packages-stable/Latest/
在/etc/make.conf 中加入下面的定义从/usr/ports中安装软件时的源
MASTER_SITE_BACKUP= \
{DIST_SUBDIR} \
{DIST_SUBDIR} \
ftp://ftp.tw.freebsd.org/pub/FreeBSD/ports/distfiles/${DIST_SUBDIR} \
ftp://ftp5.freebsd.org/pub/FreeBSD/ports/distfiles/${DIST_SUBDIR} /
MASTER_SITE_OVERRIDE= ${MASTER_SITE_BACKUP}
rehash ## 让make.conf更改生效
###############################################
################ 加装安全补丁 ##################
freebsd-update fetch
freebsd-update install
################ 复制必需的文件[所需软件安装包] ##################
# ftp://ftp4.FreeBSD.org/pub/FreeBSD/ports/ports/ports.tar.gz
tar zxvf femp-0.1.0.tar.gz #涉及到的所有安装文件,由于较大就不提供下载了,可自行制作
cd femp
################ 更新ports ##################
portsnap fetch
portsnap extract
portsnap fetch update
## tar zxvf ports.tar.gz
## cp -r ports/ /usr/ports/distfiles/
################ 安装pcre ##################
cd /usr/ports/devel/pcre
make install clean
rehash
################ 安装xml ##################
cd /usr/ports/textproc/libxml
make install clean
cd /usr/ports/textproc/libxml2
make install clean
################ 安装curl ##################
cd /usr/ports/ftp/curl
make install clean
################ 安装jpeg ##################
cd /usr/ports/graphics/jpeg
make install clean
################ 安装png ##################
cd /usr/ports/graphics/png
make install clean
################ 安装gd ##################
cd /usr/ports/graphics/gd
make install
################ 安装freetype ##################
cd /usr/ports/print/freetype
make install clean
cd /usr/ports/print/freetype2
make install clean
################ 安装autoconf ##################
fetch ftp://mirrors.kernel.org/gnu/autoconf/autoconf-2.13.tar.gz
tar zxvf autoconf-2.13.tar.gz
cd autoconf-2.13
./configure
make
make install
##cd /usr/ports/devel/autoconf262
##make install clean
################ 安装nginx ##################
tar zxvf nginx-0.7.64.tar.gz
cd nginx-0.7.64
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
make
make install
cd ..
/usr/local/nginx/sbin/nginx ## 启动nginx
/usr/local/nginx/sbin/nginx -t ## 测试nginx.conf配置是否正确
ps aux ## 查看nginx服务是否启动
## nginx的配置可参考张宴或袁旭东的文章
## 张宴博客:http://blog.s135.com/nginx_php_v6
## 袁旭东博客:http://blog.jiqila.com/post/157/
## /usr/local/nginx/html ## nginx站点默认目录
## cp nginx.conf /usr/local/nginx/conf/
################ 安装mysql ##################
tar zxvf mysql-5.1.44.tar.gz
cd mysql-5.1.44
./configure --prefix=/usr/local/mysql/ --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=innobase --with-mysqld-user=mysql --without-ndb-debug --without-debug --with-charset=utf8 --localstatedir=/usr/local/mysql/data --with-collation=utf8_general_ci
## [Success] Thank you for choosing MySQL!
make ## [Success] Making all in win
make install
cd ..
pw groupadd mysql
pw useradd mysql -g mysql -d /usr/local/mysql -s /usr/sbin/nologin
mkdir -p /usr/local/mysql/data/
chown -R mysql:mysql /usr/local/mysql/
/usr/local/mysql/bin/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
cd /usr/local/mysql/share/mysql
cp my-large.cnf /etc/my.cnf
cp mysql.server /usr/local/mysql/mysqld
chmod 755 /usr/local/mysql/mysqld
/usr/local/mysql/mysqld start
## 若mysql无法启动,需要在my.cnf中加入下面这两句:
basedir="/usr/local/mysql/"
datadir="/usr/local/mysql/data/"
/usr/local/mysql/bin/mysql -u root -p -S /tmp/mysql.sock
# GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456';
# quit
cd /home/imarmot/femp/
################ 安装PHP ##################
""
mv "libmcrypt-2.5.8.tar.gz?modtime=1171868460&big_mirror=0" libmcrypt-2.5.8.tar.gz
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure --prefix=/usr
make
make install
cd ..
""
mv "mhash-0.9.9.9.tar.gz?modtime=1175740843&big_mirror=0" mhash-0.9.9.9.tar.gz
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9
./configure --prefix=/usr
make
make install
cd ..
""
mv "mcrypt-2.6.8.tar.gz?modtime=1194463373&big_mirror=0" mcrypt-2.6.8.tar.gz
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8
cd src
vi rfc2440.c
将
#include
修改为
#include
cd ..
./configure --prefix=/usr
make
make install
cd ..
mv mirror php-5.2.17.tar.gz
tar zxvf php-5.2.17.tar.gz
gzip -cd php-5.2.17-fpm-0.5.14.diff.gz | patch -d php-5.2.17 -p1
cd php-5.2.17/ext/gd/libgd/
编辑gd库的 gd_png.c文件,将
if (!png_check_sig (sig, 8)) { /* bad signature */
return NULL;
}
修改为
if (png_sig_cmp (sig, 0, 8)) { /* bad signature */
return NULL;
}
cd ../../../
./buildconf --force
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir=/usr --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr/local --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --disable-ipv6 --without-pear --enable-ftp
## [↑Success] Thank you for using PHP.
make ZEND_EXTRA_LIBS='-liconv' ## [Success] Build complete.
make install
提示:如果configure配置失败,可能是由于autoconf版本不匹配。经测试,autoconf2.62和autoconf2.13无此问题。若出现该问题,可重新安装autoconf,并删除php安装目录,重新解压安装php。
cp ./php.ini-recommended /usr/local/php/etc/php.ini
## cp /usr/local/php/etc/php-fpm.conf /usr/local/php/etc/
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
cd ..
tar jxvf eaccelerator-0.9.5.3.tar.bz2
cd eaccelerator-0.9.5.3
/usr/local/php/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config
make
make install
cd ..
tar zxvf PDO_MYSQL-1.0.2.tgz
cd 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
cd ..
tar zxvf ImageMagick-6.6.5-10.tar.gz
cd ImageMagick-6.6.5-10
ln -s /usr/local/lib/libfreetype.la /usr/lib/libfreetype.la
ln -s /usr/local/lib/libfreetype.so /usr/lib/libfreetype.so
ln -s /usr/local/lib/libfreetype.so.9 /usr/lib/libfreetype.so.9
ln -s /usr/local/lib/libjpeg.so /usr/lib/libjpeg.so
ln -s /usr/local/lib/libjpeg.la /usr/lib/libjpeg.la
ln -s /usr/local/lib/libjpeg.so.11 /usr/lib/libjpeg.so.11
ln -s /usr/local/lib/libpng.a /usr/lib/libpng.a
ln -s /usr/local/lib/libpng.so /usr/lib/libpng.so
ln -s /usr/local/lib/libpng.so.6 /usr/lib/libpng.so.6
./configure
make
make install
cd ..
tar zxvf imagick-2.2.2.tgz
cd imagick-2.2.2
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
cd ..
################ 修改php.ini ##################
vi /usr/local/php/etc/php.ini
查找output_buffering = 4096
修改为output_buffering = On
再查找extension_dir = "./"
修改为extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"
并在此行后增加以下几行,然后保存:
extension = "memcache.so"
extension = "pdo_mysql.so"
extension = "imagick.so"
extension = "eaccelerator.so"
################ 配置eAccelerator,加速PHP ##################
cd /usr/local/php/etc/
mkdir -p eaccelerator_cache
vi /usr/local/php/etc/php.ini
在文件末尾增加下面的内容:
[eaccelerator]
eaccelerator.shm_size="64"
eaccelerator.cache_dir="/usr/local/php/etc/eaccelerator_cache"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="3600"
eaccelerator.shm_prune_period="3600"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
################ 修改php-fpm.conf ##################
vi /usr/local/php/etc/php-fpm.conf
将
Unix user of processes
Unix group of processes
换成
Unix user of processes
www
Unix group of processes
www
################ 修改nginx.conf ##################
重点:
location ~ .*\.(php|php5)?$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
################ 开机启动php/nginx/mysql ##################
vi /etc/rc.local
/usr/local/nginx/sbin/nginx
/usr/local/mysql/mysqld start
/usr/local/php/sbin/php-fpm start
################ 创建需要的目录 ##################
## mkdir -p /data/php/eaccelerator_cache
## mkdir -p /data/www
chmod +w /usr/local/nginx/html
chown -R www:www /usr/local/nginx/html
chmod -R o+wx /usr/local/nginx/html ##为所有用户增加写权限
################ 复制启动文件 ##################
cp rc.local /etc/
################ 安装mono ##################
cd /usr/ports/lang/mono
make install clean
################ 安装mono ##################
cd /home/imarmot/femp/
tar zxvf jexus-3.3.tar.gz
mkdir /usr/local/jexus/
cp -r jexus-3.3/ /usr/local/jexus/
################ 服务自启动(/etc/rc.local) ##################
################ 服务自启动(/etc/rc.local) ##################
/usr/local/nginx/sbin/nginx
/usr/local/mysql/mysqld start
/usr/local/php/sbin/php-fpm start
阅读(1399) | 评论(0) | 转发(0) |