IMOOWI http://simple.imoowi.com/ zh-CN Stay Hungry Stay Foolish Tue, 22 May 2018 18:16:00 +0800 Tue, 22 May 2018 18:16:00 +0800 FreeSSL证书申请以及配置过程 http://simple.imoowi.com/160.html http://simple.imoowi.com/160.html Tue, 22 May 2018 18:16:00 +0800 simpleyuan 1、申请证书,访问https://freessl.cn/,在输入框中输入你要申请的证书域名“wot.imoowi.com”,点击“创建免费的SSL证书”,

如图:
1.png
2、点击“点击创建”按钮,如图:
2.png
3、等待几分钟,会生成TXT验证文件,当然也可以选择文件验证类型,这里以DNS验证类型为例,会生成以下内容,如图:
3.png
4、进入域名管理后台,添加TXT记录,如图:
4.png
5、等待1分钟左右,回到FreeSSL网站页面,进入控制台-订单列表,如图:5.png
6、点击“验证”按钮,如果一直不成功,请耐心等待几分钟,不要频繁点击“验证”按钮,最好间隔10分钟点击,如果验证成功,会自动下载证书,或者点击右边的“证书”按钮进行下载,如图:
6.png

7、配置nginx,请先把下载的证书上传到服务器;配置nginx,如图:
7.png
8、重启nginx
9、验证:https://wot.imoowi.com/app/meeting

]]>
0 http://simple.imoowi.com/160.html#comments http://simple.imoowi.com/feed/160.html
IOS开发IPV6测试环境搭建 http://simple.imoowi.com/136.html http://simple.imoowi.com/136.html Fri, 17 Feb 2017 12:03:00 +0800 simpleyuan 由于苹果公司规定从2016.6.1起,所有提交AppStore的应用,都必须通过IPV6访问网络。下面就如何搭建这样的环境做详细说明,以http://simple.imoowi.com/为例:

一、App代码增加IPV6支持,在Podfile中更新AFNetworking到3.0
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
target 'ipv6_test' do
pod 'AFNetworking', '~> 3.0'
pod 'IQKeyboardManager'
pod 'UMengAnalytics'
pod 'Appirater'
end

二、修改DNS服务器
1、由于Dnspod现在支持IPV6,所以我们选择了它,在Dnspod(https://www.dnspod.cn)中增加域名,如图:
dnspod.png
dnspod2.png
2、在域名服务商的域名管理界面,把DNS地址改为下图:
west.png
等待0-72个小时内会生效,具体什么时候生效,就看人品了。
三、建立Mac本地IPV6-WIFI热点
参考地址:https://developer.apple.com/library/content/documentation/NetworkingInternetWeb/Conceptual/NetworkingOverview/UnderstandingandPreparingfortheIPv6Transition/UnderstandingandPreparingfortheIPv6Transition.html#//apple_ref/doc/uid/TP40010220-CH213-SW1
1、打开“系统偏好设置”,按住“option”键,点击“共享”,如图:
1.png
2、放开“option”键,选中“创建NAT64网络”复选框,如图:
2.png
3、“共享以下来源的连接”,选择“Thunderbolt以太网”,如图:
3.png
4、“用以下端口共享给电脑”,选中“Wi-Fi”复选框,如图:
4.png
5、点击“Wi-Fi选项...”,设置密码,如图:
5.png
6、选中“互联网共享”复选框,点击“启用”按钮,如图:
6.png
7、最后在状态栏里出现以下图片:
7.png
8、至此,热点创建成功
四、设置Iphone Wi-Fi
1、打开飞行模式
2、打开Wi-Fi
3、连接“yuanjun的MacBook Pro”热点
4、查看NDS,如图:
8.png
五、运行demo代码,进行检测
1、代码地址:https://pan.baidu.com/s/1eRLNhia
2、运行结果,如图:
9.png10.png
如果下载地址为null,说明没有测试成功IPV6环境,如果有下载地址,说明IPV6环境测试通过

God bless U !

]]>
0 http://simple.imoowi.com/136.html#comments http://simple.imoowi.com/feed/136.html
老书分享-《参与感》 http://simple.imoowi.com/134.html http://simple.imoowi.com/134.html Mon, 16 Jan 2017 09:21:00 +0800 simpleyuan 《参与感》是多年前的一本书了,这是一本好书,欲知它好在哪里?请细细品读!
电子书(kindle版)地址参与感-二维码.png

]]>
0 http://simple.imoowi.com/134.html#comments http://simple.imoowi.com/feed/134.html
简单二维码生成器 http://simple.imoowi.com/130.html http://simple.imoowi.com/130.html Thu, 24 Nov 2016 16:06:00 +0800 simpleyuan 访问地址: http://qr.imoowi.com

