最近一直在研究freeBSD下nginx+php+mysql的安装,看了很多网上的资料收获不小,不过大部分都是编译安装,相对初学者来说比较复杂,不容易理解,所以我整合了一些ports安装的资料,都是经过自己验证后的,安装成功也比较容易理解,下面是两种成功的案例,其中有一个是Apache代替nginx的安装,希望对大家有所帮助。
cd /usr/ports/ftp/axel
make install
#修改 /et/make.conf
ee /etc/make.conf
#加入以下内容
FETCH_CMD=axel
FETCH_BEFORE_ARGS= -n 10 -a
FETCH_AFTER_ARGS=
DISABLE_SIZE=yes
MASTER_SITE_OVERRIDE?=/
http://ports.hshh.org/${DIST_SUBDIR}//
http://ports.cn.freebsd.org/${DIST_SUBDIR}//
ftp://ftp.freeBSDchina.org/pub/FreeBSD/ports/distfiles/${DIST_SUBDIR}/
MASTER_SITE_OVERRIDE?=${MASTER_SITE_BACKUP}
cd /usr/ports/www/nginx
make install
#配置编译参数
[ ] DEBUG Enable nginx debugging
[ ] IPV6 Enable IPv6
[ ] GOOGLE_PERFTOOLS Enable google perftools module
[X] HTTP_MODULE Enable HTTP module
[ ] HTTP_ADDITION_MODULE Enable http_addition module
[X] HTTP_CACHE_MODULE Enable http_cache module
[ ] HTTP_DAV_MODULE Enable http_webdav module
[ ] HTTP_FLV_MODULE Enable http_flv module
[X] HTTP_GZIP_STATIC_MODULE Enable http_gzip_static module
[ ] HTTP_IMAGE_FILTER_MODULE Enable http_image_filter module
[ ] HTTP_PERL_MODULE Enable http_perl module
[ ] HTTP_RANDOM_INDEX_MODULE Enable http_random_index module
[ ] HTTP_REALIP_MODULE Enable http_realip module
[X] HTTP_REWRITE_MODULE Enable http_rewrite module
[ ] HTTP_SECURE_LINK_MODULE Enable http_secure_link module
[ ] HTTP_SSL_MODULE Enable http_ssl module
[X] HTTP_STATUS_MODULE Enable http_stub_status module
[ ] HTTP_SUB_MODULE Enable http_sub module
[ ] HTTP_XSLT_MODULE Enable http_xslt module
[ ] MAIL_MODULE Enable IMAP4/POP3/SMTP proxy module
[ ] MAIL_IMAP_MODULE Enable IMAP4 proxy module
[ ] MAIL_POP3_MODULE Enable POP3 proxy module
[ ] MAIL_SMTP_MODULE Enable SMTP proxy module
[ ] MAIL_SSL_MODULE Enable mail_ssl module
[ ] WWW Enable html sample files
[ ] HTTP_ACCESSKEY_MODULE 3rd party http_accesskey module
[ ] HTTP_EVAL_MODULE 3rd party eval module
[ ] HTTP_FANCYINDEX_MODULE 3rd party http_fancyindex module
[ ] HTTP_MOGILEFS_MODULE 3rd party mogilefs module
[ ] HTTP_MP4_H264_MODULE 3rd party mp4/h264 module
[ ] HTTP_NOTICE_MODULE 3rd party notice module
[ ] HTTP_REDIS_MODULE 3rd party http_redis module
[ ] HTTP_RESPONSE_MODULE 3rd party http_response module
[ ] HTTP_UPLOAD_MODULE 3rd party upload module
[ ] HTTP_UPLOAD_PROGRESS 3rd party upload_progress module
[ ] HTTP_UPSTREAM_FAIR 3rd party upstream fair module
[ ] HTTP_UPSTREAM_KEEPALIVE 3rd party upstream keepalive module
[ ] HTTP_ZIP_MODULE 3rd party http_zip module
[ ] PASSENGER_MODULE 3rd party passenger module
#修改 nginx 配置文件
vi /usr/local/etc/nginx/nginx.conf
修改配置文件请参考http://wiki.nginx.org/NginxChsFullExample2(来自官方网站)
#设置 mysql 开机启动 vi /etc/rc.conf #添加以下内容 mysql_enable="YES"
#启动nginx /usr/local/etc/rc.d/nginx start
cd /usr/ports/textproc/libxml2
make install
cd /usr/ports/graphics/png
make install
cd /usr/ports/graphics/jpeg
make install
cd /usr/ports/print/freetype2
make install
cd /usr/ports/graphics/gd
make install
#配置编译参数
[ ] X11 X11 support
[ ] XPM XPM color bitmap loading support (requires X11)
[ ] FONTCONFIG fontconfig library support (requires X11)
[X] ICONV iconv support
cd /usr/ports/lang/php5 make install clean #配置编译参数 [X] CLI Build CLI version [X] CGI Build CGI version [ ] APACHE Build Apache module [ ] DEBUG Enable debug [X] SUHOSIN Enable Suhosin protection system (not for jails) [ ] MULTIBYTE Enable zend multibyte support [ ] IPV6 Enable ipv6 support [ ] MAILHEAD Enable mail header patch [ ] REDIRECT Enable force-cgi-redirect support (CGI only) [ ] DISCARD Enable discard-path support (CGI only) [X] FASTCGI Enable fastcgi support (CGI only) [X] PATHINFO Enable path-info-check support (CGI only) #安装 php5-extensions cd /usr/ports/lang/php5-extensions make install clean #配置编译参数 [ ] BCMATH bc style precision math functions [ ] BZ2 bzip2 library support [ ] CALENDAR calendar conversion support [X] CTYPE ctype functions [X] CURL CURL support [ ] DBA dba support [ ] DBASE dBase library support [X] DOM DOM support [ ] EXIF EXIF support [ ] FILEINFO fileinfo support [X] FILTER input filter support [ ] FRIBIDI FriBidi support [ ] FTP FTP support [X] GD GD library support [ ] GETTEXT gettext library support [ ] GMP GNU MP support [X] HASH HASH Message Digest Framework [X] ICONV iconv support [ ] IMAP IMAP support [ ] INTERBASE Interbase 6 database support (Firebird) [X] JSON JavaScript Object Serialization support [ ] LDAP OpenLDAP support [X] MBSTRING multibyte string support [ ] MCRYPT Encryption support [ ] MHASH Crypto-hashing support [ ] MING ming shockwave flash support [ ] MSSQL MS-SQL database support [X] MYSQL MySQL database support [ ] MYSQLI MySQLi database support [ ] NCURSES ncurses support (CLI only) [ ] ODBC unixODBC support [ ] OPENSSL OpenSSL support [ ] PCNTL pcntl support (CLI only) [X] PCRE Perl Compatible Regular Expression support [ ] PDF PDFlib support (implies GD) [X] PDO PHP Data Objects Interface (PDO) [X] PDO_SQLITE PDO sqlite driver [ ] PGSQL PostgreSQL database support [X] POSIX POSIX-like functions [ ] PSPELL pspell support [ ] READLINE readline support (CLI only) [ ] RECODE recode support [X] SESSION session support [ ] SHMOP shmop support [X] SIMPLEXML simplexml support [ ] SNMP SNMP support [ ] SOAP SOAP support [ ] SOCKETS sockets support [X] SPL Standard PHP Library [ ] SQLITE sqlite support [ ] SYBASE_CT Sybase database support [ ] SYSVMSG System V message support [ ] SYSVSEM System V semaphore support [ ] SYSVSHM System V shared memory support [ ] TIDY TIDY support [X] TOKENIZER tokenizer support [ ] WDDX WDDX support (implies XML) [X] XML XML support [X] XMLREADER XMLReader support [ ] XMLRPC XMLRPC-EPI support [X] XMLWRITER XMLWriter support [ ] XSL XSL support (Implies DOM) [ ] YAZ YAZ support (ANSI/NISO Z39.50) [ ] ZIP ZIP support [X] ZLIB ZLIB support #安装过程中遇到的软件配置编译参数默认选择即可