配置交换机本地端口镜像

配置交换机本地端口镜像步骤
1)进入系统视图
# system-view

2)创建本地镜像组
# mirroring-group group-id local
注:group-id:端口镜像组的组号,取值范围为1-20K
local 指定镜像组为本地镜像组

3)为镜像组配置源端口,有两种,系统视图和端口视图
第一种是在系统视图下配置源端口
# mirroring-group group-id mirroring-port mirroring-port-list { both | inbound |outbound }

注:both | inbound | outbound : 表示被镜像报文的方向,both表示同时对端口接收和发送报文进行镜像;inbound 表示仅对端口接收的报文进行镜像;outbound表示仅对端口发送的报文进行镜像

第二种是在端口视图下配置源端口
# interface interface-type interface-number
# mirroring-group group-id mirroring-port { both | inbound | outbound }
# quit

注:以上两种选其一就可以,在系统视图下同时配置多个源端口,也可以在具体的端口视图下配置源端口,两种视图下的配置效果相同

4)为镜像组配置目的端口,也是有两种方法,分别是在系统视图下配置和端口视图下配置
第一种在系统视图下配置目的端口
# mirroring-group group-id monitor-port monitor-port-id

第二种在端口视图下配置目的端
# interface interface-type interface-number
# mirroring-group group-id monitor-port

例一:

进入系统视图
# system-view

创建本地镜像组1
# mirroring-group 1 local

为镜像组1配置源端口
# mirroring-group 1 mirroring-port Ethernet1/0/1—Ethernet1/0/24 both

为镜像组配置目的端口
# mirroring-group 1 monitor-port Ethernet1/0/13

例二:

monitor-port
interface interface-type interface-number
mirroring-port { both | inbound | outbound }
monitor-port

首先要进入系统视频
sys
interface e1/0/1
mirroring-port both
quit
int e1/0/2
monitor-port
将1口的数据镜像到2口

注: monitor-port 是接监控设备的。 mirroring-port 是被监控端口
是上配置是华为s3600的,其他相关操作可以去华为官方查看操作手册

http://www.h3c.net.cn/Service/Document_Center/Switches/Catalog/S3600/S3600-SI/Command/Command_Manual/S3600-SI_CM(V1.04)/200711/317223_30005_0.htm#_Toc164575957

windows下设置mysql自动备份

windows下设置mysql自动备份脚本
把下面的代码保存在记事本文件中,然后以.bat格式保存,注意修改数据库所在的实际路径

@echo off
echo.
echo MySQL数据库备份脚本

echo *****************************
echo.
echo 备份日期:%date%
echo 备份时间:%time%
echo.
echo *****************************

set “Ymd=%date:~,4%%date:~5,2%%date:~8,2%”
echo 正在进入MySQL目录。注意:对于有空格的目录,命令行要加引号。”C:\Program Files”
cd “D:\Program Files\MySQL\MySQL Server 5.1\bin
echo 正在停止MySQL,请稍等……
net stop MySQL
echo 正在备份数据,请稍等……
xcopy “D:\Program Files\MySQL\MySQL Server 5.1″\data\mysql\*.* D:\MySQLdata_Bak\mysql\%Ymd%\ /s /y
echo 数据库备份完成,正在重启MySQL,请稍等……
net start MySQL
echo MySQL启动完成
echo.

然后添加到计划任务中,定时执行就可以了。以上代码让mysql自动备份有一个确定,就是会把服务停止了,然后再拷贝文件,压缩,如果可以像linux 下面用for 循环,结合mysqldump 就更完美了!

无法加载安装程序库 wbemupgd.dll,或是找不到函数0cEntry.

今天想给服务器添加一个组件,打开控制面板–添加或删除程序–添加或删除windows(组件)时,报无法加载安装程序库 wbemupgd.dll,或是找不到函数0cEntry.这个错误
解决办法:右击我的电脑–属性–高级—环境变量–系统变量找到path–编辑,把下面这段加到后面去,注意前面的分号‘;’
;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem

grep的基本用法

grep的基本用法
grep -[acinv] ‘搜索内容’ filename

-a :表示以文件方式搜索