PC效果图如下:
WechatIMG1.jpeg

移动端效果图如下:
WechatIMG3.jpeg

分享给大家使用

]]>
0 http://simple.imoowi.com/130.html#comments http://simple.imoowi.com/feed/130.html
nginx1.10.0+mysql5.7.16+php7.0.13安装教程 http://simple.imoowi.com/86.html http://simple.imoowi.com/86.html Tue, 15 Nov 2016 11:44:00 +0800 simpleyuan 一、准备
1、zlib zlib-1.2.8.tar.gz(http://www.zlib.net)
2、pcre pcre-8.36.tar.bz2(http://www.pcre.org/)
3、openssl openssl-1.0.1j.tar.gz(http://www.openssl.org/)
4、nginx nginx-1.10.0.tar.gz(http://nginx.org/en/download.html)
5、mysql mysql-boost-5.7.16.tar.gz(http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-boost-5.7.16.tar.gz)
6、php php-7.0.13.tar.gz(http://php.net/downloads.php)
(约定:所有的源码放在目录 /home/yuanjun/src,所有的操作权限都是在root权限下进行)

二、安装NGINX
#cd /home/yuanjun/src
1、安装zlib
#tar zxf zlib-1.2.8.tar.gz
#cd zlib-1.2.8
#./configure --static --prefix=/usr/local/zlib
#make
#make install
#cd ../

2、安装openssl
#tar zxf openssl-1.0.1j.tar.gz
#cd openssl-1.0.1j
#./config --prefix=/usr/local/openssl -L/usr/local/zlib/lib -I/usr/local/zlib/include threads zlib enable-static-engine
#make
#make install
#cd ../

3、安装pcre
#tar jxf pcre-8.36.tar.bz2
#cd pcre-8.36
#./configure --prefix=/usr/local/pcre
#make
#make install
#cd ../

4、安装nginx
#tar zxf nginx-1.10.0.tar.gz
#cd nginx-1.10.0
#./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-openssl=../openssl-1.0.1j --with-zlib=../zlib-1.2.8 --with-pcre=../pcre-8.36 --with-http_stub_status_module --with-http_gzip_static_module --with-http_ssl_module
#make
#make install
#cd ../

三、配置
1、配置nginx.conf
#vim /usr/local/nginx/nginx.conf
打开nginx.conf文件,其内容如下:
#user nobody;
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;

#gzip on;

server {
listen 80; //监听端口
server_name localhost; //服务器名

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
root html; //web根目录
index index.html index.htm; //首页支持语言
}

#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 html;
}

# 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
#
#location ~ \.php$ {
# root html;
# 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;
#}
}


# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;

# location / {
# root html;
# index index.html index.htm;
# }
#}


# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;

# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;

# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;

# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;

# location / {
# root html;
# index index.html index.htm;
# }
#}

}

进行以上配置之后,打开nginx服务
#/usr/local/nginx/nginx
这样服务器就打开了,在本机浏览器输入localhost,即可看见nginx的欢迎页面
如果想要关闭nginx服务,则输入以下命令:
#/usr/local/nginx/ -s stop

2、配置防火墙
如果想要外网能够访问我们的web服务,则需要添加防火墙规则
#vim /etc/sysconfig/iptables
加入以下规则:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
#/etc/init.d/iptables restart #重启防火墙使其配置生效
这样,就可以从外网访问我们的web服务了

centos7:
查看80端口:# firewall-cmd --query-port=80/tcp
开启80端口:# firewall-cmd --zone=public --add-port=80/tcp --permanent

3、加入系统服务
vim /etc/init.d/nginx
加入以下内容:
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /usr/local/nginx/nginx.conf
# config: /usr/local/nginx/nginx
# pidfile: /usr/local/nginx/nginx.pid

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0

# 这里要根据实际情况修改
nginx="/usr/local/nginx/nginx"
prog=$(basename $nginx)

# 这里要根据实际情况修改
NGINX_CONF_FILE="/usr/local/nginx/nginx.conf"

[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx

lockfile=/var/lock/subsys/nginx

start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}

stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
killall -9 nginx
}

restart() {
configtest || return $?
stop
sleep 1
start
}

reload() {
configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}

force_reload() {
restart
}

configtest() {
$nginx -t -c $NGINX_CONF_FILE
}

rh_status() {
status $prog
}

rh_status_q() {
rh_status >/dev/null 2>&1
}

case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac

chmod 755 /etc/init.d/nginx
chkconfig nginx on
chkconfig --list

启动nginx:service nginx start
停止nginx:service nginx stop
重启nginx服务:service nginx reload


四、安装 mysql5.7.16:
# yum install cmake
# tar zxf mysql-5.7.16.tar.gz
# cd mysql-5.7.16
# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/data/mysql -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/home/yuanjun/src/mysql-5.7.16/boost
#make
#make install

# groupadd mysql
# useradd -r -g mysql -s /bin/false mysql
# cd /usr/local
# tar zxvf /path/to/mysql-VERSION-OS.tar.gz
# ln -s full-path-to-mysql-VERSION-OS mysql
# cd mysql
# mkdir mysql-files
# chmod 750 mysql-files
# chown -R mysql .
# chgrp -R mysql .
# bin/mysql_install_db --user=mysql # Before MySQL 5.7.6
# bin/mysqld --initialize --user=mysql # MySQL 5.7.6 and up
# bin/mysql_ssl_rsa_setup # MySQL 5.7.6 and up
# chown -R root .
# chown -R mysql data mysql-files
# bin/mysqld_safe --user=mysql &
# Next command is optional
# cp support-files/mysql.server /etc/init.d/mysql
# ln -s /usr/local/mysql/bin/mysql /usr/bin
# service mysql start

启动mysql:service mysql start
停止mysql: service mysql stop
重启mysql: service mysql restart
mysql password : 111111


五、安装 php7.0.13:
#yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel pcre-devel
#yum -y install curl-devel
#yum -y install libxslt-devel
#tar zxf php-7.0.13.tar.gz
#cd php-7.0.13
#./configure --prefix=/usr/local/php \
--with-curl \
--with-freetype-dir \
--with-gd \
--with-gettext \
--with-iconv-dir \
--with-kerberos \
--with-libdir=lib64 \
--with-libxml-dir \
--with-mysqli \
--with-openssl \
--with-pcre-regex \
--with-pdo-mysql \
--with-pdo-sqlite \
--with-pear \
--with-png-dir \
--with-jpeg-dir \
--with-xmlrpc \
--with-xsl \
--with-zlib \
--enable-fpm \
--enable-bcmath \
--enable-libxml \
--enable-inline-optimization \
--enable-gd-native-ttf \
--enable-mbregex \
--enable-mbstring \
--enable-opcache \
--enable-pcntl \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-sysvsem \
--enable-xml \
--enable-zip

#make && make install
#
#cp php.ini-development /usr/local/php/lib/php.ini
#cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
#cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
#cp -R ./sapi/fpm/php-fpm /etc/init.d/php-fpm

在配置的时候如果报错:error: Cannot find OpenSSL's,请输入以下命令安装openssl库:
#yum install openssl openssl-devel
启动
# /etc/init.d/php-fpm
将php-fpm加入系统自启动
#vim /etc/init.d/php-fpm
替换内容为:
#! /bin/sh

### BEGIN INIT INFO
# Provides: php-fpm
# Required-Start: $remote_fs $network
# Required-Stop: $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts php-fpm
# Description: starts the PHP FastCGI Process Manager daemon
### END INIT INFO

prefix=/usr/local/php
exec_prefix=${prefix}

php_fpm_BIN=${exec_prefix}/sbin/php-fpm
php_fpm_CONF=${prefix}/etc/php-fpm.conf
php_fpm_PID=${prefix}/var/run/php-fpm.pid


php_opts="--fpm-config $php_fpm_CONF --pid $php_fpm_PID"


wait_for_pid () {
try=0

while test $try -lt 35 ; do

case "$1" in
'created')
if [ -f "$2" ] ; then
try=''
break
fi
;;

'removed')
if [ ! -f "$2" ] ; then
try=''
break
fi
;;
esac

