Apache通过htaccess添加权限验证

参考文章:http://www.htaccesstools.com/articles/password-protection/

With .htaccess it is very easy to password protect a folder or directory. The method is called htaccess password protection or htaccess authentication, and works by uploading two files called .htaccess and .htpasswd in the directory you want to password protect. The htaccess file should contain the following:

AuthType Basic
AuthName "Password Protected Area"
AuthUserFile /path/to/.htpasswd
Require valid-user

You only need to change “/path/to/.htpasswd” with the full path to your .htpasswd. Take a look at my article on how to find the full path using PHP. Next you need to upload the .htpasswd file which contains the username and password to enter the password protected folder. The .htpasswd file should contain:

test:dGRkPurkuWmW2

The above code will allow the user “test” to access the password proteced area with the password “test”. The text “dGRkPurkuWmW2” is a encrypted version of the password. You will need to use a htpasswd generator to create another password. Each line in the .htpasswd file contains a username and password combination, so feel free to add as many combinations as you like.
The automatic way – Use the generator
You can also just use the htaccess authentication generator to create a htaccess file for password protection.

MySQL的ibdata1文件占用过大瘦身

参考文章:https://blog.csdn.net/qq_32448349/article/details/82965878

处理MySQL的ibdata1文件过大问题

本人在对数据库进行大量的数据插入和删除的时候,发现ibdata1的占了将近一个T

ibdata1文件是什么?

ibdata1是一个用来构建innodb系统表空间的文件,这个文件包含了innodb表的元数据、撤销记录、修改buffer和双写buffer。如果file-per-table选项打开的话,该文件则不一定包含所有表的数据。当innodb_file_per_table选项打开的话,新创建表的数据和索引则不会存在系统表空间中,而是存放在各自表的.ibd文件中.

显然这个文件会越来越大,innodb_autoextend_increment选项则指定了该文件每次自动增长的步进,默认是8M.

是什么原因导致ibdata1文件会越来越大?

ibdata1存放数据,索引和缓存等,是MYSQL的最主要的数据。所以随着数据库越来越大,表也会越大,这个无法避免的。如果时间长了,越来越大,我们在处理日志和空间的时候就不是那么方便了,就不知从何入手了。接下来我们就要处理下这样的情况,分库存储数据。

该如何处理呢?

首先我们把数据库文件备份下来,然后直接删除ibdata文件(为了保险起见最好先全备一次,做到数据安全和完整),然后再重新导入数据库文件即可!

具体操作步骤如下(截图并不完整,但是首先要弄懂大概情况和原理):

第一种方法:

1、停止业务,备份一次全库

mysqldump -uroot -ppassword –all-databases  > all_mysql.sql
2、备份完成,停止数据库

systemctl stop mariadb 或者 service mysqld stop
3、修改配置文件

在[mysqld]下增加下面配置 innodb_file_per_table=1 验证配置是否生效,可以重启mysql后,执行 #service mysqld restart
4、验证

mysql -uroot -ppassword mysql

show variables like ‘%per_table%’;

+———————–+——-+

| Variable_name | Value |

+———————–+——-+

| innodb_file_per_table | ON |

+———————–+——-+

1 row in set (0.00 sec)

innodb_file_per_table的状态变为ON

5、删除ibdata1文件和日志

rm -rf ibdata1

rm -rf ib_logfile*

6、还原数据库

mysql -uuser -ppassword

source all_mysql.sql

数据文件单独存放(共享表空间改为每个表独立的表空间文件)。

第二种方法:

把数据库的表引擎为InnoDB 的数据表转为MyIsam 后,删除ibdata1,按上面方法修改成独立的表空间,在把改成MyIsam引擎的表改为InnoDB,这个就要衡量那种方法的时间耗时最短,两者取其优。数据的表和库很多的通常不建议这么做,耗时间。

CentOS + Apache2.4 + PHP5.6 FPM报503错误