-c:表示计算找到符合行的次数

-i :表示忽略大小写

-n :表示顺便输出行号

-v : 表示反向选择,即找到没有搜索字符串的行
eg:
1) 搜索有mglog的行,并输出行号
# grep -n ‘mglog’ mglog.txt
搜索没有mglog的行,并输出行号
# grep -nv ‘mglog’ mglog.txt
2) 利用 [ ] 搜索集合字符
# grep -n ‘t[ae]st’ mglog.txt
10:i can’t finish the test
11: Oh! the soup taste good!
3) 结合 行首字符^与行尾字条$ 使用
^ 表示行的开关 $ 表示行的结尾(不是字条,是位置)’^ $’ 表示空,因为只有行首和行尾

编译安装php、apache常见参数及错误

编译安装php、apache常见参数及错误
***********************************常用 apache 编译参数说明**********************

prefix 指定安装目录

enable-rewrite 支持 URL 重写

enable-deflate 支持网页压缩

enable-speling 纠正常见的URL拼写错误

enable-ssl SSL/TLS support (mod_ssl)

with-module 加载模块

–enable-so 指明编译动态加载模块(DSO)支持到httpd二进制文件,此模块使得Apache的各功能模块可以与核心分开编译、运行时动态加载

错误解决:
错误一:
httpd: Could not reliably determine the server’s fully qualified domain name, using ::1 for ServerName
解决:打开httpd.conf 找到#ServerName www.example.com:80 把#去掉,再重启apache

httpd: Could not reliably determine the server’s fully qualified domain name, using 61.191.206.4 for ServerName

错误二:不能识php文件
解决: 打开httpd.conf文件,把
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps 两行加进去
大约在这两行下面
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz

**************************************常用mysql编译参数说明**************************

enable-assembler 使用一些字符函数来汇编版本

with-extra-charsets=complex 使用的字符集为默认(无,复杂的,所有,或从上述设置选定的名单)

enable-thread-safe-client 让客户端支持线程

with-big-tables 大表支持

with-readline Use system readline instead of bundled copy

with-ssl Include SSL support

with-embedded-server 编译成embedded MySQL library (libmysqld.a)

enable-local-infile 让mysql支持从本地文件 导入数据库

with-plugins=innobase 存储引擎

with-charset=utf8 设置默认字符集

with-collation=utf8_general_ci 设置字符集校验规则

*******************************************常用PHP编译参数说明********************************

with-config-file-path 指定php.ini位置

with-apxs2 整合 apache,apxs功能是使用mod_so中的LoadModule指令,加载指定模块到 apache,要求 apache 要打开SO模块

with-mysql mysql安装目录,对mysql的支持

with-mysqli mysqli文件目录,优化支持

with-iconv-dir iconv函数,对字符集间的转换

with-freetype-dir 打开对freetype字体库的支持

with-jpeg-dir 打开对jpeg图片的支持

with-png-dir 打开对png图片的支持

with-zlib 打开zlib库的支持

with-libxml-dir 打开libxml2库的支持

enable-xml 打开xml的支持

enable-inline-optimization 优化线程

with-curl 打开curl浏览工具的支持

with-curlwrappers 运用curl工具打开url流

enable-mbregex 打开对mbregex的支持

enable-mbstring 多字节,字符串的支持

with-mcrypt 算法

with-gd 打开gd库的支持

enable-gd-native-ttf 支持TrueType字符串函数库

with-openssl openssl的支持,加密传输时用到的

with-mhash 算法

enable-pcntl freeTDS需要用到的,可能是链接mssql 才用到

enable-sockets 打开 sockets 支持

with-ldap Include LDAP support

with-ldap-sasl LDAP: Include Cyrus SASL support

with-xmlrpc 打开xml-rpc的c语言

enable-zip 打开对zip的支持

enable-soap Enable SOAP support

with-gettext 打开gnu 的gettext 支持,编码库用到

错误一:
You’ve configured multiple SAPIs to be build. You can build only |
| one SAPI module and CLI binary at the same time.