echo -n .
try=`expr $try + 1`
sleep 1

done

}

case "$1" in
start)
echo -n "Starting php-fpm "

$php_fpm_BIN --daemonize $php_opts

if [ "$?" != 0 ] ; then
echo " failed"
exit 1
fi

wait_for_pid created $php_fpm_PID

if [ -n "$try" ] ; then
echo " failed"
exit 1
else
echo " done"
fi
;;

stop)
echo -n "Gracefully shutting down php-fpm "

if [ ! -r $php_fpm_PID ] ; then
echo "warning, no pid file found - php-fpm is not running ?"
exit 1
fi

kill -QUIT `cat $php_fpm_PID`

wait_for_pid removed $php_fpm_PID

if [ -n "$try" ] ; then
echo " failed. Use force-quit"
exit 1
else
echo " done"
fi
;;

status)
if [ ! -r $php_fpm_PID ] ; then
echo "php-fpm is stopped"
exit 0
fi

PID=`cat $php_fpm_PID`
if ps -p $PID | grep -q $PID; then
echo "php-fpm (pid $PID) is running..."
else
echo "php-fpm dead but pid file exists"
fi
;;

force-quit)
echo -n "Terminating php-fpm "

if [ ! -r $php_fpm_PID ] ; then
echo "warning, no pid file found - php-fpm is not running ?"
exit 1
fi

