转到正文

天亮了说晚安's Blog

欢迎您的光临! http://www.tllswa.com

存档

2014 年 11 月 的存档

linux下shell脚本学习

11月 29
未分类

本文转自:http://yq329.blog.163.com/blog/static/117379566201161385120497/ 在Linux系统中,虽然有各种各样的图形化接口工具,但是sell仍然是一个非常灵活的工具。Shell不仅仅是命令的收集,而且是一门非常棒的编程语言。您可以通过使用shell使大量的任务自动化,shell特别擅长系统管理任务,尤其适合那些易用性、可维护性和便携性比效率更重要的任务。    下面,让我们一起来看看shell是如何工作的: 1. 建立一个脚本 Linux中有好多中不同的shell,但是通常我们使用bash (bourne again shell) 进行shell编程,因为bash是免费的并且很容易使用。所以在本文中笔者所提供的脚本都是使用bash(但是在大多数情况下,这些脚本同样可以在bash的大姐,bourne shell 中运行)。 如同其他语言一样,通过我们使用任意一种文字编辑器,比如nedit、kedit、emacs、vi等来编写我们的shell程序。程序必须以下面的行开始(必须方在文件的第一行):   #!/bin/sh   符号#!用来告诉系统它后面的参数是用来执行该文件的程序。在这个例子中我们使用/bin/sh来执行程序。   当编辑好脚本时,如果要执行该脚本,还必须使其可执行。   要使脚本可执行:   chmod +x filename  ......Read More

本文转自:os.51cto.com/art/201006/208330.htm 一、如何查看服务器的CPU 今天安装了9台Linux服务器,型号完全不一样(有DELL、HP和IBM服务器),又懒得去对清单,如何在Linux下cpu的个数和核数呢?另外,nginx的cpu工作模式也需要确切的知道linux服务器到底有多少个逻辑cpu,不过现在服务器那是相当的彪悍,直接上worker_processes 8吧。 判断依据: 1.具有相同core id的cpu是同一个core的超线程。(Physical id and core id are not necessarily consecutive but they are unique. Any cpu with the same core id are hyperthreads in the same core.) 2.具有相同physical id的cpu是同一颗cpu封装的线程或者cores。(Any cpu with the same physical id are threads or cores in the same physical socket.) 以自己的惠普DL380G6为例说明: ①物理cpu个数: [root@localhost ~]# cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l ②每个物理cpu中core的个数(即核数) [root@localhost ~]# cat /proc/cpuinfo | grep "cpu cores" | uniq cpu cores : 4 这样可以推算出自己服务器的逻辑CPU为物理个数*核数,如果你的服务器是server2003,你可以在你的资源管......Read More

CentOS修改IP、DNS、网关

11月 29
未分类

本文转自:http://www.cnblogs.com/meteoric_cry/archive/2010/10/19/1855807.html 编辑网关:vi /etc/sysconfig/network 编辑DNS:vi /etc/resolv.conf 上面有两个dns地址(nameserver后面的内容),有一个是备用   修改IP,我装的机器是戴尔的(双网卡):vi /etc/sysconfig/network-scripts/ifcfg-eth0     具体英文名的参数,可以到网上搜一下,大把的。     更多详细的内容可以点击这里:www.21andy.com/blog/20100227/1717.html Read More

本文参考部分引用了:http://www.cnblogs.com/meteoric_cry/archive/2011/01/27/1945882.html 这里使用的是编写shell脚本的方式来处理,使用vi编辑器编写一个nginx文件存放于/etc/init.d/目录中。 vi /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/logs/nginx.pid nginx=”/usr/local/nginx/nginx” sysconfig=”/etc/sysconfig/$prog” lockfile=”/var/lock/subsys/nginx” pidfile=”/usr/local/nginx/logs/${prog}.pid” NGINX_CONF_FILE=”/usr/local/nginx/nginx.conf” prog=$(basename $nginx) # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ “$NETW......Read More

