FreeBSD下配置Nginx+php+mysql高性能web服务器

概述:

FreeBSD版本8.4

Nginx版本1.6

php版本5.4

mysql版本5.6

在配置之前要先更新系统,在root模式下输入如下命令查看pkg安装工具版本,如果版本低于1.4,那么需要更新才可使用:

配置环境的服务器要能上网,因为需要直接从官方资源站点下载配置包。

#pkg info
将看到如下信息,系统提示需要安装pkg工具:
root@localhost:/usr/home/root001 # pkg info
The package management tool is not yet installed on your system.
Do you want to fetch and install it now? [y/N]:
选择yes
Do you want to fetch and install it now? [y/N]: y
Bootstrapping pkg please wait
_http._tcp.pkg.FreeBSD.org
Installing pkg-1.4.7...
Extracting pkg-1.4.7: 100%
Message for pkg-1.4.7:
 If you are upgrading from the old package format, first run:
  # pkg2ng
pkg: PACKAGESITE in pkg.conf is no longer supported.  Convert to the new repository style.  See pkg.conf(5)
pkg: Cannot parse configuration file!
系统提示运行pkg2ng 此时配置文件和内部数据库还未更新
pkg: PACKAGESITE in pkg.conf is no longer supported.  Convert to the new repository style.  See pkg.conf(5)
pkg: Cannot parse configuration file!
Analysing shared libraries, this will take a while...
pkg: PACKAGESITE in pkg.conf is no longer supported.  Convert to the new repository style.  See pkg.conf(5)
pkg: Cannot parse configuration file!
更新系统安装包,在/usr/ports/下运行如下命令:
root@localhost:/usr/ports # portsnap fetch
Looking up portsnap.FreeBSD.org mirrors... 7 mirrors found.
Fetching public key from ec2-ap-southeast-2.portsnap.freebsd.org... done.
Fetching snapshot tag from ec2-ap-southeast-2.portsnap.freebsd.org... done.
Extracting snapshot... done.
Verifying snapshot integrity... done.
Fetching snapshot tag from ec2-ap-southeast-2.portsnap.freebsd.org... done.
Fetching snapshot metadata... done.
Updating from Mon Feb  9 08:16:34 CST 2015 to Mon Feb  9 23:26:07 CST 2015.
Fetching 4 metadata patches... done.
Applying metadata patches... done.
Fetching 0 metadata files... done.
Fetching 33 patches.....10....20....30. done.
Applying patches... done.
Fetching 3 new ports or files... done.
root@localhost:/usr/ports #
然后运行释放更新命令,这个时间稍微久一些:
root@localhost:/usr/ports # portsnap extract
然后更新目录和数据库:
root@localhost:/usr/ports # portsnap fetch update
Looking up portsnap.FreeBSD.org mirrors... 7 mirrors found.
Fetching snapshot tag from ec2-ap-southeast-2.portsnap.freebsd.org... done.
Fetching snapshot metadata... done.
Updating from Mon Feb  9 23:26:07 CST 2015 to Mon Feb  9 23:43:52 CST 2015.
Fetching 1 metadata patches. done.
Applying metadata patches... done.
Fetching 0 metadata files... done.
Fetching 1 patches. done.
Applying patches... done.
Fetching 0 new ports or files... done.
Removing old files and directories... done.
Extracting new files:
/usr/ports/cad/pcb/
Building new INDEX files... done.
//开始编译安装pkg工具
root@localhost:/usr/ports # make && make install clean
或者:
root@localhost:/usr/ports/ports-mgmt/pkg # pkg_add -r pkg
............................
checking for arc4random_uniform... (cached) yes
checking for chflags... yes
checking for chflagsat... no
checking whether we should only build the static version of pkg... no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating external/Makefile
config.status: creating scripts/Makefile
config.status: creating docs/Makefile
config.status: creating tests/Makefile
config.status: creating libpkg/Makefile
config.status: creating libpkg/repo/Makefile
config.status: creating libpkg/pkg.h
config.status: creating libpkg/pkg.pc
config.status: creating scripts/periodic/400.status-pkg
config.status: creating scripts/periodic/410.pkg-audit
config.status: creating scripts/periodic/411.pkg-backup
config.status: creating scripts/periodic/460.pkg-checksum
config.status: creating scripts/periodic/490.status-pkg-changes
config.status: creating scripts/sbin/pkg2ng
config.status: creating scripts/completion/_pkg.bash
config.status: creating scripts/completion/_pkg
config.status: creating libpkg/repo/binary/Makefile
config.status: creating pkg_config.h
config.status: executing depfiles commands
config.status: executing libtool commands
config.status: executing pkg_repos.h commands
config.status: executing mkdir commands
===>  Building for pkg-1.4.10
/usr/bin/make  all-recursive
  CC       libucl/src/libucl_la-ucl_emitter.lo
  CC       libucl/src/libucl_la-ucl_emitter_utils.lo
  CC       libucl/src/libucl_la-ucl_emitter_streamline.lo
  CC       libucl/src/libucl_la-ucl_hash.lo