kill -TERM `cat $php_fpm_PID`

wait_for_pid removed $php_fpm_PID

if [ -n "$try" ] ; then
echo " failed"
exit 1
else
echo " done"
fi
;;

restart)
$0 stop
$0 start
;;

reload)

echo -n "Reload service php-fpm "

if [ ! -r $php_fpm_PID ] ; then
echo "warning, no pid file found - php-fpm is not running ?"
exit 1
fi

kill -USR2 `cat $php_fpm_PID`

echo " done"
;;

configtest)
$php_fpm_BIN -t
;;

*)
echo "Usage: $0 {start|stop|force-quit|restart|reload|status|configtest}"
exit 1
;;

esac

加入系统服务
#chmod 755 /etc/init.d/php-fpm
#chkconfig --add php-fpm
#chkconfig php-fpm on

控制自己.jpg

]]>
0 http://simple.imoowi.com/86.html#comments http://simple.imoowi.com/feed/86.html
ssdb做主主同步 http://simple.imoowi.com/81.html http://simple.imoowi.com/81.html Mon, 07 Nov 2016 15:16:00 +0800 simpleyuan 参考网址:http://ssdb.io/docs/zh_cn/replication.html

host1(192.168.10.1)的ssdb.conf配置文件
# ssdb-server config
# MUST indent by TAB!

# relative to path of this file, directory must exists
work_dir = ./var
pidfile = ./var/ssdb.pid

