服务器
ubuntu交互式界面修改时区
sudo dpkg-reconfigure tzdata
安装ucmq
1 安装libevent ucmq需求>2.0.10
$ wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz $ tar zxvf libevent-2.0.21-stable.tar.gz $ cd libevent-2.0.21-stable $ ./configure --prefix=/usr/local/libevent $ make $ sudo make install
2 安装ucmq
$ git clone git://github.com/ucopensource/ucmq.git $ cd ucmq $ ./configure --with-libevent=/usr/local/libevent --prefix=/usr/local/ucmq $ make $ sudo make install
3 配置启动关闭ucmq
ucmq目录/usr/local/ucmq/
启动UCMQ /usr/local/ucmq/bin/ucmq –c /usr/local/ucmq/conf/ucmq.ini –d
关闭UCMQ killall ucmq 或者 curl http://0.0.0.0:8803/exec?cmd=kill
4 遇到libpthread.so.0: error adding symbols: DSO missing from command line编译错误
在
source/Makefile Makefile
中添加-lpthread
LIBS = -lz -lrt -lresolv -lnsl -lm -ldl -lbz2 -lpthread
Ubuntu下安装php-redis扩展
$ sudo apt-get install php5-dev $ wget --no-check-certificate http://github.com/nicolasff/phpredis/tarball/master -O phpredis.tar.gz $ tar -xzvf phpredis.tar.gz $ cd nicolasff-phpredis-94e0649 $ phpize $ ./configure $ make $ sudo make install
增加php.ini配置
extension=redis.so
mysql 远程访问权限开启
mysql -u root -p123456; mysql GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION; mysql flush privileges;
mysql5.5远程主从设置
主机:10.0.0.1
从机:10.0.0.2
1 主机设置
1.1 配置文件/etc/mysql/my.cnf
server-id = 1 log_bin = /var/log/mysql/mysql-bin.log expire_logs_days = 2 max_binlog_size = 100M binlog_ignore_db = mysql binlog_ignore_db = information_schema binlog_ignore_db = performance_schema binlog_do_db = testcase binlog_do_db = db100 binlog_do_db = db200
1.2 mysql控制台命令启动master模式
mysql>GRANT replication slave on *.* to 'slave2'@'10.0.0.2' IDENTIFIED BY 'password'; mysql>SHOW master status;
2 从机设置
2.1 从机配置
server-id = 2 log_bin = /var/log/mysql/mysql-bin.log expire_logs_days = 2 max_binlog_size = 100M
2.2 从机控制台命令
mysql>slave stop; mysql>change master to master_host='10.0.0.1', master_port=3306, master_user='slave2', master_password='password', master_log_file='mysql-bin.000011', master_log_pos=189; mysql>slave start; mysql>show slave status \G;
3mysql远程账号设置
mysql>grant all privileges on *.* to njava@10.0.0.1 identified by "password" with grant option;
服务器上PHP使用QQ邮箱或者Gmail邮箱的SMTP发信
关键点
smtp地址需要加密:
gmail的smtp地址 【ssl://smtp.gmail.com 】
qq邮箱的smtp地址 【ssl://smtp.qq.com】
端口 【465】
linux内网利用iptables共享上网
一 上网机器设置,wlan0为互联网连接,eth0为内网网卡
1 设置/etc/sysctl.conf
net.ipv4.io_forward=1;
2 iptables规则
sudo iptables -t nat -A POSTROUTING -s 10.0.1.0/24 -o wlan0 -j MASQUERADE
3 /etc/network/interfaces
auto eth0 iface eth0 inet static address 10.0.1.1 netmask 255.255.255.0
局域网上网机器设置
1 /etc/network/interfaces
auto eth0 iface eth0 inet static address 10.0.1.2 gateway 10.0.1.1 netmask 255.255.255.0 dns-nameservers 8.8.8.8
自动同步linux服务器时间
在/etc/crontab中添加定时同步服务器时间,每天23点同步服务器时间
0 23 * * * root ntpdate asia.pool.ntp.org >> /var/log/ntpdate.log
ubuntu使用rsync+ssh备份
服务器一直没做备份,丢失信息,很惨,以后都使用rsync+ssh来同步服务器重要文件了。
WEB是要备份的服务器,CLIENT是放备份的服务器
1 在WEB上编写rsync备份脚本,使用root权限cron定时推送
2 rsync命令行语法如下
rsync -vzrtopg --delete -e ssh /var/www njava@bak-server01:/bak/www rsync -vclRarpogt --progress --delete -e ssh /var/lib/mysql/ root@bak-server01:/data/web01
macos下php+mysql不能使用localhost连接的问题解决
因为localhost是通过socket方式来连接,而127.0.0.1则是走的TCP协议。所以需要重新设置php-mysql的配置文件
$echo "show variables" | mysql | grep "socket" socket /opt/local/var/run/mysql5/mysqld.sock $vi /opt/local/var/db/php5/mysql.ini ; Do not edit this file; it is automatically generated by MacPorts. ; Any changes you make will be lost if you upgrade or uninstall php5-mysql. ; To configure PHP, edit /opt/local/etc/php5/php.ini. extension=mysql.so extension=mysqli.so extension=pdo_mysql.so mysql.default_socket= /opt/local/var/run/mysql5/mysqld.sock mysqli.default_socket= /opt/local/var/run/mysql5/mysqld.sock pdo_mysql.default_socket= /opt/local/var/run/mysql5/mysqld.sock
设置mysql.default_socket,mysqli.default_socket,pdo_mysql.default_socket