CC       libucl/src/libucl_la-ucl_parser.lo
  CC       libucl/src/libucl_la-ucl_schema.lo
CC       libucl/src/libucl_la-ucl_util.lo
CC       libucl/src/libucl_la-xxhash.lo
libucl/src/ucl_schema.c: In function 'ucl_schema_validate':
libucl/src/ucl_schema.c:885: warning: 'ret' may be used uninitialized in this function
  CC       libucl/src/libucl_static_la-ucl_emitter.lo
  CC       libucl/src/libucl_static_la-ucl_emitter_utils.lo
CC       libucl/src/libucl_static_la-ucl_emitter_streamline.lo
  CC       libucl/src/libucl_static_la-ucl_hash.lo
  CC       libucl/src/libucl_static_la-ucl_parser.lo
  CC       libucl/src/libucl_static_la-ucl_schema.lo
  CC       libucl/src/libucl_static_la-ucl_util.lo
libucl/src/ucl_schema.c: In function 'ucl_schema_validate':
libucl/src/ucl_schema.c:885: warning: 'ret' may be used uninitialized in this function
  CC       libucl/src/libucl_static_la-xxhash.lo
CC       sqlite/libsqlite_la-sqlite3.lo
CC       sqlite/libsqlite_la-shell.lo
sqlite/sqlite3.c: In function 'sqlite3BtreeBeginTrans':
sqlite/sqlite3.c:54924: warning: unused variable 'pBlock'
sqlite/sqlite3.c: In function 'balance_nonroot':
sqlite/sqlite3.c:59023: warning: unused variable 'key'
  CC       sqlite/libsqlite_static_la-sqlite3.lo
CC       sqlite/libsqlite_static_la-shell.lo
sqlite/sqlite3.c: In function 'sqlite3BtreeBeginTrans':
sqlite/sqlite3.c:54924: warning: unused variable 'pBlock'
sqlite/sqlite3.c: In function 'balance_nonroot':
sqlite/sqlite3.c:59023: warning: unused variable 'key'
CC       expat/lib/libexpat_la-xmlparse.lo
CC       expat/lib/libexpat_la-xmlrole.lo
CC       expat/lib/libexpat_la-xmltok.lo
CC       expat/lib/libexpat_static_la-xmlparse.lo
  CC       expat/lib/libexpat_static_la-xmlrole.lo
  CC       expat/lib/libexpat_static_la-xmltok.lo
CC       libsbuf/libsbuf_la-subr_sbuf.lo
  CC       libsbuf/libsbuf_static_la-subr_sbuf.lo
CC       picosat/libpicosat_la-picosat.lo
CC       picosat/libpicosat_la-version.lo
  CC       picosat/libpicosat_static_la-picosat.lo
....................
.............................................

===>  Installing for pkg-1.4.10
===>  Checking if pkg already installed
===>   Registering installation for pkg-1.4.10
Installing pkg-1.4.10...
If you are upgrading from the old package format, first run:
  # pkg2ng
//系统提示更新数据库:
root@localhost:/usr/ports/ports-mgmt/pkg # pkg2ng
Converting packages from /var/db/pkg
Analysing shared libraries, this will take a while...
Checking all packages: 100%
root@localhost:/usr/ports/ports-mgmt/pkg # ls
Makefile        distinfo        files           pkg-descr       pkg-message     pkg-plist       work
For more information on available commands and options see 'pkg help'.
//然后更新pkg
root@localhost:/usr/ports/ports-mgmt/pkg # pkg update
Updating FreeBSD repository catalogue...
Fetching meta.txz: 100%    968 B   1.0kB/s    00:01   
Fetching packagesite.txz: 100%    5 MiB  58.1kB/s    01:31   
Processing entries: 100%
FreeBSD repository update completed. 23775 packages processed
root@localhost:/usr/ports/ports-mgmt/pkg #
//此时在看pkg版本
root@localhost:/usr/ports/ports-mgmt/pkg # pkg -v
1.4.10