Service Unavailable 503错误,很可能的原因是服务器过载。

错误提示:

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

服务器使用Apache2.4,fpm方式加载PHP,因此排查解决过程如下。

1. 查看PHP-FPM日志
#tail -f /alidata/server/php56/var/log/php-fpm.log
WARNING: [pool www] server reached pm.max_children setting (5), consider raising it

2. 修改PHP-FPM配置
#vi /alidata/server/php56/etc/php-fpm.conf
pm.max_children = 5
​修改为
pm.max_children = 100

计算依据参考:https://blog.csdn.net/solmyr_biti/article/details/53955141
pm.max_children = Total RAM dedicated to the web server / Max child process size – in my case it was 85MB
The server has 8GB of RAM, so:
pm.max_children = 6144MB / 85MB = 72

CentOS Requires: libc.so.6(GLIBC_2.17)(64bit) 升级glibc到2.17

1、原先的系统glibc库的版本是2.12,需要升级到2.17版本。

下载地址:

http://ftp.gnu.org/gnu/glibc/glibc-2.17.tar.gz
这里可以选择你所需要的版本。

2、安装部署

[root@kafzook1 common]# tar -xf glibc-2.17.tar.gz
[root@kafzook1 common]# cd glibc-2.17
[root@kafzook1 glibc-2.17]# mkdir build; cd build
[root@kafzook1 build]# ../configure –prefix=/usr –disable-profile –enable-add-ons –with-headers=/usr/include –with-binutils=/usr/bin
[root@kafzook1 build]# make -j 8
[root@kafzook1 build]# make install
[root@kafzook1 common]# strings /lib64/libc.so.6 | grep GLIBC
会看到下面的结果
GLIBC_2.2.5
GLIBC_2.2.6
GLIBC_2.3
GLIBC_2.3.2
GLIBC_2.3.3
GLIBC_2.3.4
GLIBC_2.4
GLIBC_2.5
GLIBC_2.6
GLIBC_2.7
GLIBC_2.8
GLIBC_2.9
GLIBC_2.10
GLIBC_2.11
GLIBC_2.12
GLIBC_2.13
GLIBC_2.14
GLIBC_2.15
GLIBC_2.16
GLIBC_2.17
GLIBC_PRIVATE

我们可以看到部署成功后的glibc的版本为2.17

问题总结:

在上面安装的过程中我们可能会遇到下面的问题

1. Requires: libc.so.6(GLIBC_2.17)(64bit),升级glibc后,通过strings /lib64/libc.so.6 | grep GLIBC可查到GLIBC_2.17,但还是报错。

解决办法:通过yum clean all,yum makecache,yum update解决了

2. 百度了一下这个问题,说是这个变量后面有一个冒号“:”,我们打印一下这个变量查看一下果然有一个冒号。
他人博客地址:glibc问题解决方案

解决方案:找到这一环境变量,把后面的冒号+$LD_LIBRARY_PATH去掉,然后source一下。

我们看到后面的冒号已经没有了。

———————
作者:wyl9527
来源:CSDN
原文:https://blog.csdn.net/wyl9527/article/details/78256066
版权声明:本文为博主原创文章,转载请附上博文链接!

CentOS6.5 下Nginx 的安装与配置

原文链接:https://www.cnblogs.com/DanBrown/p/8005184.html

1.安装必须环境

nginx的编译需要c++,同时prce(重定向支持)和openssl(https支持)也需要安装。

请顺序安装依赖

1  yum install gcc-c++  
2  yum -y install pcre*  
3  yum -y install openssl*

2.,下载nginx-1.9.9.tar.gz,可放在 /usr/local/ 目录下   ps:我这里使用的老本你可以尝试新版

1  [root@admin ~]# cd /usr/local/  
2  [root@admin local]# wget http://nginx.org/download/nginx-1.9.9.tar.gz

3.解压及编译

1 [root@admin local]# tar -zxvf nginx-1.9.9.tar.gz