本文转自:http://www.nginx.cn/2196.html centos源不能安装libmcrypt-devel,由于版权的原因没有自带mcrypt的包 有两种方法解决,一种是使用第三方源,这样还可以使用yum来安装,简单方便,坏处是第三方源多少有中不可靠的感觉。 解决办法一 1、安装第三方yum源 wget http://www.atomicorp.com/installers/atomic sh ./atomic 2、使用yum命令安装 yum  install  php-mcrypt  libmcrypt  libmcrypt-devel 解决办法二、 使用php mcrypt 前必须先安装Libmcrypt libmcrypt源码安装方法: cd /usr/local/src wget http://softlayer.dl.sourceforge.net/sourceforge/mcrypt/libmcrypt-2.5.8.tar.gz tar -zxvf libmcrypt-2.5.8.tar.gz cd /usr/local/src/libmcrypt-2.5.8 ./configure --prefix=/usr/local make make install 另一解决办法: configure: error: mcrypt.h not found. Please reinstall libmcrypt. 今天在编译php的时候,出现如下错误php安装出错:configure: error: mcrypt.h not found. Please reinstall libmcrypt.,意思是,没有查找到mcrytp.h,需要安装libcrytp,在下面的地址下载libmarypt: wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/at......Read More

本文转自:http://www.nginx.cn/231.html nginx本身不能处理PHP,它只是个web服务器,当接收到请求后,如果是php请求,则发给php解释器处理,并把结果返回给客户端。 nginx一般是把请求发fastcgi管理进程处理,fascgi管理进程选择cgi子进程处理结果并返回被nginx 本文以php-fpm为例介绍如何使nginx支持PHP 一、编译安装php-fpm 什么是PHP-FPM PHP-FPM是一个PHP FastCGI管理器,是只用于PHP的,可以在 http://php-fpm.org/download下载得到. PHP-FPM其实是PHP源代码的一个补丁,旨在将FastCGI进程管理整合进PHP包中。必须将它patch到你的PHP源代码中,在编译安装PHP后才可以使用。 新版PHP已经集成php-fpm了,不再是第三方的包了,推荐使用。PHP-FPM提供了更好的PHP进程管理方式,可以有效控制内存和进程、可以平滑重载PHP配置,比spawn-fcgi具有更多优点,所以被PHP官方收录了。在./configure的时候带 –enable-fpm参数即可开启PHP-FPM,其它参数都是配置php的,具体选项含义可以查看这里。 安装前准备 centos下执行 yum -y install gcc automake autoconf libtool make yum -y install gcc gcc-c++ glibc yum -y install libmcrypt-devel mhash-devel libxslt-devel......Read More

Centos下Nginx安装

11月 28
未分类

本文转自:http://www.nginx.cn/install nginx可以使用各平台的默认包来安装,本文是介绍使用源码编译安装,包括具体的编译参数信息。 正式开始前,编译环境gcc g++ 开发库之类的需要提前装好,这里默认你已经装好。 ububtu平台编译环境可以使用以下指令 apt-get install build-essential apt-get install libtool centos平台编译环境使用如下指令 安装make: yum -y install gcc automake autoconf libtool make 安装g++: yum install gcc gcc-c++ 下面正式开始 ————————————————————————— 一般我们都需要先装pcre, zlib,前者为了重写rewrite,后者为了gzip压缩。 1.选定源码目录 可以是任何目录,本文选定的是/usr/local/src cd /usr/local/src 2.安装PCRE库 ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ 下载最新的 PCRE 源码包,使用下面命令下载编译和安装 PCRE 包: cd /usr/local/src wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.34.tar.gz tar -zxvf pcre-8.......Read More

本文转自:http://blog.csdn.net/lmss82/article/details/4414178 今天服务器遇到了一个很熟悉的问题 输入 #mysql -u root -p ERROR 2002 (HY000):Can’t connect to local MySQL server 随即上网找寻答案 根据大家提供的方法我逐一尝试 方案1.  1.#ps -A|grep mysql    显示类似:   1829 ?        00:00:00 mysqld_safe 1876 ?        00:00:31 mysqld   2.#kill -9 1829   3.#kill -9 1876   4.#/etc/init.d/mysql restart   5.#mysql -u root -p    他的麻烦解决了,我的还没解决! 继续找 方案2 先查看 /etc/rc.d/init.d/mysqld status 看看m y s q l 是否已经启动. 另外看看是不是权限问题. ———————————————————————————— [root@localhost beinan]#chown -R mysql:mysql /var/lib/mysql [root@localhost beinan]# /etc/init.d/mysqld start 启动 MySQL: [ 确定 ] [root@localhost lib]# mysqladmin -uroot password ‘123456’ [root@l......Read More

备案信息