此时pkg更新完毕
我们利用pkg工具直接安装web服务所需的程序包,可以一次将所需包安装,此时pkg自动会将关联的
支持程序全部安装,web服务器我们需要nginx php5 及php5-extensions扩展,此扩展包含了gd等的扩展程序
pecl扩展,mysql数据库
如下:
root@localhost:/usr/local # pkg install nginx php5 php5-extensions pecl-APC mysql56-server
Updating FreeBSD repository catalogue...
FreeBSD repository is up-to-date.
All repositories are up-to-date.
Updating database digests format: 100%
The following 28 packages will be affected (of 0 checked):
New packages to be INSTALLED:
        nginx: 1.6.2_1,2
        php5: 5.4.37
        php5-extensions: 1.7
        pecl-APC: 3.1.14_1
        mysql56-server: 5.6.22
        pcre: 8.35_2
        libxml2: 2.9.2_2
        libiconv: 1.14_6
        php5-session: 5.4.37
        php5-xmlwriter: 5.4.37
        php5-xmlreader: 5.4.37
        php5-dom: 5.4.37
        php5-xml: 5.4.37
        php5-simplexml: 5.4.37
        php5-ctype: 5.4.37
        php5-posix: 5.4.37
        php5-hash: 5.4.37
        php5-filter: 5.4.37
        php5-tokenizer: 5.4.37
        php5-json: 5.4.37
        php5-sqlite3: 5.4.37_1
        sqlite3: 3.8.8.1
        php5-pdo_sqlite: 5.4.37_1
        php5-pdo: 5.4.37
        php5-iconv: 5.4.37
        php5-phar: 5.4.37
        perl5: 5.18.4_11
        mysql56-client: 5.6.22
The process will require 192 MiB more space.
28 MiB to be downloaded.
Proceed with this action? [y/N]:

///选择“y”pkg会自动将所需包全部安装完毕