4.进入nginx目录

1 [root@admin local]# cd nginx-1.9.9

5.设置安装目录为 /usr/local/nginx

1 [root@admin nginx-1.9.9]# ./configure --prefix=/usr/local/nginx

开始编译安装

1  [root@admin nginx-1.9.9]# make  
2  [root@admin nginx-1.9.9]# make install

我这里是阿里服务器在(控制台)实例中配置一下端口,,本机中再开放一下80端口(不知道请查我的博客中有讲过如何开放指定端口);

 

 

 

启动nginx服务

进入安装目录 /usr/local/nginx

1 [root@admin ~]# cd /usr/local/nginx  
2 [root@admin sbin]# ./nginx

查看进程,可以看到nginx的master和worker进程

1     [root@admin sbin]# ps -ef | grep nginx  
2     root     32150     1  0 13:28 ?        00:00:00 nginx: master process ./nginx  
3     nobody   32151 32150  0 13:28 ?        00:00:00 nginx: worker process  
4     root     32154 28494  0 13:28 pts/1    00:00:00 grep nginx

可以通过访问ip:80测试,看到页面这样的提示就说明安装成功

重启的命令:

1 [root@admin sbin]# ./nginx -s reload

最后可以配置一下命令 添加nginx为系统服务(service nginx start/stop/restart)

1、在/etc/init.d/目录下编写脚本,新建名为nginx的文件然后把脚本代码粘贴进去 注意:配置 文件位置我的在usr/local/下若果不是这个路径你需要修改)

脚本代码

然后执行

2 [root@example ~]# chmod 755 /etc/init.d/nginx
3 [root@example ~]# chkconfig --add nginx

nginx启动、停止、无间断服务重启

1 [root@example ~]# service nginx start
2 
3 [root@example ~]# service nginx stop
4 
5 [root@example ~]# service nginx reload

好了蕾丝(@.@)

注补充:

  停止服务  查进程号之后 kill -9 进程号 即可.

CentOS6.5安装Zookeeper

原文地址:https://www.cnblogs.com/duenboa/articles/6665169.html

