Nginx配置noVNC的web页面教程

先说下noVNC的一键启动

./utils/launch.sh --listen localhost:6002--vnc localhost:6001

listen是监听本地端口,如果开放就不要用localhost而用0.0.0.0就好了 。vnc后面是vnc server的端口。

这个noVNC的启动项目没法直接用Nginx反代,因为涉及到websocket。官方的教程是这样做的

在nginx.conf的http字段中添加
upstream vnc_proxy {
    server 127.0.0.1:6080;
}
在nginx.conf的server字段中添加
location /websockify {
          proxy_http_version 1.1;
          proxy_pass http://vnc_proxy/;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection "upgrade";

          # VNC connection timeout
          proxy_read_timeout 61s;

          # Disable cache
          proxy_buffering off;
    }
location /vnc {
            index vnc.html;
            alias /home/nenew/noVNC/;
            try_files $uri $uri/ /vnc.html;
    }

其实很好理解,就是通过建立nginx和upstream的连接,然后把vnc的传输通过websocket完成。

这里nginx配置就算完成了,我们还需要一个websocket

./utils/websockify/run source_port target_addr:target_port

其中的源端口和目标地址:端口就正常填写即可,这里需要说的是目标端口和一键启动的端口没有关系,就是vnc的服务端口,websockify和launch俩程序没啥关系。

然后直接通过网站http://www.nenew.net/vnc访问即可。

Ubuntu Server安装KVM NAT虚拟机

安装kvm和libvert套装

apt install qemu qemu-kvm libvirt-bin  bridge-utils  virt-manager

下载好安装镜像并查看NAT网络

virsh net-list
查看会有一个default网络
ifconfig
会有一个私网的bridge网桥

开启IPV4转发

vi /etc/sysctl.conf
net.ipv4.ip_forward = 1
sysctl –p

安装KVM虚拟机

virt-install --name kvm --memory 4096 --vcpus=2 --boot hd,cdrom,menu=on --cdrom /home/nenew/ubuntu-18.04.3-desktop-amd64.iso --cdrom /home/nenew/virtio-win.iso --disk path=/home/nenew/kvm.img,format=qcow2,bus=virtio --network network=default --graphics vnc,listen=0.0.0.0,port=6001

这样配置一个可以在6001端口监听的VNC server,用VNC连接server并进行安装。

启动虚拟机

virsh list --all
查看所有虚拟机
virsh start kvm
启动虚拟机(安装完成后虚拟机可能关机)

奶牛现在码字感觉很费力,懒得多写了。

穷病——应该可以治

我卖了这么多年药,发现世界上只有一种病—“穷病”。这种病你治不好,也治不过来。

 

穷病,能治么?我觉得能,只是不是所有人的穷病都能治。

这些日子一直在思考,关于穷病。

今天又重看了《我不是药神》,人生不能缺少思考,如行尸走肉一般,如果说这部电影是讲正版盗版药,我觉得不够透彻,最根本的应该是那个行走江湖多年的假药骗子说的话,关键点是“穷病”。

假如,我是说假如,所有人都买得起正版药,谁去买盗版药。

但是,买不起。

你说是药贵么?对,确实贵。

但根本呢,穷!

工作已有一些年头了,可能大多数人的想法,结婚–买房–供房贷。

但是,如果在这个最佳的翻身时机做一个无法翻身的选择,我觉得不明智。起初,我觉得可能买了房子就真的没有钱去做些什么了。

今年的HK事件也让我有了更多的思考,直到前阵子偶然看到一本关于负债和资产的书,我仿佛看到了新世界的大门朝我敞开了。

房子,到底是资产还是负债?

HK事件,归根结底是房子的问题?是政治的问题?

仅在这个思考的清晨,记录下最近的收获。

自建sit 6in4 Tunnel Broker IPv6隧道

从大概8年前就知道HE(Hurricane Electric)的Free IPv6 Tunnel Broker,但是印象中尝试一直是失败的,当然这次的尝试也是失败的,原因估计是电信运营商封了6in4这种数据包封装,不过还是把过程记录下吧。

先说说sit tunnel,其实和GRE tunnel啊IPIP tunnel是相似的,sit tunnel也是本地和远程对等的一种tunnel,也就是说服务器端和客户端几乎是相反的配置。这里的配置需要iproute2的支持。

客户端:

ip tunnel add user-ipv6 mode sit remote 服务器IPv4地址 local 本地IP(如果是内网则为内网地址) ttl 255
ip link set user-ipv6 up
ip addr add 服务器IPv6地址::2/80 dev user-ipv6
ip route add ::/0 dev user-ipv6

服务器端:

ip tunnel add server-ipv6 mode sit remote 客户公网IPv4地址 local 服务器IPv4地址 ttl 255
ip link set server-ipv6 up
ip addr add 服务器IPv6地址网关::1/80 dev server-ipv6
ip route add 服务器IPv6 Route地址::/80 dev server-ipv6
echo "net.ipv6.conf.all.forwarding = 1" >>/etc/sysctl.conf
sysctl -p

配置完成后需要添加邻居信息服务,防止IPv6地址无法被广播识别。