./configure –prefix=/usr/local/php –with-sybase-ct=/usr –with-apxs2=/usr/local/apache2/bin/apxs –with-mysql –with-config-file-path=/usr/local/php/etc –with-iconv-dir=/usr/local/lib –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib –with-libxml-dir=/usr –enable-xml –disable-rpath –enable-bcmath –with-curl –with-curlwrappers –enable-mbregex –enable-mbstring –with-mcrypt –with-gd –enable-gd-native-ttf –with-openssl –with-mhash –enable-pcntl –enable-sockets –with-xmlrpc –enable-zip –enable-soap –without-pear

同样的编译的参数,5.4.0 可以,可是5.3.10却不行

错误二:
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
解决办法: 安装libmcrypt

错误三:
checking Checking for ctpublic.h… configure: error: ctpublic.h missing!
解决办法:编译安装freetds,并指定–with-sybase-ct的安装目录
# ./configure –prefix=/usr/local/freetds –with-tdsver=7.1 –enable-msdblib
# make
# make install
安装后执行/usr/local/freetds/bin/tsql -C 会显示安装成功的信息

错误四:configure: error: Cannot find ldap libraries in /usr/lib.
解析办法:
# whereis ldap
# ln -s /usr/include/ldap.h /usr/local/lib64/ldap.h

错误五:这个是在php5.3.10下编译的报错,如果在php5.4.0下不会有,原因可能是php5.4.10把mysql函数库加进去了
checking for specified location of the MySQL UNIX socket… no
configure: error: Cannot find MySQL header files under yes.
Note that the MySQL client library is not bundled anymore!
解决办法:换php5.4.10 或者编译安装mysql 指定mysql 扩展目录
./configure –prefix=/usr/local/php –with-sybase-ct=/usr/local/freetds –with-apxs2=/usr/local/apache2/bin/apxs –with-mysql –with-config-file-path=/usr/local/php/etc –with-iconv-dir=/usr/local/lib –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib –with-libxml-dir=/usr –enable-xml –disable-rpath –enable-bcmath –with-curl –with-curlwrappers –enable-mbregex –enable-mbstring –with-mcrypt –with-gd –enable-gd-native-ttf –with-openssl –with-mhash –enable-pcntl –enable-sockets –with-xmlrpc –enable-zip –enable-soap –without-pear –with-ldap –with-ldap-sasl
Generating files
configure: creating ./config.status
creating main/internal_functions.c
creating main/internal_functions_cli.c
+——————————————————————–+
| License: |
| This software is subject to the PHP License, available in this |
| distribution in the file LICENSE. By continuing this installation |
| process, you are bound by the terms of this license agreement. |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point. |
+——————————————————————–+

Thank you for using PHP.

config.status: creating php5.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating main/php_config.h
config.status: executing default commands

# make ZEND_EXTRA_LIBS=’-liconv’
# make install

===========================php5.4================================================================================================================

# ./configure –prefix=/usr/local/php –with-sybase-ct=/usr/local/freetds –with-apxs2=/usr/local/apache2/bin/apxs –with-pdo-mysql –with-mysql –with-config-file-path=/usr/local/php/etc –with-iconv-dir=/usr/local/lib –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib –with-libxml-dir=/usr –enable-xml –disable-rpath –enable-bcmath –with-curl –with-curlwrappers –enable-mbregex –enable-mbstring –with-mcrypt –with-gd –enable-gd-native-ttf –with-openssl –with-mhash –enable-pcntl –enable-sockets –with-xmlrpc –enable-zip –enable-soap –without-pear

===========================php5.3.10参数=========================================================================================================
# ./configure –prefix=/usr/local/php –with-sybase-ct=/usr/local/freetds –with-apxs2=/usr/local/apache2/bin/apxs –with-pdo-mysql=/usr/local/mysql –with-mysql=/usr/local/mysql –with-mysqli=/usr/local/mysql/bin/mysql_config –with-config-file-path=/usr/local/php/etc –with-iconv-dir=/usr/local/lib –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib –with-libxml-dir=/usr –enable-xml –disable-rpath –enable-bcmath –with-curl –with-curlwrappers –enable-mbregex –enable-mbstring –with-mcrypt –with-gd –enable-gd-native-ttf –with-openssl –with-mhash –enable-pcntl –enable-sockets –with-xmlrpc –enable-zip –enable-soap –without-pear