1. 下载安装文件zookeeper-3.4.6.tar.gz
2. 还是copy到虚拟机的centos系统桌面
3. 新建/usr/loca/zookeeper文件夹
[root@localhost ~]# mkdir -pv /usr/local/zookeeper
4.拷贝文件到指定文件夹
[root@localhost ~]# cd /root/Desktop/
[root@localhost ~]# cp ./zookeeper-3.4.6.tar.gz /usr/local/zookeeper
5. 解压
[root@localhost ~]# tar -zxvf jdk-8u121-linux-x64.tar.gz
6. 配置环境变量
[root@localhost ~]#cd /etc/
[root@localhost ~]#cp ./profile ./profile.bak — 把文件备份一下
[root@localhost ~]#vi /etc/profile — 编辑此配置文件
在文件末尾添加此段内容: — 开始和–中间的一段.(注意,尽量保持环境变量名全大写,下划线隔开. 保持规范)
— 开始
export ZOOKEEPER_INSTALL=/usr/local/zookeeper/zookeeper-3.4.6/
export PATH=$PATH:$ZOOKEEPER_INSTALL/bin
— 结束
7. 配置文件修改
[root@localhost zookeeper-3.4.6]# cd /usr/local/zookeeper/zookeeper-3.4.6/conf/ — 进入文件所在路径
[root@localhost conf]# cp zoo_sample.cfg zoo.cfg — 将zoo.sample.cfg拷贝出一份zoo.cfg出来. 文件名强制
8. 文件内容如下:
[root@localhost conf]# vi zoo.cfg — 按i进入编辑模式. 修改完成之后, esc退出编辑模式, 大写字母Z双击即可保存.
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/tmp/zookeeper — 这里要设置一下文件路径 路径必须存在,不存在的话就新建一个呗
dataLogDir=/tmp/zookeeper/log — 日志路径 路径必须存在,不存在的话就新建一个呗
# the port at which the clients will connect
clientPort=2181 — 如果是多机器的话,在clientPort处添加服务器的ip
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to “0” to disable auto purge feature
#autopurge.purgeInterval=1
修改完之后 通过 > # cat zoo.cfg 查看.
9. 开启服务,关闭服务, 查看
[root@localhost bin]# cd /usr/local/zookeeper/zookeeper.3.4.6/bin/
[root@localhost bin]# ./zkServer.sh stop — 停止服务
JMX enabled by default
Using config: /usr/local/zookeeper/zookeeper-3.4.6/bin/../conf/zoo.cfg
Stopping zookeeper … STOPPED
[root@localhost bin]# ./zkServer.sh start — 开启服务
JMX enabled by default
Using config: /usr/local/zookeeper/zookeeper-3.4.6/bin/../conf/zoo.cfg
Starting zookeeper … STARTED
[root@localhost bin]# ./zkServer.sh status — 查看状态
JMX enabled by default
Using config: /usr/local/zookeeper/zookeeper-3.4.6/bin/../conf/zoo.cfg
Mode: standalone
[root@localhost bin]#
[root@localhost bin]# ./zkCli.sh — 客户端启动, 可以查看启动状态和日志
Connecting to localhost:2181
2017-03-08 06:15:26,918 [myid:] – INFO [main:Environment@100] – Client environment:zookeeper.version=3.4.6-1569965, built on 02/20/2014 09:09 GMT
2017-03-08 06:15:26,923 [myid:] – INFO [main:Environment@100] – Client environment:host.name=localhost
2017-03-08 06:15:26,923 [myid:] – INFO [main:Environment@100] – Client environment:java.version=1.8.0_121
2017-03-08 06:15:26,925 [myid:] – INFO [main:Environment@100] – Client environment:java.vendor=Oracle Corporation
2017-03-08 06:15:26,926 [myid:] – INFO [main:Environment@100] – Client environment:java.home=/usr/local/java/jdk1.8.0_121/jre
2017-03-08 06:15:26,926 [myid:] – INFO [main:Environment@100] – Client environment:java.class.path=/usr/local/zookeeper/zookeeper-3.4.6/bin/../build/classes:/usr/local/zookeeper/zookeeper-3.4.6/bin/../build/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/slf4j-log4j12-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/slf4j-api-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/netty-3.7.0.Final.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/log4j-1.2.16.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/jline-0.9.94.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../zookeeper-3.4.6.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../src/java/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../conf:.:/usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib:.:/usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib:.:/usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib:
2017-03-08 06:15:26,926 [myid:] – INFO [main:Environment@100] – Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2017-03-08 06:15:26,926 [myid:] – INFO [main:Environment@100] – Client environment:java.io.tmpdir=/tmp
2017-03-08 06:15:26,926 [myid:] – INFO [main:Environment@100] – Client environment:java.compiler=<NA>
2017-03-08 06:15:26,930 [myid:] – INFO [main:Environment@100] – Client environment:os.name=Linux
2017-03-08 06:15:26,930 [myid:] – INFO [main:Environment@100] – Client environment:os.arch=amd64
2017-03-08 06:15:26,930 [myid:] – INFO [main:Environment@100] – Client environment:os.version=2.6.32-431.el6.x86_64
2017-03-08 06:15:26,931 [myid:] – INFO [main:Environment@100] – Client environment:user.name=root
2017-03-08 06:15:26,931 [myid:] – INFO [main:Environment@100] – Client environment:user.home=/root
2017-03-08 06:15:26,931 [myid:] – INFO [main:Environment@100] – Client environment:user.dir=/usr/local/zookeeper/zookeeper-3.4.6/bin
2017-03-08 06:15:26,940 [myid:] – INFO [main:ZooKeeper@438] – Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@277050dc
Welcome to ZooKeeper!
2017-03-08 06:15:27,039 [myid:] – INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@975] – Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error)
JLine support is enabled
2017-03-08 06:15:27,290 [myid:] – INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@852] – Socket connection established to localhost/0:0:0:0:0:0:0:1:2181, initiating session
[zk: localhost:2181(CONNECTING) 0] 2017-03-08 06:15:27,445 [myid:] – INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1235] – Session establishment complete on server localhost/0:0:0:0:0:0:0:1:2181, sessionid = 0x15aae45f1330000, negotiated timeout = 30000
WATCHER::
WatchedEvent state:SyncConnected type:None path:null
root@localhost bin]# ps -ef | grep zookeeper — 查看zookeeper的服务进程. 看样子还是挺嗨的.
root 9779 9774 0 05:26 pts/0 00:00:09 /usr/local/java/jdk1.8.0_121/bin/java -Dzookeeper.log.dir=. -Dzookeeper.root.logger=INFO,CONSOLE -cp /usr/local/zookeeper/zookeeper-3.4.6/bin/../build/classes:/usr/local/zookeeper/zookeeper-3.4.6/bin/../build/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/slf4j-log4j12-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/slf4j-api-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/netty-3.7.0.Final.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/log4j-1.2.16.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/jline-0.9.94.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../zookeeper-3.4.6.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../src/java/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../conf:.:/usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib:.:/usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib:.:/usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib: org.apache.zookeeper.ZooKeeperMain
root 10188 10183 0 06:14 pts/0 00:00:00 /usr/local/java/jdk1.8.0_121/bin/java -Dzookeeper.log.dir=. -Dzookeeper.root.logger=INFO,CONSOLE -cp /usr/local/zookeeper/zookeeper-3.4.6/bin/../build/classes:/usr/local/zookeeper/zookeeper-3.4.6/bin/../build/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/slf4j-log4j12-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/slf4j-api-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/netty-3.7.0.Final.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/log4j-1.2.16.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/jline-0.9.94.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../zookeeper-3.4.6.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../src/java/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../conf:.:/usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib:.:/usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib:.:/usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib: org.apache.zookeeper.ZooKeeperMain
root 10230 1 0 06:15 pts/1 00:00:01 /usr/local/java/jdk1.8.0_121/bin/java -Dzookeeper.log.dir=. -Dzookeeper.root.logger=INFO,CONSOLE -cp /usr/local/zookeeper/zookeeper-3.4.6/bin/../build/classes:/usr/local/zookeeper/zookeeper-3.4.6/bin/../build/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/slf4j-log4j12-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/slf4j-api-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/netty-3.7.0.Final.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/log4j-1.2.16.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/jline-0.9.94.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../zookeeper-3.4.6.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../src/java/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../conf:.:/usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false org.apache.zookeeper.server.quorum.QuorumPeerMain /usr/local/zookeeper/zookeeper-3.4.6/bin/../conf/zoo.cfg
root 10282 10277 0 06:15 pts/0 00:00:01 /usr/local/java/jdk1.8.0_121/bin/java -Dzookeeper.log.dir=. -Dzookeeper.root.logger=INFO,CONSOLE -cp /usr/local/zookeeper/zookeeper-3.4.6/bin/../build/classes:/usr/local/zookeeper/zookeeper-3.4.6/bin/../build/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/slf4j-log4j12-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/slf4j-api-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/netty-3.7.0.Final.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/log4j-1.2.16.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/jline-0.9.94.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../zookeeper-3.4.6.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../src/java/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../conf:.:/usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib:.:/usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib:.:/usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib: org.apache.zookeeper.ZooKeeperMain
root 10314 8885 0 06:18 pts/0 00:00:00 grep zookeeper
[root@localhost bin]#
10 到此, zookeeper的单机版安装完成.