Proceed with this action? [y/N]: y
Fetching nginx-1.6.2_1,2.txz: 100%  239 KiB  49.0kB/s    00:05   
Fetching php5-5.4.37.txz: 100%    1 MiB  63.0kB/s    00:28   
Fetching php5-extensions-1.7.txz: 100%    1 KiB   1.1kB/s    00:01   
Fetching pecl-APC-3.1.14_1.txz: 100%   94 KiB  48.6kB/s    00:02   
Fetching mysql56-server-5.6.22.txz: 100%    8 MiB  49.5kB/s    02:50   
Fetching pcre-8.35_2.txz: 100%    1 MiB  58.7kB/s    00:19   
Fetching libxml2-2.9.2_2.txz: 100%  709 KiB  66.0kB/s    00:11   
Fetching libiconv-1.14_6.txz: 100%  594 KiB  60.9kB/s    00:10   
Fetching php5-session-5.4.37.txz: 100%   29 KiB  29.7kB/s    00:01   
Fetching php5-xmlwriter-5.4.37.txz: 100%   12 KiB  13.0kB/s    00:01   
Fetching php5-xmlreader-5.4.37.txz: 100%   13 KiB  13.4kB/s    00:01   
Fetching php5-dom-5.4.37.txz: 100%   54 KiB  56.0kB/s    00:01   
Fetching php5-xml-5.4.37.txz: 100%   19 KiB  19.8kB/s    00:01   
Fetching php5-simplexml-5.4.37.txz: 100%   21 KiB  21.5kB/s    00:01   
Fetching php5-ctype-5.4.37.txz: 100%    6 KiB   6.7kB/s    00:01   
Fetching php5-posix-5.4.37.txz: 100%   11 KiB  11.5kB/s    00:01   
Fetching php5-hash-5.4.37.txz: 100%  116 KiB  39.9kB/s    00:03   
Fetching php5-filter-5.4.37.txz: 100%   19 KiB  20.3kB/s    00:01   
Fetching php5-tokenizer-5.4.37.txz: 100%    8 KiB   8.7kB/s    00:01   
Fetching php5-json-5.4.37.txz: 100%   17 KiB  17.6kB/s    00:01   
Fetching php5-sqlite3-5.4.37_1.txz: 100%   17 KiB  18.3kB/s    00:01   
Fetching sqlite3-3.8.8.1.txz: 100%  660 KiB  96.6kB/s    00:07   
Fetching php5-pdo_sqlite-5.4.37_1.txz: 100%   13 KiB  13.5kB/s    00:01   
Fetching php5-pdo-5.4.37.txz: 100%   44 KiB  45.5kB/s    00:01   
Fetching php5-iconv-5.4.37.txz: 100%   17 KiB  18.0kB/s    00:01   
Fetching php5-phar-5.4.37.txz: 100%  101 KiB 104.0kB/s    00:01   
Fetching perl5-5.18.4_11.txz: 100%   12 MiB  52.7kB/s    04:14   
Fetching mysql56-client-5.6.22.txz: 100%    1 MiB  62.6kB/s    00:30   
Checking integrity... done (0 conflicting)
[1/28] Installing libiconv-1.14_6...
[1/28] Extracting libiconv-1.14_6: 100%
[2/28] Installing pcre-8.35_2...
[2/28] Extracting pcre-8.35_2: 100%
[3/28] Installing libxml2-2.9.2_2...
[3/28] Extracting libxml2-2.9.2_2: 100%
[4/28] Installing php5-5.4.37...
[4/28] Extracting php5-5.4.37: 100%
[5/28] Installing php5-dom-5.4.37...
[5/28] Extracting php5-dom-5.4.37: 100%
[6/28] Installing php5-hash-5.4.37...
[6/28] Extracting php5-hash-5.4.37: 100%
[7/28] Installing sqlite3-3.8.8.1...
[7/28] Extracting sqlite3-3.8.8.1: 100%
[8/28] Installing php5-pdo-5.4.37...
[8/28] Extracting php5-pdo-5.4.37: 100%
[9/28] Installing php5-session-5.4.37...
[9/28] Extracting php5-session-5.4.37: 100%
[10/28] Installing php5-xmlwriter-5.4.37...
[10/28] Extracting php5-xmlwriter-5.4.37: 100%
[11/28] Installing php5-xmlreader-5.4.37...
[11/28] Extracting php5-xmlreader-5.4.37: 100%
[12/28] Installing php5-xml-5.4.37...
[12/28] Extracting php5-xml-5.4.37: 100%
[13/28] Installing php5-simplexml-5.4.37...
[13/28] Extracting php5-simplexml-5.4.37: 100%
[14/28] Installing php5-ctype-5.4.37...
[14/28] Extracting php5-ctype-5.4.37: 100%
[15/28] Installing php5-posix-5.4.37...
[15/28] Extracting php5-posix-5.4.37: 100%
[16/28] Installing php5-filter-5.4.37...
[16/28] Extracting php5-filter-5.4.37: 100%
[17/28] Installing php5-tokenizer-5.4.37...
[17/28] Extracting php5-tokenizer-5.4.37: 100%
[18/28] Installing php5-json-5.4.37...
[18/28] Extracting php5-json-5.4.37: 100%
[19/28] Installing php5-sqlite3-5.4.37_1...
[19/28] Extracting php5-sqlite3-5.4.37_1: 100%
[20/28] Installing php5-pdo_sqlite-5.4.37_1...
[20/28] Extracting php5-pdo_sqlite-5.4.37_1: 100%
[21/28] Installing php5-iconv-5.4.37...
[21/28] Extracting php5-iconv-5.4.37: 100%
[22/28] Installing php5-phar-5.4.37...
[22/28] Extracting php5-phar-5.4.37: 100%
[23/28] Installing perl5-5.18.4_11...
[23/28] Extracting perl5-5.18.4_11: 100%
[24/28] Installing mysql56-client-5.6.22...
[24/28] Extracting mysql56-client-5.6.22: 100%
[25/28] Installing nginx-1.6.2_1,2...
===> Creating users and/or groups.
Using existing group 'www'.
Using existing user 'www'.
[25/28] Extracting nginx-1.6.2_1,2: 100%
[26/28] Installing php5-extensions-1.7...
[27/28] Installing pecl-APC-3.1.14_1...
[27/28] Extracting pecl-APC-3.1.14_1: 100%
[28/28] Installing mysql56-server-5.6.22...
===> Creating users and/or groups.
Creating group 'mysql' with gid '88'.
Creating user 'mysql' with uid '88'.
[28/28] Extracting mysql56-server-5.6.22: 100%
Message for pecl-APC-3.1.14_1:
 ************************************************************************