server:
#ip: 127.0.0.1
ip: 0.0.0.0
port: 8888
# bind to public ip
#ip: 0.0.0.0
# format: allow|deny: all|ip_prefix
# multiple allows or denys is supported
#deny: all
allow: 127.0.0.1
allow: 192.168
# auth password must be at least 32 characters
#auth: very-strong-password

replication:
binlog: yes
# Limit sync speed to *MB/s, -1: no limit
sync_speed: -1
slaveof:
# to identify a master even if it moved(ip, port changed)
# if set to empty or not defined, ip:port will be used.
id: svc_2
# sync|mirror, default is sync
type: mirror
ip:192.168.10.2
#host: localhost
port: 8888

logger:
level: debug
output: log.txt
rotate:
size: 1000000000

leveldb:
# in MB
cache_size: 500
# in KB
block_size: 32
# in MB
write_buffer_size: 64
# in MB/s
compaction_speed: 1000
# yes|no
compression: yes


host2(192.168.10.2)的ssdb.conf配置文件

# ssdb-server config
# MUST indent by TAB!

# relative to path of this file, directory must exists
work_dir = ./var
pidfile = ./var/ssdb.pid

server:
#ip: 127.0.0.1
ip: 0.0.0.0
port: 8888
# bind to public ip
#ip: 0.0.0.0
# format: allow|deny: all|ip_prefix
# multiple allows or denys is supported
#deny: all
allow: 127.0.0.1
allow: 192.168
# auth password must be at least 32 characters
#auth: very-strong-password

replication:
binlog: yes
# Limit sync speed to *MB/s, -1: no limit
sync_speed: -1
slaveof:
# to identify a master even if it moved(ip, port changed)
# if set to empty or not defined, ip:port will be used.
id: svc_1
# sync|mirror, default is sync
type: mirror
ip:192.168.10.1
#host: localhost
port: 8888

logger:
level: debug
output: log.txt
rotate:
size: 1000000000

leveldb:
# in MB
cache_size: 500
# in KB
block_size: 32
# in MB
write_buffer_size: 64
# in MB/s
compaction_speed: 1000
# yes|no
compression: yes

注意:两台机器的8888端口需要防火墙打开权限

]]>
4 http://simple.imoowi.com/81.html#comments http://simple.imoowi.com/feed/81.html
gulp多张图片自动合成sprite图片(Mac环境) http://simple.imoowi.com/73.html http://simple.imoowi.com/73.html Tue, 01 Nov 2016 21:52:00 +0800 simpleyuan 1、安装nodejs,直接到nodejs官网下载安装包,双击安装即可。

2、创建工程目录,准备好放图片的目录
$ cd
$ mkdir ~/Desktop/gulp_project
$ cd ~/Desktop/gulp_project
$ mkdir images


3、把需要用到的图片放到~/Desktop/gulp_project/images目录下

4、开始,输入以下简单几条命令即可搞定
$ sudo npm install --global gulp-cli //安装全局gulp
$ sudo npm init //生成package.json文件,可以一直按Enter
$ sudo npm install gulp //安装本地gulp模块
$ sudo npm install --save-dev gulp.spritesmith //安装sprite模块


4.1 编写gulpfile.js
var gulp=require('gulp'),spritesmith=require('gulp.spritesmith'); //引入gulp和gulp.spritesmith模块

gulp.task('default', function () {
return gulp.src('images/*.png')//需要合并的图片地址,此处为png后缀的图片
.pipe(spritesmith({
imgName: 'images/sprite.png',//保存合并后图片的地址
cssName: 'css/sprite.css',//保存合并后对于css样式的地址
padding:5,//合并时两个图片的间距
}))
.pipe(gulp.dest('dist/')); //最终结果放在哪里
});


4.2 运行
$ sudo gulp //在工程目录下执行

