2018年10月

配置java

软件目录在 /soft/

cd /soft
tar zxvf jdk.tar.gz 
vim /etc/profile
/*加入如下代码*/
JAVA_HOME=/soft/jdk/
JAVA_BIN=/soft/jdk/bin
JRE_HOME=/soft/jdk/jre
CATALINA_BASE=/soft/tomcat
PATH=$PATH:/soft/jdk/bin:/soft/jdk/jre/bin:/soft/nginx/sbin:/soft/php/bin:/soft/php/sbin
CLASSPATH=/soft/jdk/jre/lib:/soft/jdk/lib:/soft/jdk/jre/lib/charsets.jar
/*然后esc :wq保存*/
 source /etc/profile
java -version

配置tomcat

cd /soft
tar zxvf tomcat.tar.gz
/soft/tomcat/bin/startup.sh
echo "/soft/tomcat/bin/startup.sh" >> /etc/rc.d/rc.local
chmod a+x /etc/rc.d/rc.local

配置nginx

wget https://nginx.org/download/nginx-1.15.5.tar.gz
tar zxvf nginx.tar.gz
cd ./src/nginx
./configure --prefix=/soft/nginx --with-http_ssl_module
yum -y install pcre pcre-devel
yum install -y zlib-devel
./configure --prefix=/soft/nginx
make
make install
nginx -version

安装PHP5.6

cd /soft
tar xzvf php.tar.gz
wget https://jaist.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.bz2
tar -xjvf libmcrypt-2.5.8.tar.bz2
cd /soft/libmcrypt-2.5.8
./configure
make && make install
cd /soft
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar -xzvf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local/libiconv
make && make install
yum  install  php-mcrypt  libmcrypt  libmcrypt-devel
cd /soft/php/
./configure --prefix=/soft/php --with-config-file-path=/soft/php/etc    --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=www   --enable-mysqlnd --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd   --enable-opcache --enable-mbstring --enable-soap --enable-zip --enable-bcmath --with-openssl   --with-zlib --with-curl --with-gd --with-zlib-dir=/usr/lib --with-png-dir=/usr/lib --with-jpeg-dir=/usr/lib   --with-mhash --with-freetype-dir --with-mcrypt --enable-gd-native-ttf   --with-xmlrpc --with-iconv-dir=/usr/local/libiconv
make
make install
/*加入:/soft/php/bin:/soft/php/sbin*/
vim /etc/profile
PATH=$PATH:/soft/jdk/bin:/soft/jdk/jre/bin:/soft/nginx/sbin:/soft/php/bin:/soft/php/sbin
source /etc/profile
 php -v
 
groupadd www
useradd php-fpm -M -s /sbin/nologin -g www

vim /soft/php/etc/php-fpm.conf
/*配置一下*/
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
;       will be used.
user = php-fpm
group = www
/*配置完毕*/
php-fpm -v

netstat -ltunp | grep 9000

nginx -s reload

/*PHP想关*/
chmod -R 777 /x4f_oa/www
php --ini

解决java验证码文字问题

yum groupinstall "Fonts"
/soft/tomcat/bin/catalina.sh stop
/soft/tomcat/bin/catalina.sh start

linux 命令行,ctrl+c退出当前命令

php-fpm的重启方法

启动方法 直接 **php-fpm**

php-fpm master 进程可以理解一下以下的信号:

   INT, TERM 立刻终止

   QUIT 平滑终止 

   USR1 重新打开日志文件

   USR2 平滑重载所有worker进程并重新载入配置和二进制模块

首先查看php-fpm 进程

ps -aux | grep php

root     14742  0.0  0.0 186456  5728 ?        Ss   Jul24   0:05 php-fpm: master process (/usr/local/php/conf/php-fpm.conf)
nginx    14743  0.0  0.0 186728  7656 ?        S    Jul24   0:00 php-fpm: pool www
nginx    14744  0.0  0.0 186728  7764 ?        S    Jul24   0:00 php-fpm: pool www
nginx    14745  0.0  0.0 186728  7656 ?        S    Jul24   0:00 php-fpm: pool www
nginx    14746  0.0  0.0 186728  7756 ?        S    Jul24   0:00 php-fpm: pool www
nginx    14747  0.0  0.0 186728  7660 ?        S    Jul24   0:00 php-fpm: pool www
nginx    14748  0.0  0.0 186728  7760 ?        S    Jul24   0:00 php-fpm: pool www
nginx    14749  0.0  0.0 186728  7756 ?        S    Jul24   0:00 php-fpm: pool www
nginx    14750  0.0  0.0 186456  5416 ?        S    Jul24   0:00 php-fpm: pool www
nginx    14751  0.0  0.0 186456  5416 ?        S    Jul24   0:00 php-fpm: pool www
nginx    14752  0.0  0.0 186728  7660 ?        S    Jul24   0:00 php-fpm: pool www
nginx    14753  0.0  0.0 186456  5416 ?        S    Jul24   0:00 php-fpm: pool www
nginx    14754  0.0  0.0 186456  5416 ?        S    Jul24   0:00 php-fpm: pool www
nginx    14755  0.0  0.0 186456  5416 ?        S    Jul24   0:00 php-fpm: pool www
nginx    14756  0.0  0.0 186728  7768 ?        S    Jul24   0:00 php-fpm: pool www
nginx    14757  0.0  0.0 186728  7660 ?        S    Jul24   0:00 php-fpm: pool www
root     19845  0.0  0.0 112708   964 pts/0    S+   10:41   0:00 grep --color=auto php

优雅的重启php-fpm:

kill -USR2 14742

OK了。

上面方案一般是没有生成php-fpm.pid文件时使用,如果要生成php-fpm.pid,使用下面这种方案:

上面master进程可以看到,matster使用的是/usr/local/php/etc/php-fpm.conf这个配置文件,cat /usr/local/php/etc/php-fpm.conf 发现:

[global]
; Pid file
; Note: the default prefix is /usr/local/php/var
; Default Value: none
;pid = run/php-fpm.pid

pid文件路径应该位于/usr/local/php/var/run/php-fpm.pid,由于注释掉,所以没有生成,我们把注释去除,再kill -USR2 42891 重启php-fpm,便会生成pid文件,下次就可以使用以下命令重启,关闭php-fpm了:

php-fpm 关闭:
kill -INT 'cat /usr/local/php/var/run/php-fpm.pid'
php-fpm 重启:
kill -USR2 'cat /usr/local/php/var/run/php-fpm.pid'
nginx重启:进入nginx可执行目录sbin下,输入命令**./nginx -s reload **即可。
php-fpm重启:killall php-fpm && /usr/local/php/sbin/php-fpm

我的主机的php-fpm.pid

[global]
; Pid file
; Note: the default prefix is /soft/php/var
; Default Value: none
pid = run/php-fpm.pid
/soft/php/var/run/php-fpm.pid

tomcat启动后访问非常慢 random改为urandom

原因是session计算的问题 可以看CSDN的文章
文件在java安装目录/soft/jdk/jre/lib/security/java.security

# In addition, if "file:/dev/random" or "file:/dev/urandom" is
# specified, the "NativePRNG" implementation will be more preferred than
# SHA1PRNG in the Sun provider.
#
securerandom.source=file:/dev/urandom