You may edit /usr/local/etc/php.ini to change this variables:
apc.enabled="1"
            ^^^ -> Default value
apc.shm_size="30"
             ^^^^ -> Default value
* More information on /usr/local/share/doc/APC/INSTALL
Then restart your web server and consult the output of phpinfo().
If there is an informational section for APC, the installation was
successful.
************************************************************************
Message for mysql56-server-5.6.22:
 ************************************************************************
Remember to run mysql_upgrade the first time you start the MySQL server
after an upgrade from an earlier version.
************************************************************************
root@localhost:/usr/local #
//编辑系统启动文件
//FreeBSD下面自带vi,ee,编辑器看情况习惯使用
root@localhost:/usr/local # ee /etc/rc.conf
//在配置文件中加入下面几行:
=====line 16 col 20 lines from top 16 =========================================
# -- sysinstall generated deltas -- # Tue Feb 10 14:06:43 2015
# Created: Tue Feb 10 14:06:43 2015
# Enable network daemons for user convenience.
# Please make all changes to this file, not to /etc/defaults/rc.conf.
# This file now contains just the overrides from /etc/defaults/rc.conf.
sendmail="NONE"
defaultrouter="192.168.1.1"
hostname="localhost"
ifconfig_em0="inet 192.168.1.105  netmask 255.255.255.0"
keymap="us.iso"
sshd_enable="YES"
###################################
nginx_enable="YES"
mysql_enable="YES"
php_fpm_enable="YES"
//按“Esc"退出,提示是否保存时保存并退出
//配置mysql系统文件,此安装默认将mysql安装至:/usr/local/share/mysql下
进入目录,拷贝下面的配置文件至/usr/local/etc
root@localhost:/usr/local # cd share/mysql/
root@localhost:/usr/local/share/mysql # ls
binary-configure                errmsg-utf8.txt                 italian              
          mysql_system_tables.sql         romanian
bulgarian                       estonian                        japanese             
          mysql_system_tables_data.sql    russian
charsets                        fill_help_tables.sql            korean               
          mysql_test_data_timezone.sql    serbian
czech                           french                          magic                
          mysqld_multi.server             slovak
danish                          german                          my-default.cnf       
          norwegian                       spanish
dictionary.txt                  greek                           mysql-log-rotate     
          norwegian-ny                    swedish
dutch                           hungarian                       mysql.server         
          polish                          ukrainian
english                         innodb_memcached_config.sql    
mysql_security_commands.sql     portuguese
root@localhost:/usr/local/share/mysql # cp my-default.cnf /usr/local/etc/my.cnf
root@localhost:/usr/local/share/mysql #
//然后启动mysql
root@localhost:/usr/local # service mysql-server start
Starting mysql.
root@localhost:/usr/local #
//设置root密码,系统装后默认的mysql指令全部在bin下面
# /usr/local/bin/mysqladmin -u root password '123456'
//配置php
root@localhost:/usr/local/etc # ls
bash_completion.d       periodic                php.ini-development
devd                    perl5_version           php.ini-production
man.d                   php                     pkg
my.cnf                  php-fpm.conf            pkg.conf.sample
nginx                   php-fpm.conf.default    rc.d
pam.d                   php.conf
root@localhost:/usr/local/etc # mv php.ini-production php.ini
root@localhost:/usr/local/etc # ls
bash_completion.d       periodic                php.ini
devd                    perl5_version           php.ini-development
man.d                   php                     pkg
my.cnf                  php-fpm.conf            pkg.conf.sample
nginx                   php-fpm.conf.default    rc.d
pam.d                   php.conf
root@localhost:/usr/local/etc #
//其他保持默认,启动php-fpm
root@localhost:/usr/local/etc # service php-fpm start
Starting php_fpm.
root@localhost:/usr/local/etc #
//配置apc,这里也可以直接打开php.ini文件编辑,以下我们直接写入
root@localhost:/usr/local/etc # echo 'apc.enable="1"' >> /usr/local/etc/php.ini
root@localhost:/usr/local/etc # echo 'apc.shm_size="32M"' >> /usr/local/etc/php.ini
//重新启动php
root@localhost:/usr/local/etc # service php-fpm restart
Stopping php_fpm.
Waiting for PIDS: 82460.
Starting php_fpm.
root@localhost:/usr/local/etc #
//下面配置nginx
root@localhost:/usr/local # cd etc/
root@localhost:/usr/local/etc # ls
bash_completion.d       my.cnf                  periodic                php-fpm.conf            php.ini                 pkg.conf.sample
devd                    nginx                   perl5_version           php-fpm.conf.default    php.ini-development     rc.d
man.d                   pam.d                   php                     php.conf                pkg
root@localhost:/usr/local/etc # cd nginx/
root@localhost:/usr/local/etc/nginx # ls
fastcgi_params          koi-win                 nginx.conf              scgi_params-dist        win-utf
fastcgi_params-dist     mime.types              nginx.conf-dist         uwsgi_params
koi-utf                 mime.types-dist         scgi_params             uwsgi_params-dist
root@localhost:/usr/local/etc/nginx # ee nginx.conf
#####################################################
#user  nobody;
user www;
worker_processes  1;
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
#pid        logs/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';
    #access_log  logs/access.log  main;
    sendfile        on;
    #tcp_nopush     on;
    #keepalive_timeout  0;
    keepalive_timeout  65;