wget https://github.com/DanielAdolfsson/ndppd/archive/0.2.5.tar.gz
tar zxvf 0.2.5.tar.gz
cd ndppd-0.2.5
make
make install

vi /etc/ndppd.conf

route-ttl 30000
proxy eth0 {
router yes
timeout 500
ttl 30000
rule 你的:IPv6:子网:前缀::/前缀长度 {
static
}
}

ndppd -d

配置完成后客户端应该可以直接使用分配的IPv6地址了。这里需要注意的是/64的IPv6地址需要切分成/80的子网,然后进行广播设置。配置工具可以使用https://github.com/sskaje/6in4

但是使用的时候需要将sipcalc安装上,否则无法正确使用。使用方法:

cd 6in4-master/etc/
vi config.ini

; IPv6 network, must be ending with '::'
; * Required
IPV6_NETWORK=你的:IPv6:子网:前缀::

; IPV6 CIDR, must be a multiple of 8.
; * Required
; If your IPV6_CIDR is smaller than /64, assigned blocks are /64; if smaller than /48, /48 is used.
; If IPV6_CIDR is greater than /64, assigned blocks are /(IPV6_CIDR + 16 [ + 8 ]), e.g.: 64->80, 72->96, 80->96
IPV6_CIDR=前缀长度

; Bind tunnel to device INTERFACE
; * Required
INTERFACE=接口名

; Local IPv4
; * Optional
; This is useful if your $INTERFACE has more than one IP.
; If BIND_IP is not set, script reads first IPv4 ip from $INTERFACE
;BIND_IP=1.1.1.1 若接口上有多于1个IPv4地址 需要绑定

; MTU
; Default: 1480
;LINK_MTU=1480

:wq

cd 6in4-master
./bin/6to4 add 1 233.233.233.233

***************************** WARNING ********************************
IPV6_CIDR greater than 64 may cause your subnet not advertisable.
***************************** WARNING ********************************

Please set up tunnel on your machine with following parameters:
    Server IPv4 Address:        1.1.1.1
    Server IPv6 Address:        2001:0db8:0001:0001:1001::1/80
    Client IPv4 Address:        233.233.233.233
    Client IPv6 Address:        2001:0db8:0001:0001:1001::2/80
    Routed /80:                 2001:0db8:0001:0001:2001::/80

If you don't have a static IP, set your local to 0.0.0.0 and invoke update api to update your endpoint

 

OVH配置Ubuntu18.04 IPv6教程

传统方法(开机需要重新配置):

ip addr add IPv6-Address/64 dev ens3
ip -6 route add IPv6-Gateway dev ens3
ip -6 route add default via IPv6-Gateway dev ens3

Ubuntu 18.04 netplan配置方法:

vim /etc/netplan/ipv6.yaml 
network:
    version: 2
    ethernets:
        ens3:
            dhcp6 : no
            match :
                    name : ens3
            addresses :
                    - "IPv6-Address/64"
            gateway6 : "IPv6-Gateway"
netplan try
netplan apply

更多的配置文件可以参考/usr/share/doc/netplan.io下的配置。

奶牛也踩了个坑,之前系统有紧急bug,OVH给做了紧急的内核升级,所以这次要apt update && apt upgrade升级下内核之后才可以,避免出现路由错误问题。

IPv6运行中——这是一篇使用IPv6网络发布的博客文章

测试IPv6的地址:

https://www.test-ipv6.com/

提供一些IPv6的DNS服务器:

#China Public IPv6 DNS
ping 240C::6666  

#CNNIC IPv6 DNS
ping 2001:dc7:1000::1  

#BaiDu Public IPv6 DNS
ping 2400:da00::6666  

#Google Public IPv6 DNS
ping 2001:4860:4860::8888  

#Cloudflare IPv6 DNS
ping 2606:4700:4700::1111

这里首选的是one.dot.one.dot.one.dot.one家的,也就是Cloudflare的1.1.1.1,很给力,而且好消息是接入Cloudflare的CDN后IPv6是直接访问,速度也很给力,比普通线路在拥堵时可能有一些优势。但是现阶段G家上传貌似不是很给力,非常不稳定,测试结果是从0~12Mbps吧,我的上传带宽应该有40Mbps左右的样子,但是还是很不稳定,不过可以将就着用了,已经很好了。

Ubuntu18.04编译安装MySQL 5.7.26

下载带有boost版本的MySQL 5.7.26

wget https://downloads.mysql.com/archives/get/file/mysql-boost-5.7.26.tar.gz

安装依赖

apt install cmake
apt install libncurses5 libncurses5-dev 
apt install bision

解压

tar xzf mysql-boost-5.7.26.tar.gz 
cd mysql-5.7.26/

编译安装

说明一下,其实这个boost并不需要单独安装,只需要把包内的boost路径加载到configure就可以了。

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8mb4 -DDEFAULT_COLLATION=utf8mb4_general_ci -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DWITH_BOOST=./boost
make
make install

完成后的工作

 