********************************************************** mysql*************************************************************
./configure –prefix=/usr/local/mysql/ –enable-assembler –with-extra-charsets=complex –enable-thread-safe-client –with-big-tables –with-readline –with-ssl –with-embedded-server –enable-local-infile –with-plugins=partition,innobase,myisammrg

@安装libiconv
#wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
#tar zxvf libiconv-1.14.tar.gz
#cd libiconv-1.14
#./configure –prefix=/usr/local ====这里的路径必须是这个,不然php编译会出错
#make && make install

@安装libmcrypt
#wget http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz
#tar zxvf libmcrypt-2.5.8.tar.gz
#cd libmcrypt-2.5.8
#./configure
#make && make install
#/sbin/ldconfig
#cd libltdl/
#./configure –enable-ltdl-install
#make & make install

@安装mhash
#wget http://downloads.sourceforge.net/mhash/mhash-0.9.9.9.tar.gz
#tar zxvf mhash-0.9.9.9.tar.gz
#cd mhash-0.9.9.9
#./configure
#make && make install
#cd ../
#ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
#ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
#ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
#ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
#ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
#ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
#ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
#ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
#ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
#ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config

@安装mcrypt
#wget http://nchc.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz
#tar zxvf mcrypt-2.6.8.tar.gz
#cd mcrypt-2.6.8
#./configure
#make && make install

运维手记:http://blog.mglog.net 编译安装php、apache常见参数及错误

编译安装php5.3.10与编译安装php5.4.10配置事项总结

编译安装php5.3.10与编译安装php5.4.10配置事项总结
由于本编译安装php,需要支持sybase扩展,但是加上了 –with-sybase-ct 这个参数,要么就要安装sybase,要么就要安装freetds,然后把目录指定freetds的安装目录,我的编译参数如下 :
#./configure –prefix=/usr/local/php –with-sybase-ct=/usr/local/freetds –with-apxs2=/usr/local/apache2/bin/apxs –with-mysql –with-config-file-path=/usr/local/php/etc –with-iconv-dir=/usr/local/lib –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib –with-libxml-dir=/usr –enable-xml –disable-rpath –enable-bcmath –with-curl –with-curlwrappers –enable-mbregex –enable-mbstring –with-mcrypt –with-gd –enable-gd-native-ttf –with-openssl –with-mhash –enable-pcntl –enable-sockets –with-xmlrpc –enable-zip –enable-soap –without-pear

1 httpd.conf
1) DirectoryIndex index.html index.php

2) 找到:Options Indexes FollowSymLinks
修改为:Options FollowSymLinks #不显示目录结构

3) 找到AllowOverride None
修改为:AllowOverride All #开启apache支持伪静态,有两处都做修改
LoadModule rewrite_module modules/mod_rewrite.so #取消前面的注释,开启apache支持伪静态

4) vi /etc/profile #添加apache服务系统环境变量
在最后添加下面这一行
export PATH=$PATH:/usr/local/apache2/bin
cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd #把apache加入到系统启动

5) vi /etc/init.d/httpd #编辑文件
在#!/bin/sh下面添加以下两行
#chkconfig:2345 10 90
#descrption:Activates/Deactivates Apache Web Server
chown daemon.daemon -R /usr/local/apache2/htdocs #更改目录所有者
chmod 700 /usr/local/apache2/htdocs -R #更改apache网站目录权限
chkconfig httpd on #设置开机启动
/etc/init.d/httpd start
service httpd restart

6)设置apache环境变量、系统自动启动
vi /etc/profile #添加apache服务系统环境变量
在最后添加下面这一行
export PATH=$PATH:/usr/local/apache2/bin

cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd #设置apache加入到系统启动
vi /etc/init.d/httpd #编辑文件
在#!/bin/bash下面添加以下两行
#chkconfig:2345 10 90
#descrption:Activates/Deactivates Apache Web Server

7) 网站用户
确保改目录为以下权限
chown daemon.daemon -R /usr/local/apache2/htdocs
chmod -R 700 /usr/local/apache2/htdocs

