1 2 3 |
sudo useradd -s /bin/bash -mr <username> sudo adduser <username> sudo sudo passwd <username> |
Month: 1月 2016
Xcode资源文件清理:删除无用的旧设备支持文件
Mac硬盘只剩下20G可用空间了,做了清理也只清理出了3G可用空间,但是印象里自己并没有在电脑存太多东西啊!于是开始做手动磁盘清理,在检查用户目录下的资源库时,发现这个目录异常的大:
~/Library/Developer/Xcode/iOS\ DeviceSupport
里面似乎是各个版本的iOS支持文件,甚至还有6.1.3版本的支持文件。如果能删除旧版的支持文件,那就能给电脑腾出一大块空间啊!于是找了一下资料,看能不能删除。
根据这个回答,删除旧版支持文件是完全没有问题的,甚至可以全部删除,并且应该定期删除!
phpMyAdmin数据库乱码问题
第一次写后端,遇到了不少问题,这个问题比较坑!
问题描述:
1,从网页提交数据库数据,在phpmyadmin上显示乱码,在网页输出是好的。
2,用phpmyadmin从数据库插入数据,输出到网页后是乱码。
环境看似没有任何问题:网页已经声明使用『UTF-8』,数据库已经设置编码为『utf8_general_ci』。
为何还是出现了编码问题呢?
答:从网页提交数据库数据,在phpmyadmin上显示乱码,在网页输出是好的,说明提交的数据和数据库的编码不一样,提取数据的编码和提交数据的编码一样 。A->B->A型
解决方案:
把所以关于数据库查询、插入的语句前全部加上一行:
1 |
mysql_query("SET NAMES 'utf8'"); |
打开/关闭php错误信息输出 nginx+php5
编辑php配置文件:/etc/php5/fpm/php.ini
display_errors = On/Off
Ubuntu Server使用命令行版VPN客户端
为了能在外网玩上内网的MC服,朱总和我在腾讯云的学生优惠服务器上部署了一个VPN,想通过让内网MC服务器和客户端同时登录一个外网VPN的方式,曲线实现MC服务器和客户端处在同一局域网。
这样就涉及到让ubuntu server连接VPN的问题。
需要连接VPN的服务器是一台Ubuntu 14.04.3 LTS,使用pptp-linux软件连接VPN。
首先是安装软件包
1 2 3 |
sudo apt-get update sudo apt-get install pptp-linux pptpsetup --help |
确认已经安装好后,根据帮助使用pptpsetup建立VPN连接。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
pptpsetup --create --server [--domain ] --username [--password ] [--encrypt] [--start] pptpsetup --delete Options: * the name you wish to use to refer to the tunnel (you choose it), * the IP address or host name of the server, * the authentication domain name (optional), * the username you are to use, * the password you are to use, * whether encryption is required, * whether to start the connection after configuration. pptpsetup - Point-to-Point Tunneling Protocol setup Copyright (C) 2006 Nelson Ferraz |
例如:
1 |
sudo pptpsetup --create VPN --server 115.159.**.** --username user --password userpass --encrypt --start |
看到如下提示,表明连接成功。
1 2 3 4 5 6 |
Using interface ppp0 Connect: ppp0 <--> /dev/pts/1 CHAP authentication succeeded MPPE 128-bit stateless compression enabled local IP address 10.0.0.100 remote IP address 10.0.0.1 |
用电脑模拟微信浏览器
想开发专为微信定制的网页,但用手机微信进行调试总是十分不方便,于是想用Chrome模拟微信浏览器。
打开Chrome的开发者工具,开启手机模拟。
将UA更改为以下任意一个:
iPhone:
1 |
Mozilla/5.0 (iPhone; CPU iPhone OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9B176 MicroMessenger/4.3.2 |
安卓:
1 |
Mozilla/5.0 (Linux; U; Android 2.3.6; zh-cn; GT-S5660 Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1 MicroMessenger/4.5.255 |
刷新页面即可。
参考资料:http://www.sky00.com/archives/1292.html/comment-page-1
ubuntu 1404 下安装 nginx+php5+mysql+phpmyadmin
1. 使用官方PPA安装 Nginx 最新版本,使用以下命令:
1 2 |
sudo apt-get update sudo apt-get install nginx |
2. 安装 PHP:(不要尝试直接apt-get install php5,这样会默认安装apache)
1 |
sudo apt-get install php5.6-cli php5.6-cgi php5.6-fpm php5.6-mcrypt php5.6-mysql curl libcurl3 libcurl3-dev php5.6-curl |
3. 安装 MySQL 数据库:
1 |
sudo apt-get install mysql-server |
4. nginx管理操作
1 |
sudo service nginx {start|stop|restart|reload|force-reload|status|configtest} |
5. 配置nginx
1 2 3 4 5 6 |
sudo mv /usr/share/nginx/html /usr/share/nginx/www # 为了方便远程编辑站点目录下的文件,我喜欢将站点根目录属主改为自己的用户 sudo chown -R ubuntu:ubuntu /usr/share/nginx/www sudo ln -s /usr/share/nginx/www /www sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/default.backup sudo nano /etc/nginx/sites-available/default |
配置文件样本:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; root /usr/share/nginx/www; index index.php index.html index.htm; # Make site accessible from http://localhost/ server_name www.test.com test.com *.test.com; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; # Uncomment to enable naxsi on this location # include /etc/nginx/naxsi.rules } 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/share/nginx/www; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini # # With php5-cgi alone: # fastcgi_pass 127.0.0.1:9000; # With php5-fpm: fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } } |
重启nginx:
1 |
sudo service nginx restart |
6. 安装phpMyAdmin
1 2 3 4 5 |
cd /www wget https://files.phpmyadmin.net/phpMyAdmin/4.5.3.1/phpMyAdmin-4.5.3.1-all-languages.zip unzip ./phpMyAdmin-4.5.3.1-all-languages.zip rm phpMyAdmin-4.5.3.1-all-languages.zip mv ./phpMyAdmin-4.5.3.1-all-languages ./pma |
参考资料:https://idefs.com/record-under-ubuntu-nginx-php5-mysql.html
Linux下批量替换文件名中的部分字段
从网上下载了一批旧的影视剧资源,命名倒是挺规范,但是不和我的胃口,想要重新命名。
但是不能用简单的批量重命名,因为原文件名里包含一个集名的字段,这个字段一定是不同的。如果用批量重命名,会导致这个字段消失,然而我想保留它,于是想批量替换掉我不想要的字段。
Mac上用brew安装了rename,默认安装的是Perl 语言版本。
命令格式:rename ‘s/原字符串/新字符串/’ 文件名
字符串支持正则,要注意字符元的使用和转义。
同时,原字符串只会在一个文件名中匹配一次,例如:
[舌尖上的中国][01][高清版][HR-HDTV].mp4
执行:rename ‘s/\]\[/./’
[舌尖上的中国.01][高清版][HR-HDTV].mp4