到目录~/Desktop/gulp_project/dist下查看结果,生成了两个文件
css/sprite.css
/*
Icon classes can be used entirely standalone. They are named after their original file names.

Example usage in HTML:

`display: block` sprite:


To change `display` (e.g. `display: inline-block;`), we suggest using a common CSS class:

// CSS
.icon {
display: inline-block;
}

// HTML

*/
.icon-action_btn_inner_dot {
background-image: url(../images/sprite.png);
background-position: 0px -47px;
width: 40px;
height: 8px;
}
.icon-action_btn_no_dot {
background-image: url(../images/sprite.png);
background-position: 0px 0px;
width: 70px;
height: 42px;
}
.icon-action_btn_with_dot {
background-image: url(../images/sprite.png);
background-position: -75px 0px;
width: 70px;
height: 42px;
}

和图片images/sprite.png


Demo下载地址https://pan.baidu.com/s/1qY2Gypm

Enjoy!

]]>
0 http://simple.imoowi.com/73.html#comments http://simple.imoowi.com/feed/73.html
Centos安装FFmpeg[支持amr转mp3] http://simple.imoowi.com/70.html http://simple.imoowi.com/70.html Tue, 25 Oct 2016 11:53:00 +0800 simpleyuan 参考网址:
linux下使用ffmpeg将amr转成mp3
apache/Nginx下的PHP/Ruby执行sudo权限的系统命令

1. 首先安装系统编译环境
yum install -y automake autoconf libtool gcc gcc-c++ #CentOS

2. 编译所需源码包

#yasm:汇编器,新版本的ffmpeg增加了汇编代码
wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
tar -xzvf yasm-1.3.0.tar.gz
cd yasm-1.3.0
./configure
make
make install

#lame:Mp3音频解码
wget http://jaist.dl.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
tar -xzvf lame-3.99.5.tar.gz
cd lame-3.99.5
./configure
make
make install

#amr支持
wget http://downloads.sourceforge.net/project/opencore-amr/opencore-amr/opencore-amr-0.1.3.tar.gz
tar -xzvf opencore-amr-0.1.3.tar.gz
cd opencore-amr-0.1.3
./configure
make
make install

#amrnb支持
wget http://www.penguin.cz/~utx/ftp/amr/amrnb-11.0.0.0.tar.bz2
tar -xjvf amrnb-11.0.0.0.tar.bz2
cd amrnb-11.0.0.0
./configure
make
make install

#amrwb支持
wget http://www.penguin.cz/~utx/ftp/amr/amrwb-11.0.0.0.tar.bz2
tar -xjvf amrwb-11.0.0.0.tar.bz2
cd amrwb-11.0.0.0
./configure
make
make install

#ffmpeg
wget https://ffmpeg.org/releases/ffmpeg-3.0.4.tar.bz2
tar -xjvf ffmpeg-3.0.4.tar.bz2
cd ffmpeg-3.0.4
./configure --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-version3 --enable-shared
make
make install

#加载配置
#最后写入config后,终端运行ffmpeg命令,出现success和已安装的扩展,则运行成功。
ldconfig

2.*

注意事项

ffmpeg默认安装目录为“/usr/local/lib”,有些64位系统下软件目录则为“/usr/lib64”,编译过程中可能会出现
“ffmpeg: error while loading shared libraries: libmp3lame.so.0: cannot open shared object file: No such file or directory”等类似的错误,解决办法是建立软链接:
# ln -s /usr/local/lib/libmp3lame.so.0.0.0 /usr/lib64/libmp3lame.so.0

附录2. 如果出现以下提示:ffmpeg: error while loading shared libraries: libavdevice.so.54: cannot open shared object file: No such file or directory
可以通过如下方式查看ffmpeg的动态链接库哪些没有找到:
ldd `which ffmpeg`
libavdevice.so.54 => not found
libavfilter.so.3 => not found
libavformat.so.54 => not found
libavcodec.so.54 => not found
libswresample.so.0 => not found
libswscale.so.2 => not found
libavutil.so.51 => not found
libm.so.6 => /lib64/libm.so.6 (0x00002ab7c0eb6000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00002ab7c100b000)
libc.so.6 => /lib64/libc.so.6 (0x00002ab7c1125000)
/lib64/ld-linux-x86-64.so.2 (0x00002ab7c0d9a000)
#如果类似于上面的输出内容,查找以上类库,会发现全部在/usr/local/lib/下
find /usr/local/lib/ | grep -E "libavdevice.so.54|libavfilter.so.3|libavcodec.so.54"
/usr/local/lib/libavfilter.so.3.17.100
/usr/local/lib/libavcodec.so.54.59.100
/usr/local/lib/libavdevice.so.54
/usr/local/lib/libavcodec.so.54
/usr/local/lib/libavfilter.so.3
/usr/local/lib/libavdevice.so.54.2.101