2 php.ini

1) cp php.ini-production /usr/local/php/etc/php.ini
vi /usr/local/php5/etc/php.ini
找到:;open_basedir =
修改为:open_basedir = .:/tmp/ #防止php木马跨站

2) 找到:;date.timezone =
修改为:date.timezone = PRC

3) error_reporting = E_ALL & ~E_NOTICE

******************************************** freetds *********************************************

[sybase_server] []内填的是服务名称,自己定义
host = 10.32.145.5 这里填的是主机IP
port = 5000 端口

这是php为了支持php_sybase_ct 函数连接以前老的sybase数据库,需要在freetds.conf 文件里配置以上参数

以上是编译安装php5.3.10与编译安装php5.4.10配置事项小小总结

运维手记:http://blog.mglog.net

编译安装mysql提示 Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock解决办法

编译安装mysql Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock解决办法

这种原因一般是因为系统已经默认安装了rpm的mysql ,所以在/etc/my.cnf 中的配置是不正确的,导致/tmp/mysql.sock 不存在
首先来备份一下/etc/my.cnf
# mv /etc/my.cnf my.cnf_bak
然后到mysql 源码目录下
# cd /home/mysql-5.1.62/support-files/

# cp my-medium.cnf /etc/my.cnf

# /usr/local/mysql/bin/mysql_install_db –user=mysql // 重新初始化,创建授权表
Installing MySQL system tables…
120404 14:32:01 [Warning] ‘–skip-locking’ is deprecated and will be removed in a future release. Please use ‘–skip-external-locking’ instead.
OK
Filling help tables…
120404 14:32:02 [Warning] ‘–skip-locking’ is deprecated and will be removed in a future release. Please use ‘–skip-external-locking’ instead.
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/local/mysql/bin/mysqladmin -u root password ‘new-password’
/usr/local/mysql/bin/mysqladmin -u root -h leak password ‘new-password’

Alternatively you can run:
/usr/local/mysql/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/local/mysql/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/local/mysql/bin/mysqlbug script!

#启动服务

# bin/mysqld_safe –user=mysql &

然后再连接就可以了

It is not safe to rely on the system’s timezone settings

Warning: phpinfo(): It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone ‘UTC’ for now, but please set date.timezone to select your timezone. in /usr/local/apache2/htdocs/m.php on line 2

打开php.ini 配置文件
找到
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
;date.timezone =

修改为:
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone =PRC

然后重启apache,警告提示就没有了!

编译安装php时,php5.3.10与php5.4的区别

在编译安装php时,我对比安装了php5.3.10与php5.4.0,可是有在使用相同的编译参数情况下,同一虚拟机,却有不同的效果
yum 安装一下所需要的库是不能少的
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers

使用下面相同的编译参数,得到的结果却不一样,因为也是在同一台虚拟环境
# ./configure –prefix=/usr/local/php –with-sybase-ct=/usr/local/freetds –with-apxs2=/usr/local/apache2/bin/apxs –with-pdo-mysql –with-mysql –with-config-file-path=/usr/local/php/etc –with-iconv-dir=/usr/local/lib –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib –with-libxml-dir=/usr –enable-xml –disable-rpath –enable-bcmath –with-curl –with-curlwrappers –enable-mbregex –enable-mbstring –with-mcrypt –with-gd –enable-gd-native-ttf –with-openssl –with-mhash –enable-pcntl –enable-sockets –with-xmlrpc –enable-zip –enable-soap –without-pear

下面是在5.3.10下的结果
checking for working const… yes
checking whether time.h and sys/time.h may both be included… yes
checking for working alloca.h… (cached) yes
checking for alloca… (cached) yes
checking for 8-bit clean memcmp… yes
checking for stdarg.h… (cached) yes
checking for mcrypt support… yes
checking for libmcrypt version… >= 2.5.6
checking for mcrypt_module_open in -lmcrypt… yes
checking for MSSQL support via FreeTDS… no
checking for MySQL support… yes
checking for specified location of the MySQL UNIX socket… no
configure: error: Cannot find libmysqlclient under /usr.
Note that the MySQL client library is not bundled anymore!