useradd -M -s /sbin/nologin mysql
groupadd mysql
chown mysql:mysql /usr/local/mysql/var/
chgrp -R mysql /usr/local/mysql/
mkdir -p /usr/local/mysql/var
cp support-files/mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql 
cat > /etc/ld.so.conf.d/mysql.conf<<EOF
    /usr/local/mysql/lib
    /usr/local/lib
EOF
ldconfig
/usr/local/mysql/bin/mysqld --initialize-insecure --basedir=/usr/local/mysql --datadir=/usr/local/mysql/var/ --user=mysql --explicit_defaults_for_timestamp=true
初始化数据库
vim /etc/my.cnf
配置数据库
service mysql start
/usr/local/mysql/bin/mysqladmin -u root password password
设置管理员密码

附上LNMP的my.cnf

[client]
#password	= your_password
port		= 3306
socket		= /tmp/mysql.sock

[mysqld]
port		= 3306
socket		= /tmp/mysql.sock
datadir = /usr/local/mysql/var
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
thread_cache_size = 8
query_cache_size = 8M
tmp_table_size = 16M

#skip-networking
max_connections = 500
max_connect_errors = 100
open_files_limit = 65535

log-bin=mysql-bin
binlog_format=mixed
server-id	= 1
expire_logs_days = 10

default_storage_engine = InnoDB
innodb_file_per_table = 1
innodb_data_home_dir = /usr/local/mysql/var
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /usr/local/mysql/var
innodb_buffer_pool_size = 16M
#innodb_additional_mem_pool_size = 2M
innodb_log_file_size = 5M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash

[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout
Ubuntu18.04编译安装PHP7.3.8

奶牛在踩坑过程中,请不要阻止。身为一个站长,一路以来一直使用LNMP来安装LNMP环境,深感羞耻,打算把该踩的坑都踩一踩,也学习一下该学习的东西。

今天是把OpenResty+PHP+Mysql的坑都踩了一遍,学到了不少东西,与君共勉。

需求环境安装

build-essential libcurl14 libcurl4-gnutls-dev openssl curl libbz2-dev libxml2-dev libjpeg-dev libpng-dev libfreetype6-dev libzip-dev libxslt1-dev

下载PHP7.3.8

wget https://www.php.net/distributions/php-7.3.8.tar.gz

解压

tar xzvf php-7.3.8.tar.gz

进入目录

cd php-7.3.8

编译安装

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-config-file-scan-dir=/usr/local/php/conf.d --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-intl --enable-ftp --with-gd --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext  --enable-opcache --with-xsl
make
make test
make install
mkdir -p /usr/local/php/{etc,conf.d}
cp php.ini-production /usr/local/php/etc/php.ini
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
update-rc.d php-fpm default

防止Failed to start php.service: Unit php-fpm.service not found.类错误发生。

配置文件php.ini

贴上现有的配置,改自LNMP。

engine = On
short_open_tag = On
precision = 14
output_buffering = 4096
zlib.output_compression = Off
implicit_flush = Off
unserialize_callback_func =
serialize_precision = -1
disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server
disable_classes =
zend.enable_gc = On
expose_php = On
max_execution_time = 300
max_input_time = 60
memory_limit = 128M
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
display_errors = Off
display_startup_errors = Off
log_errors = On
log_errors_max_len = 1024
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
html_errors = On
variables_order = "GPCS"
request_order = "GP"
register_argc_argv = Off
auto_globals_jit = On
post_max_size = 50M
auto_prepend_file =
auto_append_file =
default_mimetype = "text/html"
default_charset = "UTF-8"
doc_root =
user_dir =
enable_dl = Off
cgi.fix_pathinfo=0
file_uploads = On
upload_max_filesize = 50M
max_file_uploads = 20
allow_url_fopen = On
allow_url_include = Off
default_socket_timeout = 60
extension=fileinfo
[CLI Server]
cli_server.color = On

[Date]
date.timezone = PRC
[filter]
[iconv]
[intl]
[sqlite3]
[Pcre]
[Pdo]
[Pdo_mysql]
pdo_mysql.cache_size = 2000
pdo_mysql.default_socket=
[Phar]
[mail function]
SMTP = localhost
smtp_port = 25
mail.add_x_header = Off
[ODBC]
odbc.allow_persistent = On
odbc.check_persistent = On
odbc.max_persistent = -1
odbc.max_links = -1
odbc.defaultlrl = 4096
odbc.defaultbinmode = 1
[Interbase]
ibase.allow_persistent = 1
ibase.max_persistent = -1
ibase.max_links = -1
ibase.timestampformat = "%Y-%m-%d %H:%M:%S"
ibase.dateformat = "%Y-%m-%d"
ibase.timeformat = "%H:%M:%S"
[MySQLi]
mysqli.max_persistent = -1
mysqli.allow_persistent = On
mysqli.max_links = -1
mysqli.cache_size = 2000
mysqli.default_port = 3306
mysqli.default_socket =
mysqli.default_host =
mysqli.default_user =
mysqli.default_pw =
mysqli.reconnect = Off
[mysqlnd]
mysqlnd.collect_statistics = On
mysqlnd.collect_memory_statistics = Off
[OCI8]
[PostgreSQL]
pgsql.allow_persistent = On
pgsql.auto_reset_persistent = Off
pgsql.max_persistent = -1
pgsql.max_links = -1
pgsql.ignore_notice = 0
pgsql.log_notice = 0
[bcmath]
bcmath.scale = 0
[browscap]
[Session]
session.save_handler = files
session.use_strict_mode = 0
session.use_cookies = 1
session.use_only_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly =
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor = 1000
session.gc_maxlifetime = 1440
session.referer_check =
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.sid_length = 26
session.trans_sid_tags = "a=href,area=href,frame=src,form="
session.sid_bits_per_character = 5
[Assertion]
zend.assertions = -1
[COM]
[mbstring]
[gd]
[exif]
[Tidy]
tidy.clean_output = Off
[soap]
soap.wsdl_cache_enabled=1
soap.wsdl_cache_dir="/tmp"
soap.wsdl_cache_ttl=86400
soap.wsdl_cache_limit = 5
[sysvshm]
[ldap]
ldap.max_links = -1
[dba]
[opcache]
[zend opcache]
zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20180731/opcache.so"
opcache.force_restart_timeout=3600
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
opcache.enable=1
opcache.enable_cli=1
[curl]
[openssl]

关于fileinfo

这个默认是安装的,但是有说内存小于1G是不推荐安装的,编译会出错,但是fileinfo很有用,有些程序需要使用fileinfo,未安装会导致500错误。可以在configiure的时候使用–disable-fileinfo参数来禁止安装,但是没有–enable-fileinfo参数哦。

关于fileinfo手动安装

cd ./ext/fileinfo/
apt install autoconf
/usr/local/php/bin/phpize
./configure –with-php-config=/usr/local/php/bin/php-config
make
make install

最后修改php.ini添加extension=fileinfo即可。

PHP configure参数详细列表

如下,以便速查

~/php/php-7.3.8# ./configure --help
`configure' configures this package to adapt to many kinds of systems.

Usage: ./configure [OPTION]... [VAR=VALUE]...

To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE.  See below for descriptions of some of the useful variables.

Defaults for the options are specified in brackets.

Configuration:
  -h, --help              display this help and exit
      --help=short        display options specific to this package
      --help=recursive    display the short help of all the included packages
  -V, --version           display version information and exit
  -q, --quiet, --silent   do not print `checking ...' messages
      --cache-file=FILE   cache test results in FILE [disabled]
  -C, --config-cache      alias for `--cache-file=config.cache'
  -n, --no-create         do not create output files
      --srcdir=DIR        find the sources in DIR [configure dir or `..']

Installation directories:
  --prefix=PREFIX         install architecture-independent files in PREFIX
                          [/usr/local]
  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
                          [PREFIX]

By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc.  You can specify
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'.

For better control, use the options below.

Fine tuning of the installation directories:
  --bindir=DIR            user executables [EPREFIX/bin]
  --sbindir=DIR           system admin executables [EPREFIX/sbin]
  --libexecdir=DIR        program executables [EPREFIX/libexec]
  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
  --libdir=DIR            object code libraries [EPREFIX/lib]
  --includedir=DIR        C header files [PREFIX/include]
  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
  --infodir=DIR           info documentation [DATAROOTDIR/info]
  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
  --mandir=DIR            man documentation [DATAROOTDIR/man]
  --docdir=DIR            documentation root [DATAROOTDIR/doc/PACKAGE]
  --htmldir=DIR           html documentation [DOCDIR]
  --dvidir=DIR            dvi documentation [DOCDIR]
  --pdfdir=DIR            pdf documentation [DOCDIR]
  --psdir=DIR             ps documentation [DOCDIR]

System types:
  --build=BUILD     configure for building on BUILD [guessed]
  --host=HOST       cross-compile to build programs to run on HOST [BUILD]
  --target=TARGET   configure for building compilers for TARGET [HOST]

Optional Features and Packages:
  --disable-option-checking  ignore unrecognized --enable/--with options
  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
  --with-libdir=NAME      Look for libraries in .../NAME rather than .../lib
  --disable-rpath         Disable passing additional runtime library
                          search paths
  --enable-re2c-cgoto     Enable -g flag to re2c to use computed goto gcc extension
  --disable-gcc-global-regs
                          whether to enable GCC global register variables

SAPI modules:

  --with-apxs2=FILE       Build shared Apache 2.0 Handler module. FILE is the optional
                          pathname to the Apache apxs tool apxs
  --disable-cli           Disable building CLI version of PHP
                          (this forces --without-pear)
  --enable-embed=TYPE     EXPERIMENTAL: Enable building of embedded SAPI library
                          TYPE is either 'shared' or 'static'. TYPE=shared
  --enable-fpm            Enable building of the fpm SAPI executable
  --with-fpm-user=USER    Set the user for php-fpm to run as. (default: nobody)
  --with-fpm-group=GRP    Set the group for php-fpm to run as. For a system user, this
                          should usually be set to match the fpm username (default: nobody)
  --with-fpm-systemd      Activate systemd integration
  --with-fpm-acl          Use POSIX Access Control Lists
  --with-litespeed        Build PHP as litespeed module
  --enable-phpdbg         Build phpdbg
  --enable-phpdbg-webhelper
                          Build phpdbg web SAPI support
  --enable-phpdbg-debug   Build phpdbg in debug mode
  --enable-phpdbg-readline   Enable readline support in phpdbg (depends on static ext/readline)
  --disable-cgi           Disable building CGI version of PHP
  --with-valgrind=DIR     Enable valgrind support

General settings:

  --enable-gcov           Enable GCOV code coverage (requires LTP) - FOR DEVELOPERS ONLY!!
  --enable-debug          Compile with debugging symbols
  --with-layout=TYPE      Set how installed files will be laid out.  Type can
                          be either PHP or GNU [PHP]
  --with-config-file-path=PATH
                          Set the path in which to look for php.ini [PREFIX/lib]
  --with-config-file-scan-dir=PATH
                          Set the path where to scan for configuration files
  --enable-sigchild       Enable PHP's own SIGCHLD handler
  --enable-libgcc         Enable explicitly linking against libgcc
  --disable-short-tags    Disable the short-form <? start tag by default
  --enable-dmalloc        Enable dmalloc
  --disable-ipv6          Disable IPv6 support
  --enable-dtrace         Enable DTrace support
  --enable-fd-setsize     Set size of descriptor sets

Extensions:

  --with-EXTENSION=shared[,PATH]

    NOTE: Not all extensions can be build as 'shared'.

    Example: --with-foobar=shared,/usr/local/foobar/

      o Builds the foobar extension as shared extension.
      o foobar package install prefix is /usr/local/foobar/


  --disable-all           Disable all extensions which are enabled by default

  --disable-libxml        Disable LIBXML support
  --with-libxml-dir=DIR   LIBXML: libxml2 install prefix
  --with-openssl=DIR      Include OpenSSL support (requires OpenSSL >= 1.0.1)
  --with-kerberos=DIR     OPENSSL: Include Kerberos support
  --with-system-ciphers   OPENSSL: Use system default cipher list instead of hardcoded value
  --with-pcre-regex=DIR   Include Perl Compatible Regular Expressions support.
                          DIR is the PCRE install prefix BUNDLED
  --with-pcre-jit         Enable PCRE JIT functionality (BUNDLED only)
  --with-pcre-valgrind=DIR
                          Enable PCRE valgrind support. Developers only!
  --without-sqlite3=DIR   Do not include SQLite3 support. DIR is the prefix to
                          SQLite3 installation directory.
  --with-zlib=DIR         Include ZLIB support (requires zlib >= 1.2.0.4)
  --with-zlib-dir=<DIR>   Define the location of zlib install directory
  --enable-bcmath         Enable bc style precision math functions
  --with-bz2=DIR          Include BZip2 support
  --enable-calendar       Enable support for calendar conversion
  --disable-ctype         Disable ctype functions
  --with-curl=DIR         Include cURL support
  --enable-dba            Build DBA with bundled modules. To build shared DBA
                          extension use --enable-dba=shared
  --with-qdbm=DIR         DBA: QDBM support
  --with-gdbm=DIR         DBA: GDBM support
  --with-ndbm=DIR         DBA: NDBM support
  --with-db4=DIR          DBA: Oracle Berkeley DB 4.x or 5.x support
  --with-db3=DIR          DBA: Oracle Berkeley DB 3.x support
  --with-db2=DIR          DBA: Oracle Berkeley DB 2.x support
  --with-db1=DIR          DBA: Oracle Berkeley DB 1.x support/emulation
  --with-dbm=DIR          DBA: DBM support
  --with-tcadb=DIR        DBA: Tokyo Cabinet abstract DB support
  --with-lmdb=DIR         DBA: Lightning memory-mapped database support
  --without-cdb=DIR       DBA: CDB support (bundled)
  --disable-inifile       DBA: INI support (bundled)
  --disable-flatfile      DBA: FlatFile support (bundled)
  --disable-dom           Disable DOM support
  --with-libxml-dir=DIR   DOM: libxml2 install prefix
  --with-enchant=DIR      Include enchant support.
                          GNU Aspell version 1.1.3 or higher required.
  --enable-exif           Enable EXIF (metadata from images) support
  --disable-fileinfo      Disable fileinfo support
  --disable-filter        Disable input filter support
  --with-pcre-dir         FILTER: pcre install prefix
  --enable-ftp            Enable FTP support
  --with-openssl-dir=DIR  FTP: openssl install prefix
  --with-gd=DIR           Include GD support.  DIR is the GD library base
                          install directory BUNDLED
  --with-webp-dir=DIR     GD: Set the path to libwebp install prefix
  --with-jpeg-dir=DIR     GD: Set the path to libjpeg install prefix
  --with-png-dir=DIR      GD: Set the path to libpng install prefix
  --with-zlib-dir=DIR     GD: Set the path to libz install prefix
  --with-xpm-dir=DIR      GD: Set the path to libXpm install prefix
  --with-freetype-dir=DIR GD: Set the path to FreeType 2 install prefix
  --enable-gd-jis-conv    GD: Enable JIS-mapped Japanese font support
  --with-gettext=DIR      Include GNU gettext support
  --with-gmp=DIR          Include GNU MP support
  --with-mhash=DIR        Include mhash support
  --disable-hash          Disable hash support
  --without-iconv=DIR     Exclude iconv support
  --with-imap=DIR         Include IMAP support. DIR is the c-client install prefix
  --with-kerberos=DIR     IMAP: Include Kerberos support. DIR is the Kerberos install prefix
  --with-imap-ssl=DIR     IMAP: Include SSL support. DIR is the OpenSSL install prefix
  --with-interbase=DIR    Include Firebird support.  DIR is the Firebird base
                          install directory /opt/firebird
  --enable-intl           Enable internationalization support
  --with-icu-dir=DIR      Specify where ICU libraries and headers can be found
  --disable-json          Disable JavaScript Object Serialization support
  --with-ldap=DIR         Include LDAP support
  --with-ldap-sasl=DIR    LDAP: Include Cyrus SASL support
  --enable-mbstring       Enable multibyte string support
  --disable-mbregex       MBSTRING: Disable multibyte regex support
  --disable-mbregex-backtrack
                          MBSTRING: Disable multibyte regex backtrack check
  --with-onig=DIR         MBSTRING: Use external oniguruma. DIR is the oniguruma install prefix.
                          If DIR is not set, the bundled oniguruma will be used
  --with-mysqli=FILE      Include MySQLi support.  FILE is the path
                          to mysql_config.  If no value or mysqlnd is passed
                          as FILE, the MySQL native driver will be used
  --enable-embedded-mysqli
                          MYSQLi: Enable embedded support
                          Note: Does not work with MySQL native driver!
  --with-mysql-sock=SOCKPATH
                          MySQLi/PDO_MYSQL: Location of the MySQL unix socket pointer.
                          If unspecified, the default locations are searched
  --with-oci8=DIR         Include Oracle Database OCI8 support. DIR defaults to $ORACLE_HOME.
                          Use --with-oci8=instantclient,/path/to/instant/client/lib
                          to use an Oracle Instant Client installation
  --with-odbcver=HEX      Force support for the passed ODBC version. A hex number is expected, default 0x0350.
                          Use the special value of 0 to prevent an explicit ODBCVER to be defined.
  --with-adabas=DIR       Include Adabas D support /usr/local
  --with-sapdb=DIR        Include SAP DB support /usr/local
  --with-solid=DIR        Include Solid support /usr/local/solid
  --with-ibm-db2=DIR      Include IBM DB2 support /home/db2inst1/sqllib
  --with-empress=DIR      Include Empress support \$EMPRESSPATH
                          (Empress Version >= 8.60 required)
  --with-empress-bcs=DIR  Include Empress Local Access support \$EMPRESSPATH
                          (Empress Version >= 8.60 required)
  --with-custom-odbc=DIR  Include user defined ODBC support. DIR is ODBC install base
                          directory /usr/local. Make sure to define CUSTOM_ODBC_LIBS and
                          have some odbc.h in your include dirs. f.e. you should define
                          following for Sybase SQL Anywhere 5.5.00 on QNX, prior to
                          running this configure script:
                            CPPFLAGS=\"-DODBC_QNX -DSQLANY_BUG\"
                            LDFLAGS=-lunix
                            CUSTOM_ODBC_LIBS=\"-ldblib -lodbc\"
  --with-iodbc=DIR        Include iODBC support /usr/local
  --with-esoob=DIR        Include Easysoft OOB support /usr/local/easysoft/oob/client
  --with-unixODBC=DIR     Include unixODBC support /usr/local
  --with-dbmaker=DIR      Include DBMaker support
  --disable-opcache       Disable Zend OPcache support
  --disable-opcache-file  Disable file based caching
  --disable-huge-code-pages
                          Disable copying PHP CODE pages into HUGE PAGES
  --enable-pcntl          Enable pcntl support (CLI/CGI only)
  --disable-pdo           Disable PHP Data Objects support
  --with-pdo-dblib=DIR    PDO: DBLIB-DB support.  DIR is the FreeTDS home directory
  --with-pdo-firebird=DIR PDO: Firebird support.  DIR is the Firebird base
                          install directory /opt/firebird
  --with-pdo-mysql=DIR    PDO: MySQL support. DIR is the MySQL base directory
                          If no value or mysqlnd is passed as DIR, the
                          MySQL native driver will be used
  --with-zlib-dir=DIR     PDO_MySQL: Set the path to libz install prefix
  --with-pdo-oci=DIR      PDO: Oracle OCI support. DIR defaults to $ORACLE_HOME.
                          Use --with-pdo-oci=instantclient,/path/to/instant/client/lib
                          for an Oracle Instant Client installation.
  --with-pdo-odbc=flavour,dir
                          PDO: Support for 'flavour' ODBC driver.
			  include and lib dirs are looked for under 'dir'.

			  'flavour' can be one of:  ibm-db2, iODBC, unixODBC, generic
			  If ',dir' part is omitted, default for the flavour
			  you have selected will be used. e.g.:

			    --with-pdo-odbc=unixODBC

			  will check for unixODBC under /usr/local. You may attempt
			  to use an otherwise unsupported driver using the 'generic'
			  flavour.  The syntax for generic ODBC support is:

			    --with-pdo-odbc=generic,dir,libname,ldflags,cflags

			  When built as 'shared' the extension filename is always pdo_odbc.so
  --with-pdo-pgsql=DIR    PDO: PostgreSQL support.  DIR is the PostgreSQL base
                          install directory or the path to pg_config
  --without-pdo-sqlite=DIR
                          PDO: sqlite 3 support.  DIR is the sqlite base
                          install directory BUNDLED
  --with-pgsql=DIR        Include PostgreSQL support.  DIR is the PostgreSQL
                          base install directory or the path to pg_config
  --disable-phar          Disable phar support
  --disable-posix         Disable POSIX-like functions
  --with-pspell=DIR       Include PSPELL support.
                          GNU Aspell version 0.50.0 or higher required
  --with-libedit=DIR      Include libedit readline replacement (CLI/CGI only)
  --with-readline=DIR     Include readline support (CLI/CGI only)
  --with-recode=DIR       Include recode support
  --disable-session       Disable session support
  --with-mm=DIR           SESSION: Include mm support for session storage
  --enable-shmop          Enable shmop support
  --disable-simplexml     Disable SimpleXML support
  --with-libxml-dir=DIR   SimpleXML: libxml2 install prefix
  --with-snmp=DIR         Include SNMP support
  --with-openssl-dir=DIR  SNMP: openssl install prefix
  --enable-soap           Enable SOAP support
  --with-libxml-dir=DIR   SOAP: libxml2 install prefix
  --enable-sockets        Enable sockets support
  --with-sodium=DIR       Include sodium support
  --with-password-argon2=DIR
                          Include Argon2 support in password_*. DIR is the Argon2 shared library path
  --enable-sysvmsg        Enable sysvmsg support
  --enable-sysvsem        Enable System V semaphore support
  --enable-sysvshm        Enable the System V shared memory support
  --with-tidy=DIR         Include TIDY support
  --disable-tokenizer     Disable tokenizer support
  --enable-wddx           Enable WDDX support
  --with-libxml-dir=DIR   WDDX: libxml2 install prefix
  --with-libexpat-dir=DIR WDDX: libexpat dir for XMLRPC-EPI (deprecated)
  --disable-xml           Disable XML support
  --with-libxml-dir=DIR   XML: libxml2 install prefix
  --with-libexpat-dir=DIR XML: libexpat install prefix (deprecated)
  --disable-xmlreader     Disable XMLReader support
  --with-libxml-dir=DIR   XMLReader: libxml2 install prefix
  --with-xmlrpc=DIR       Include XMLRPC-EPI support
  --with-libxml-dir=DIR   XMLRPC-EPI: libxml2 install prefix
  --with-libexpat-dir=DIR XMLRPC-EPI: libexpat dir for XMLRPC-EPI (deprecated)
  --with-iconv-dir=DIR    XMLRPC-EPI: iconv dir for XMLRPC-EPI
  --disable-xmlwriter     Disable XMLWriter support
  --with-libxml-dir=DIR   XMLWriter: libxml2 install prefix
  --with-xsl=DIR          Include XSL support.  DIR is the libxslt base
                          install directory (libxslt >= 1.1.0 required)
  --enable-zend-test      Enable zend-test extension
  --enable-zip            Include Zip read/write support
  --with-zlib-dir=DIR     ZIP: Set the path to libz install prefix
  --with-pcre-dir         ZIP: pcre install prefix
  --with-libzip=DIR       ZIP: use libzip
  --enable-mysqlnd        Enable mysqlnd explicitly, will be done implicitly
                          when required by other extensions
  --disable-mysqlnd-compression-support
                          Disable support for the MySQL compressed protocol in mysqlnd
  --with-zlib-dir=DIR     mysqlnd: Set the path to libz install prefix

PEAR:

  --with-pear=DIR         Install PEAR in DIR [PREFIX/lib/php]
  --without-pear          Do not install PEAR

Zend:

  --enable-maintainer-zts Enable thread safety - for code maintainers only!!
  --disable-inline-optimization
                          If building zend_execute.lo fails, try this switch
  --disable-zend-signals  whether to enable zend signal handling

TSRM:

  --with-tsrm-pth=pth-config
                          Use GNU Pth
  --with-tsrm-st          Use SGI's State Threads
  --with-tsrm-pthreads    Use POSIX threads (default)

Libtool:

  --enable-shared=PKGS    Build shared libraries default=yes
  --enable-static=PKGS    Build static libraries default=yes
  --enable-fast-install=PKGS
                          Optimize for fast installation default=yes
  --with-gnu-ld           Assume the C compiler uses GNU ld default=no
  --disable-libtool-lock  Avoid locking (might break parallel builds)
  --with-pic              Try to use only PIC/non-PIC objects default=use both
  --with-tags=TAGS        Include additional configurations automatic


Some influential environment variables:
  CC          C compiler command
  CFLAGS      C compiler flags
  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
              nonstandard directory <lib dir>
  LIBS        libraries to pass to the linker, e.g. -l<library>
  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
              you have headers in a nonstandard directory <include dir>
  CPP         C preprocessor
  YACC        The `Yet Another Compiler Compiler' implementation to use.
              Defaults to the first program found out of: `bison -y', `byacc',
              `yacc'.
  YFLAGS      The list of arguments that will be passed by default to $YACC.
              This script will default YFLAGS to the empty string to avoid a
              default value of `-d' given by some make applications.
  CXX         C++ compiler command
  CXXFLAGS    C++ compiler flags
  CXXCPP      C++ preprocessor

Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.

Report bugs to the package provider.

 

 

Ubuntu安装配置OpenResty教程及补充方案

Ubuntu安装OpenResty教程

# import our GPG key:
wget -qO - https://openresty.org/package/pubkey.gpg | sudo apt-key add -
# for installing the add-apt-repository command
# (you can remove this package and its dependencies later):
sudo apt-get -y install software-properties-common
# add the our official APT repository:
sudo add-apt-repository -y "deb http://openresty.org/package/debian $(lsb_release -sc) openresty"
# to update the APT index:
sudo apt-get update
sudo apt-get install openresty

执行完上面一串就安装完最新版的OpenResty了。

Ubuntu配置OpenResty教程

奶牛先说下配置文件的位置:

OpenResty启动文件:/etc/rc0.d/K01openresty
OpenResty启动文件:/etc/init.d/openresty  (ldconf openresty default会生成不同runlevel的conf,Ubuntu的默认runlevel是5)
OpenResty的Nginx配置文件:/usr/local/openresty/nginx/conf/nginx.conf
OpenResty的默认目录:/usr/local/openresty/nginx/html/

然后剩下的就可以自己安装Nginx进行配置了。

OpenResty安装补充方案 设置www用户和组

groupadd www 
useradd -g www -s /sbin/nologin www

设置/usr/local/openresty/nginx/conf/nginx.conf,添加

user  www www;
worker_processes  auto;
以OVH为例聊聊怎么选网络性能更好的机房

奶牛有时候也很纠结到底选哪个机房哪个线路的服务器,到底怎么选总得有个头绪,奶牛今天就来聊聊到底怎么选。

Looking Glass

以OVH为例,OVH提供了一个插件形式的Looking Glass,地址是http://ovh.net。

通过上传、下载、延时三个方面,已经可以给我们一个很直观的网速如何的概念了。一个Looking Glass就够了么?不不不,奶牛觉得还是很不够的。

Ping

Ping值的大小由距离远近决定,同样的距离,Ping越低越好么?奶牛觉得不尽然,Ping只能反应延迟的一个结果,并不能代表什么,想像一下300ms才0.3s,不会有很大影响的,当然游戏除外,对于建站来说,Ping的大小真的没有那么重要。那么重要的是什么呢?要奶牛说,最重要的是Ping的一个loss指标,丢包率,这个才是重要的,如果丢包率很高,表示网络很不稳定,从一方面可以说明,数据包传输过程中可能会有很多重传,所以,理论上应该并不好。但是也有这种情况,人家本来就是禁Ping的,loss是100%,这种时候可以使用TCP Ping来试试,不过这个就跟丢包率没啥关系了。

Traceroute

路由追踪,这个很关键,同样的机房,可能联通、电信、移动三网走三条线路,所以,如果想选一个三网通用的机房,当然还是都要traceroute一下,不要有的线路完全无法访问导致客户丢失。

下载速度

这个也是要测试三网的,那样会比较准确,如果找不到test file这种可以下载的文件,完全可以用ab这类的压测工具来测试,找个机房的网站然后随便找个测试文件。

ab -n 1000 -c 10 -k http://xxx.xxx.com/css/bootstrap.min.css

我们完全可以开10个线程同时跑一个小文件,只要文件在这个机房的服务器上,这样子可以很容易得到一个下载速度的结果。

Transfer rate:          3440.29 [Kbytes/sec] received

像奶牛这个测试,就是3.4MB/s,理论上还是很不错的。

多时测试

不要只在一个时间测试,至少要在一天的不同时段进行测试,特别是晚7:30~12:00,这个时段是我们网络使用率最高的时段,所以这个时段的结果更具有说明性。

OVH机房的测试IP

参考:http://smokeping.ovh.net

[欧洲]

法国RBX:rbx.smokeping.ovh.net

法国SBG:sbg.smokeping.ovh.net

法国GRA:gra.smokeping.ovh.net

波兰OZA:oza.smokeping.ovh.net

英国ERI:eri.smokeping.ovh.net

德国LIM:lim.smokeping.ovh.net

[美洲]

加拿大BHS:bhs.smokeping.ovh.net

美国VIN:vin.smokeping.ovh.net

美国HIL:hil.smokeping.ovh.net

[亚太]

新加坡SGP:sgp.smokeping.ovh.net

悉尼SYD:syd.smokeping.ovh.net