#查看链接库配置文件
more /etc/ld.so.conf | grep /usr/local/lib
#如果不包含的话,需要编辑此文添加:
vi /etc/ld.so.conf
/usr/local/lib
/usr/local/lib64
#运行配置命令
ldconfig


3. php调用ffmpeg权限问题
apache/Nginx下的PHP/Ruby可以直接Windows和Linux下的系统命令,在Linux下,一般只能执行普通用户对应的权限,如果要执行一下需要Sudo的命令,则需要进行一些配置。

修改方式是将Webserver运行的用户名,加上sudo权限,这样php或者Ruby(以下就只写php了)就可以调用sudo及对应的命令了。

一般来说,为了安全,需要指定这些用户可以执行哪些命令,方法是修改sudoers这个文件的配置。

首先编辑 /etc/sudoers 使用 vim来编辑
/etc/sudoers的权限是440:
-r–r—– 1 root root 3248 Oct 18 23:47 /etc/sudoers
需要
chmod u+w /etc/sudoers
修改完后再恢复原来的权限
chmod -w /etc/sudoers
因为如果/etc/sudoers的权限不是440,那么sudo会报错:
[root@hn ~]# sudo
sudo: /etc/sudoers is mode 0640, should be 0440
sudo: no valid sudoers sources found, quitting

在最下面添加一行
nobody ALL=NOPASSWD:/usr/local/squid/sbin/squid -k reconfigure
然后注释掉文件中的Defaults requiretty这行
否则会出现sudo: sorry, you must have a tty to run sudo的错误
保存退出即可

这里的nobody为WebServer运行的用户名,如httpd默认为apache,Nginx默认为nobody;
ALL=NOPASSWD为执行sudo时不需要输入密码,即在非交互界面中直接执行命令;
/usr/local/squid/sbin/squid -k reconfigure则是将可以执行的完整命令。

]]>
0 http://simple.imoowi.com/70.html#comments http://simple.imoowi.com/feed/70.html
加班狗-成功上线 http://simple.imoowi.com/65.html http://simple.imoowi.com/65.html Fri, 10 Jun 2016 01:29:00 +0800 simpleyuan 接到“加班狗”通过的邮件,实在是激动万分,因为首次发布IOS工具就顺利的通过了
“加班狗”是用来记录自己的加班时间的,如果以后要调休/倒休,都可以参考这个时间来进行;同时也是对自己加班的一个督促,督促自己少加班,多提高工作效率。
加班狗的下载地址是:
http://a.app.qq.com/o/simple.jsp?pkgname=com.imoowi.jiabangou
也可手机扫描二维码进行下载

]]>
0 http://simple.imoowi.com/65.html#comments http://simple.imoowi.com/feed/65.html
chrome二维码扩展 http://simple.imoowi.com/63.html http://simple.imoowi.com/63.html Sat, 02 Apr 2016 03:43:12 +0800 simpleyuan 晚上看iOS的英文文档,在准备睡觉的时候,想把文档放到手机上,于是决定做个chrome二维码插件来显示当前网页的url二维码,然后通过手机扫描,即可在手机阅读想要的文章。
现在将插件分享出来,插件地址 imoowi_qr_chrome_extension.crx

]]>
0 http://simple.imoowi.com/63.html#comments http://simple.imoowi.com/feed/63.html