而把这个相同的参数放在5.4.10就可以了

Generating files
configure: creating ./config.status
creating main/internal_functions.c
creating main/internal_functions_cli.c
+——————————————————————–+
| License: |
| This software is subject to the PHP License, available in this |
| distribution in the file LICENSE. By continuing this installation |
| process, you are bound by the terms of this license agreement. |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point. |
+——————————————————————–+

Thank you for using PHP.

config.status: creating php5.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating main/php_config.h
config.status: executing default commands

下面是编译安装php的一些参数说明
with-config-file-path 指定php.ini位置

with-apxs2 整合 apache,apxs功能是使用mod_so中的LoadModule指令,加载指定模块到 apache,要求 apache 要打开SO模块

with-mysql mysql安装目录,对mysql的支持

with-mysqli mysqli文件目录,优化支持

with-iconv-dir iconv函数,对字符集间的转换

with-freetype-dir 打开对freetype字体库的支持

with-jpeg-dir 打开对jpeg图片的支持

with-png-dir 打开对png图片的支持

with-zlib 打开zlib库的支持

with-libxml-dir 打开libxml2库的支持

enable-xml 打开xml的支持

enable-inline-optimization 优化线程

with-curl 打开curl浏览工具的支持

with-curlwrappers 运用curl工具打开url流

enable-mbregex 打开对mbregex的支持

enable-mbstring 多字节,字符串的支持

with-mcrypt 算法

with-gd 打开gd库的支持

enable-gd-native-ttf 支持TrueType字符串函数库

with-openssl openssl的支持,加密传输时用到的

with-mhash 算法

enable-pcntl freeTDS需要用到的,可能是链接mssql 才用到

enable-sockets 打开 sockets 支持

with-ldap Include LDAP support

with-ldap-sasl LDAP: Include Cyrus SASL support

with-xmlrpc 打开xml-rpc的c语言

enable-zip 打开对zip的支持

enable-soap Enable SOAP support

with-gettext 打开gnu 的gettext 支持,编码库用到

CentOS6.2+nginx1.1.15+mysql5.6+php5.3.10

LNMP环境的搭建配置(CentOS6.2+nginx1.1.15+mysql5.6+php5.3.10)

一、安装前的准备
1、下载所需要的安装包
Nginx 下载: http://nginx.org/download/nginx-1.1.15.tar.gz (当前最新稳定版本)
Mysql下载:
http://mysql.mirrors.pair.com/Downloads/MySQL-5.6/mysql-5.6.4-m7.tar.gz (测试版)
http://mysql.cs.pu.edu.tw/Downloads/MySQL-5.5/mysql-5.5.21.tar.gz (稳定版,建议下载此彼)
php下载:http://cn.php.net/distributions/php-5.3.10.tar.gz (目前最新的版本是5.4的,但此版本已经是漏洞修复版)

2、首先对环境需要的库和编译工具进行安装
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers

二、安装过程
1、编译安装Mysql
1) 创建mysql安装目录及数据存放目录 
# mkdir -p /usr/local/mysql/
# mkdir -p /data/mysql/

2)创建用户和用户组与赋予数据存放目录权限
# groupadd mysql
# useradd mysql -M -s /sbin/nologin
# chown mysql.mysql -R /data/mysql/

3)安装必要的组件
# yum -y install cmake
# yum -y install ncurses-devel
4)开始编译安装Mysql
#cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk -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
# make
# make install

5)初始化数据库
# cd /usr/local/mysql
# scripts/mysql_install_db –user=mysql –basedir=/usr/local/mysql –datadir=/data/mysql/

6)配置环境
# cp support-files/my-medium.cnf /etc/my.cnf
# cp support-files/mysql.server /etc/init.d/mysql
# chmod 755 /etc/init.d/mysql
# chkconfig mysql on
# export PATH=/usr/local/mysql/bin:$PATH

7)启动并设置初始密码

# /etc/init.d/mysql start
# mysqladmin -uroot password ’123456′

进行再修改密码的语句
> UPDATE mysql.user SET Password = PASSWORD(‘newpwd’) WHERE User = ‘root’;(生新设置密码)
> flush privileges;(刷新权限)

