前幾天安裝FreeBSD 8.0 Web伺服器環境的時候寫的一個指令碼,已經在FreeBSD 8.0下測試通過,不過不是一鍵安裝,大家可以照指令碼複製粘貼手工進行操作。可以節省輸入命令的時間,減少了出錯的幾率。未來我將對指令碼進行修改,以使其 真正做到一鍵安裝。
#!/bin/sh
###############################################
# ver 0.1.0
# 適用於 FreeBSD 7.2、8.0,推薦使用 FreeBSD 8.0
###############################################
################ 加裝安全補丁 ##################
freebsd-update fetch
freebsd-update install
################ 複製必需的檔案 ##################
tar zxvf femp-0.1.0.tar.gz #涉及到的所有安裝檔案,由於較大就不提供下載了,可自行製作
cd femp
################ 更新ports ##################
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
################ 安裝freetype ##################
cd /usr/ports/print/freetype
make install clean
cd /usr/ports/print/freetype2
make install clean
################ 安裝autoconf ##################
cd /usr/ports/devel/autoconf262
make install clean
################ 安裝nginx ##################
cd /home/imarmot/femp/
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 ..
cp nginx.conf /usr/local/nginx/conf/
################ 安裝mysql ##################
tar zxvf mysql-5.1.41.tar.gz
cd mysql-5.1.41
./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=/data/mysql/data --with-collation=utf8_general_ci
make
make install
cd ..
pw groupadd mysql
pw useradd mysql -g mysql -d /data/mysql -s /usr/sbin/nologin
mkdir -p /data/mysql/data/
chown -R mysql:mysql /data/mysql/
/usr/local/mysql/bin/mysql_install_db --basedir=/usr/local/mysql --datadir=/data/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
/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 ##################
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure --prefix=/usr
make
make install
cd ..
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9
./configure --prefix=/usr
make
make install
cd ..
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8
./configure --prefix=/usr
make
make install
cd ..
tar zxvf php-5.2.11.tar.gz
gzip -cd php-5.2.11-fpm-0.5.13.diff.gz | patch -d php-5.2.11 -p1
cd php-5.2.11
./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
make ZEND_EXTRA_LIBS='-liconv'
make install
cd ..
cp ./php.ini /usr/local/php/etc/
cp ./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.5.4-2.tar.gz
cd ImageMagick-6.5.4-2
./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 ..
################ 建立需要的目錄 ##################
mkdir -p /data/php/eaccelerator_cache
mkdir -p /data/www
chmod +w /data/www
chown -R www:www /data/www
################ 複製開機檔案 ##################
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/