Linux免密码登录设置

原文地址:https://blog.csdn.net/furzoom/article/details/79139570

假设要登录的机器为192.168.1.100,当前登录的机器为192.168.1.101。

首先在101的机器上生成密钥(如果已经生成可以跳过):

$ ssh-keygen -t rsa

一路回车即可。

然后在将生成的公钥复制到机器100上的~/.ssh/authorized_keys中,使用如下命令:

$ ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.1.100

root为需要登录到机器100上的身份,需要替换成需要的用户名。

最后,测试免密码登录:

$ ssh root@192.168.1.100

(完)

Centos6.6下编译安装最新apache

转载地址:http://www.linuxprobe.com/centos66-make-apache.html
安装编译环境
安装开发工具组
yum groupinstall 'Development tools'
仅安装需要的工具

因我的虚拟机是mini安装,配置aliyun的yum源家里小水管下载慢,就只装个gcc好了。

yum install gcc
下载源码包
下载最新版httpd

下载地址:http://httpd.apache.org/download.cgi#apache24

写此篇文章时最新版本为:httpd-2.4.27

在Centos6.6下编译安装最新apache在Centos6.6下编译安装最新apache

如果默认镜像下载太慢的话,可以在红框内选择其他国内镜像。

执行如下命令将源码包下载至Linux中并解压