2、 编译安装nginx
1) 添加一个不能登录并且没有主目录的用户
# useradd www -M -s /sbin/nologin
2) 下载必要的组件并安装
# wget http://nchc.dl.sourceforge.net/project/pcre/pcre/8.21/pcre-8.21.zip
# unzip pcre-8.21.zip
# cd pcre-8.21
# ./configure
# make && make install

3)下载编译安装nginx
# wget http://nginx.org/download/nginx-1.1.15.tar.gz
# tar zxvf nginx-1.1.15.tar.gz
# cd nginx-1.1.15
# ./configure –prefix=/usr/local/nginx –user=www –group=www –with-http_stub_status_module –with-http_ssl_module
# make && make install

4)启动nginx
# /usr/local/nginx/sbin/nginx
启动后,在浏览器里输入IP,即可查看到:Welcome to nginx!的欢迎界面

# echo “/usr/local/nginx/sbin/nginx” >> /etc/rc.local

4 编译安装php
1) 下载安装必要的组件
wget -c http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/mcrypt/libmcrypt-2.5.8.tar.gz 或者wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/mcrypt/mcrypt-2.6.8.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/memcache/memcache-2.2.5.tgz
wget http://blog.s135.com/soft/linux/nginx_php/mhash/mhash-0.9.9.9.tar.gz
wget http://cn.php.net/distributions/php-5.3.10.tar.gz
wget http://pear.php.net/go-pear.phar

# yum -y install libjpeg-devel libpng-devel

# tar zxvf libiconv-1.14.tar.gz
# cd libiconv-1.14
# ./configure
# make
# make install

# tar -zxvf libmcrypt-2.5.8.tar.gz
# cd libmcrypt-2.5.8
# ./configure
# make
# make install
# /sbin/ldconfig
# cd libltdl/
# ./configure –enable-ltdl-install
# make
# make install
# cd ../../

# tar zxvf mhash-0.9.9.9.tar.gz
# cd mhash-0.9.9.9
# ./configure
# make
# make install
# cd ../

ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config

# tar zxvf mcrypt-2.6.8.tar.gz
# cd mcrypt-2.6.8
# /sbin/ldconfig
#./configure
# make
# make install
# cd ../

2)编译安装php
# tar zxvf php-5.3.10.tar.gz
# cd php-5.3.10
# ./configure –prefix=/usr/local/php –with-config-file-path=/usr/local/php/etc –with-mysql=/usr/local/mysql –with-mysqli=/usr/local/mysql/bin/mysql_config –with-iconv-dir=/usr/local/lib –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib –with-libxml-dir=/usr –enable-xml –disable-rpath –enable-safe-mode –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –with-curl –with-curlwrappers –enable-mbregex –enable-fpm –enable-mbstring –with-mcrypt –with-gd –enable-gd-native-ttf –with-openssl –with-mhash –enable-pcntl –enable-sockets –with-ldap –with-ldap-sasl –with-xmlrpc –enable-zip –enable-soap –without-pear –with-fpm-user=www –with-fpm-group=www

# make ZEND_EXTRA_LIBS=’-liconv’
# make install

备注:在make ZEND_EXTRA_LIBS=’-liconv’ 这一步时,出错了,先是下面第一个错
①/home/Lnmp/php-5.3.10/sapi/cli/php: error while loading shared libraries: libiconv.so.2: cannot open shared object file: No such file or directory
make: *** [ext/phar/phar.php] 错误 127

②/home/Lnmp/php-5.3.10/sapi/cli/php: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
make: *** [ext/phar/phar.php] 错误 127
find / -name libmysqlclient.so.18
结果是在: /usr/local/mysql/lib/libmysqlclient.so.18
做个链接:ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/

3) 复制和修改php配置文件
# cp php.ini-production /usr/local/php/lib/php.ini 或是 /usr/local/lib/php.ini
# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
# /usr/local/php/bin/php –ini //测试ini文件是否加载

注:Nginx+PHP整合,在安装时必须启用–enable-fastcgi 和 –enable-fpm

5 环境测试,写一个phpinfo文件测试一下
http://192.168.1.108/index.php 访问一下