file "nginx.conf", 118 lines
................

         server {
        listen       80;
        server_name  localhost;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
        location / {
            root   /usr/local/www/nginx;
            index  index.php index.html index.htm;#这里加入php页面支持
        }
        #error_page  404              /404.html;
        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/local/www/nginx-dist;
        }
        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        
 #将这里的注释#去掉,让nginx解析php脚本
        location ~ \.php$ {
            root           /usr/local/www/nginx;#修改文件目录
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
//启动nginx
root@localhost:/usr/local/etc/nginx # service nginx start
Performing sanity check on nginx configuration:
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
Starting nginx.
root@localhost:/usr/local/etc/nginx #
此时在浏览器输入http://192.168.1.105/应该能看到如下界面
 
//进入web默认目录新建phpinfo.php文件
<?php
phpinfo();
?>
root@localhost:/usr/local/www/nginx # ls
50x.html                                        index.html
EXAMPLE_DIRECTORY-DONT_ADD_OR_TOUCH_ANYTHING    phpinfo.php
root@localhost:/usr/local/www/nginx # ee phpinfo.php
//在浏览器查看http://192.168.1.105/phpinfo.php

转载于:https://www.cnblogs.com/zjxfly/p/4310819.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
张宴《实战Nginx:取代Apache的高性能Web服务器》pdf电子版下载,此资料网友共享,请购买作者正版书籍. 目录介绍: 第1部分 基础篇 第1章 Nginx简介 1.1 常用的Web服务器简介 1.2 Nginx简介 1.3 选择Nginx的理由 1.4 Nginx与Apache、Lighttpd的综合对比 第2章 Nginx服务器的安装与配置 2.1 安装Nginx服务器所需要的系统资源 2.2 Nginx的下载 2.3 Nginx的安装 2.4 Nginx的启动、停止、平滑重启 2.5 Nginx的平滑重启 2.6 Nginx的信号控制 2.7 Nginx的平滑升级 第2部分 进 阶 篇 第3章 Nginx的基本配置与优化 3.1 Nginx的完整配置示例 3.2 Nginx的虚拟主机配置 3.3 Nginx的日志文件配置与切割 3.4 Nginx的压缩输出配置 .3.5 Nginx的自动列目录配置 3.6 Nginx的浏览器本地缓存设置 第4章 NginxPHP(FastCGI)的安装、配置与优化 4.1 获取相关开源程序 4.2 安装PHP 5.2.10(FastCGI模式) 4.3 安装Nginx 0.8.15 4.4 配置开机自动启动Nginx + PHP 4.5 优化Linux内核参数 4.6 在不停止Nginx服务的情况下平滑变更Nginx配置 4.7 编写每天定时切割Nginx日志的脚本 第5章 Nginx与JSP、ASP.NET、Perl的安装与配置 5.1 Nginx与JSP(Tomcat)在Linux上的安装、配置 5.2 Nginx与ASP.NET(Mono+FastCGI)在Linux上的安装、配置 5.3 Nginx与Perl(FastCGI)在Linux上的安装、配置 第6章 Nginx HTTP负载均衡和反向代理的配置与优化 6.1 什么是负载均衡和反向代理 6.2 常见的Web负载均衡方法 6.3 Nginx负载均衡与反向代理的配置实例 6.4 Nginx负载均衡的HTTP Upstream 模块 6.5 Nginx负载均衡服务器的双机高可用 第7章 Nginx的Rewrite规则编写实例 7.1 什么是Nginx的Rewrite规则 7.2 Nginx Rewrite规则相关指令 7.3 PCRE正则表达式语法 7.4 Nginx的Rewrite规则编写实例 7.5 Nginx与Apache的Rewrite规则实例对比 第8章 Nginx模块开发 8.1 Nginx模块概述 8.2 Nginx模块编写实践 第9章 NginxWeb缓存服务与新浪网的开源NCACHE模块 9.1 什么是Web缓存? 9.2 NginxWeb缓存服务 9.3 新浪网开源软件项目——基于Nginx的NCache网页缓存系统 第3部分 实战篇 第10章 Nginx在国内知名网站中的应用案例 10.1 Nginx反向代理与负载均衡类网站应用案例 10.2 Nginx+PHP类网站应用案例 第11章 Nginx的非典型应用实例 11.1 用HTTPS(SSL)构建一个安全的Nginx Web服务器 11.2 采用Nginx搭建FLV视频服务器 11.3 Nginx+PHP+MySQL在小内存VPS服务器上的优化 11.4 采用Nginx搭建正向代理服务器 第4部分 模块篇 第12章 Nginx的核心模块 12.1 主模块指令 12.2 主模块变量 12.3 事件模块指令 第13章 Nginx的标准HTTP模块 13.1 HTTP的核心模块 13.2 HTTP Upstream模块 13.3 Http Access 模块 13.4 HTTP Auth Basic 模块 13.5 Http Autoindex 模块 13.6 Http Browser 模块 13.7 Http Charset 模块 13.8 Http Empty Gif模块 13.9 Http Fcgi 模块 13.10 geo 模块 13.11 Gzip 模块 13.12 Http Headers模块 13.13 Http Index模块 13.14 HTTP Referer模块 13.15 Http Limit Zone模块 13.16 Http Limit Req模块 13.17 Http Log模块 13.18 Http Map模块 13.19 Http Memcached模块 13.20 Http Proxy模块 第14章 Nginx的其他HTTP模块 14.1 Http Addition模块 14.2 Embedded Perl模块 14.3 Flv Stream模块 14.3 flv 指令 14.4 Http Gzip Sta
TrueNAS是一个基于FreeBSD的存储操作系统,它内置了一些基本的网络服务,比如FTP,SMB,NFS,但是它并没有内置nginxphpmysql。 如果你想在TrueNAS上搭建一个nginx+php+mysql服务器,你需要进行以下步骤: 1. 安装pkg包管理器 在TrueNAS的Shell界面中,输入以下命令: ``` pkg ``` 如果提示你需要安装pkg,输入以下命令进行安装: ``` pkg install pkg ``` 2. 安装nginx 在Shell界面中,输入以下命令进行nginx的安装: ``` pkg install nginx ``` 安装完成后,你可以通过以下命令启动nginx服务: ``` service nginx start ``` 3. 安装php 在Shell界面中,输入以下命令进行php的安装: ``` pkg install php74 ``` 安装完成后,你需要在nginx配置文件中添加php的支持。找到nginx配置文件,一般是在/usr/local/etc/nginx/nginx.conf,添加以下内容: ``` location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/local/www$fastcgi_script_name; include fastcgi_params; } ``` 4. 安装mysql 在Shell界面中,输入以下命令进行mysql的安装: ``` pkg install mysql80-server ``` 安装完成后,你可以通过以下命令启动mysql服务: ``` service mysql-server start ``` 5. 配置nginxmysql 在TrueNAS的Web界面中,进入Jails -> Configuration,创建一个新的Jail,并勾选“Auto start”选项。 进入Jail的Shell界面,编辑以下文件: - /usr/local/etc/nginx/nginx.conf - /usr/local/etc/php.ini - /usr/local/etc/mysql/my.cnf 根据你的需求进行配置,然后重启服务即可。 希望这些步骤能够帮助你在TrueNAS上搭建一个nginx+php+mysql服务器

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值