wget https://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.27.tar.gz
tar -xf httpd-2.4.27.tar.gz
下载apr及apr-util

apr是Apache Portable Runtime的缩写,中文译为Apache可移植运行环境,是httpd所必须的,apr-util同理。

apr及apr-util下载地址:http://apr.apache.org/download.cgi

执行如下命令:

wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.6.2.tar.gz
wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.0.tar.gz
tar -xf apr-1.6.2.tar.gz
tar -xf apr-util-1.6.0.tar.gz

着手编译

首先编译apr
cd apr-1.6.2
./configure --prefix=/usr/local/apr  //指定安装位置
make && make install
编译apr-util
cd apr-util-1.6.0
./configure --with-apr=/usr/local/apr/ --prefix=/usr/local/apr-util  //指定apr所在目录及apr-util安装目录
make && make install

在这里会报一个错,如下所示

xml/apr_xml.c:35:19: error: expat.h: No such file or directory   //注意这一行,提示没有expat.h这个头文件
xml/apr_xml.c:66: error: expected specifier-qualifier-list before ‘XML_Parser’
......强行省略.....
xml/apr_xml.c: In function ‘do_parse’:
xml/apr_xml.c:434: error: ‘apr_xml_parser’ has no member named ‘xp’
.....不要看我......
xml/apr_xml.c:500: error: ‘apr_xml_parser’ has no member named ‘xp_err’
make[1]: *** [xml/apr_xml.lo] Error 1
make[1]: Leaving directory `/root/apr-util-1.6.0'
make: *** [all-recursive] Error 1

expat是解析XML的程序,是不是想立马执行yum install expat-devel呢?

然而我可以告诉你,然并卵!

不管是base库中的2.0版还是epel库中的2.1版在后面编译httpd的时候都会报错!

所以,我们去expat的官网去下载最新版的expat。

cd ~
wget https://nchc.dl.sourceforge.net/project/expat/expat/2.2.3/expat-2.2.3.tar.bz2
tar -xf expat-2.2.3.tar.bz2
cd expat-2.2.3
./configure --prefix=/usr/local/expat23
make && make install

现在可以重新编译apr-util了

cd ~
cd apr-util-1.6.0
./configure --with-apr=/usr/local/apr/ --with-expat=/usr/local/expat23/ --prefix=/usr/local/apr-util
make clean //因执行过一次编译了,保险起见把那些编译出来的东东删掉,虽然理论上并不影响
make && make install
编译httpd
cd ~
cd httpd-2.4.27
./configure --prefix=/alidata/server/httpd24 --sysconfdir=/alidata/server/httpd24/conf --with-mpm=prefork --enable-mpms-shared=all --enable-mods-shared=most --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/

到这一步会报错,提示我们没有装pcre,报错如下:

configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/

执行yum install pcre-devel即可

./configure --prefix=/alidata/server/httpd24 --sysconfdir=/alidata/server/httpd24/conf --with-mpm=prefork --enable-mpms-shared=all --enable-mods-shared=most --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/
make && make install

下面解释一下所用的选项:

  • –prefix=/usr/local/httpd24 :配置安装目录不用多说了吧?
  • –sysconfdir=/etc/httpd24:指定配置文件存放目录,默认存放到安装目录下
  • –with-mpm=prefork:默认mpm为prefork
  • –enable-mpms-shared=all:将所有mpm编译为.so模块
  • –enable-mods-shared=most:编译大多数模块为.so文件
  • –with-apr=/usr/local/apr:指定apr所在目录
  • –with-apr-util=/usr/local/apr-util/ : 指定apr-util所在目录

更多的./configure脚本选项请参考:http://httpd.apache.org/docs/2.4/programs/configure.html

测试新版httpd

首先将httpd2.4.27的bin目录加到PATH环境变量中以便执行命令~

echo "export PATH=$PATH:/usr/local/httpd24/bin" >> /etc/profile.d/httpd.sh
source /etc/rc.local

简单执行下面命令开启服务并测试:

apachectl start

打开浏览器–>访问192.168.123.233–>看到如下图说明安装成功

在Centos6.6下编译安装最新apache在Centos6.6下编译安装最新apache

上文所指报错

好吧,我没重现出错误情景….

如遇到类似如下报错,可自行编译expat

libaprutil-1.so: undefined reference to `XML_GetErrorCode'
新增编译时没有启用的模块
1. 进入apache源代码的modules/proxy目录
2. 运行如下命令自动编译、安装和修改httpd.conf文件,激活mod_proxy模块:
apachepath/bin/apxs -c -i -a mod_proxy.c proxy_util.c
apachepath/bin/apxs -c -i -a mod_proxy_http.c proxy_util.c
选项说明:
-c 执行编译操作
-i 安装操作,安装一个或多个动态共享对象到服务器的modules目录
-a 自动增加一个LoadModule行到httpd.conf文件,以激活此模块,若此行存在则启用之
-A 与-a类似,但是它增加的LoadModule行前有井号前缀(#)
-e 需要执行编辑操作,可与-a和-A选项配合使用,与-i操作类似,修改httpd.conf文件,但并不安装此模块
3. 重启apache。

PHP多版本共存:php5.6与php5.5共存

续:
php多版本共存,需要使用php-fpm来运行php方便,这样更方便配置和管理
准备工作:
创建PHP5.6的相关目录,不要与已安装的php5.5的目录相同

mkdir /alidata/server/php56  安装目录 
mkdir /alidata/server/php56/etc      配置文件存放目录

源码包下载:

wget http://cn2.php.net/distributions/php-5.6.30.tar.gz

解压,编译安装php

tar xvf php-5.6.30.tar.gz
cd php-5.6.30
所有配置参数与上一个php5.5的完全相同,只有安装的目录和配置文件目录不同。
./configure \
--prefix=/alidata/server/php56 \
--with-config-file-path=/alidata/server/php56/etc \
--with-apxs2=/alidata/server/httpd/bin/apxs \
--with-libdir=lib64
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-opcache \
--enable-fpm \
--with-fpm-user=www \
--with-fpm-group=www \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-mssql=/usr/local/freetds \
--with-pdo-dblib=/usr/local/freetds \
--with-gettext \
--enable-mbstring \
--with-iconv \
--with-mhash \
--with-openssl \
--enable-bcmath \
--enable-soap \
--with-libxml-dir \
--enable-pcntl \
--enable-shmop \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-sockets \
--with-curl \
--with-zlib \
--enable-zip \
--with-bz2 \
--with-gd \
--without-sqlite3 \
--without-pdo-sqlite \
--with-pear \
--with-mcrypt \
--with-freetype-dir=/usr/local/freetype.2.1.10 \
--with-jpeg-dir=/usr/local/jpeg.6

make && make install

若编译安装时遇到如下错误

/usr/local/src/php-5.3.10/ext/xmlrpc/libxmlrpc/encodings.c:73: undefined reference to `libiconv_open’ /usr/local/src/php-5.3.10/ext/xmlrpc/libxmlrpc/encodings.c:81: undefined reference to `libiconv’ /usr/local/src/php-5.3.10/ext/xmlrpc/libxmlrpc/encodings.c:101: undefined reference to `libiconv_close’ collect2: ld returned 1 exit status make: *** [sapi/fpm/php-fpm] 错误
在执行完 ./configure … 之后,修改下 Makefile,找到其中的
EXTRA_LIBS = -lcrypt -lz -lcrypt -lrt -lmysqlclient -lmcrypt -lldap -llber -lfreetype -lpng -lz -ljpeg -lcurl -lz -lrt -lm -ldl -lnsl -lrt -lxml2 -lz -lm -lssl -lcrypto -ldl -lz -lcurl -ldl -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lidn -lssl -lcrypto -lz -lxml2 -lz -lm -lssl -lcrypto -ldl -lz -lxml2 -lz -lm -lxml2 -lz -lm -lcrypt -lxml2 -lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lcrypt
在最后面添加 -liconv ,修改后如下
EXTRA_LIBS = -lcrypt -lz -lcrypt -lrt -lmysqlclient -lmcrypt -lldap -llber -lfreetype -lpng -lz -ljpeg -lcurl -lz -lrt -lm -ldl -lnsl -lrt -lxml2 -lz -lm -lssl -lcrypto -ldl -lz -lcurl -ldl -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lidn -lssl -lcrypto -lz -lxml2 -lz -lm -lssl -lcrypto -ldl -lz -lxml2 -lz -lm -lxml2 -lz -lm -lcrypt -lxml2 -lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lcrypt -liconv

配置php-fpm

拷贝配置文件,在安装目录里
cd /alidata/server/php56/etc
cp php-fpm.conf.default php-fpm.conf 
修改配置文件
vim php-fpm.conf
将listen = 127.0.0.1:9000 改为listen = 127.0.0.1:9056
与php5.59000端口区别开,防止端口冲突

拷贝服务脚本,在源码包里
# cp sapi/fpm/init.d.php-fpm /etc/init.d/php56-fpm
# chmod +x /etc/init.d/php56-fpm
# chkconfig --add php56-fpm

启动php-fpm

 service php56-fpm start
 监听端口为:9056

nginx 切换php版本只需修改nginx.conf即可
php5.5 php-fpm 监听端口为:9000
php5.6 php-fpm监听端口为:9056

vim /etc/nginx/nginx.conf
将fastcgi_pass   127.0.0.1:9000;修改为
  fastcgi_pass   127.0.0.1:9056;
  重启nginx,打开phpinfo

apache切换PHP版本:
由于之前是用php mod来运行php,php作为apache的一个模块来运行。如果想要使用多版本切换,就不能再用php mod来运行了,必须要用php-fpm运行,然后和Apache关联。

修改配置文件

vim /etc/httpd/httpd.conf

首先注释掉以下内容(这是用php mod与PHP关联的)

#LoadModule php5_module modules/libphp5.so
#<FilesMatch \.php$> 
   #SetHandler application/x-httpd-php
#</FilesMatch>

然后去掉以下两行的注释,开启代理功能

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so

再添加下面内容,使用php-fpm与PHP关联

<FilesMatch \.php$>
         SetHandler "proxy:fcgi://127.0.0.1:9056"
</FilesMatch>

重启apache服务,成功切换为php5.6
致此全部完成,nginx和apache全都可以正常切换PHP版本