设为首页 收藏本站
查看: 1261|回复: 0

centos下LNMP搭建

[复制链接]

尚未签到

发表于 2015-11-16 10:25:59 | 显示全部楼层 |阅读模式
LNMP安装与配置



1.准备php函数的rpm包

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

2.准备lnmp其他的源代码包

wget http://blog.s135.com/soft/linux/nginx_php/nginx/nginx-0.8.46.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/php/php-5.2.14.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/phpfpm/php-5.2.14-fpm-0.5.14.diff.gz
wget http://blog.s135.com/soft/linux/nginx_php/mysql/mysql-5.5.3-m3.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/libiconv/libiconv-1.13.1.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/mcrypt/libmcrypt-2.5.8.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://blog.s135.com/soft/linux/nginx_php/pcre/pcre-8.10.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/eaccelerator/eaccelerator-0.9.6.1.tar.bz2
wget http://blog.s135.com/soft/linux/nginx_php/pdo/PDO_MYSQL-1.0.2.tgz
wget http://blog.s135.com/soft/linux/nginx_php/imagick/ImageMagick.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/imagick/imagick-2.3.0.tgz

3.安装php-5.2.14源代码包所需要的函数支持包

tar zxvf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1/
./configure --prefix=/usr/local
make
make install
cd ../
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure
make
make install
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/
./configure
make
make install
cd ../configure: error: *** libmcrypt was not found

export LD_LIBRARY_PATH=/usr/local/lib: LD_LIBRARY_PATH



4. 编译安装MySQL 5.5.3-m3

./configure --prefix=/usr/local/mysql --without-debug --enable-thread-safe-client --with-pthread --enable-assembler --enable-profiling --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --with-extra-charsets=all --with-plugins=all --with-mysqld-user=mysql --without-embedded-server --with-server-suffix=-community --with-unix-socket-path=/tmp/mysql.sock
make && make install
Useradd mysql
#创建mysql用户
Setfacl -m u:mysql:rwx -R /usr/local/mysql
Setfacl -m d:u:mysql:rwx -R /usr/local/mysql
#设置权限
/usr/local/mysql/bin/mysql_install_db --user=mysql
#安装mysql和test数据库
/usr/local/mysql/bin/mysqld_safe --user=mysql &
#启动mysql服务
/usr/local/mysql/bin/mysqladmin -uroot password "123"
#修改mysql登录密码为123
/usr/local/mysql/bin/mysql -uroot -p123
#用mysql登录
cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
#准备mysql配置文件
Vi /etc/my.cnf
default-character-set=utf8
#修改客户端和连接字符集
character-set-server=utf8
#修改服务器和数据库字符集
collation-server=utf8
#修改服务器校验字符集
pkill mysqld
/usr/local/mysql/bin/mysqld_safe --user=mysql &
#重启mysql服务让字符集生效make[2]: *** [do_abi_check] 错误 1

在configure完成之后,用VI打开Makefile,删掉do_abi_check:目标后的所有语句



5. 编译安装PHP(FastCGI模式)

tar zxvf php-5.2.14.tar.gz
gzip -cd php-5.2.14-fpm-0.5.14.diff.gz | patch -d php-5.2.14 -p1
#解压并打补丁,让php支持fpm来方便管理php-cgi进程
cd php-5.2.14/
./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 --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --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
make ZEND_EXTRA_LIBS='-liconv'
make install
cp php.ini-dist
/usr/local/php/etc/php.ini
cd ../

6.准备编译安装PHP5扩展模块

tar zxvf memcache-2.2.5.tgz
cd memcache-2.2.5/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
cd ../
tar jxvf eaccelerator-0.9.6.1.tar.bz2
cd eaccelerator-0.9.6.1/
/usr/local/php/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config
make && make install
cd ../
tar zxvf PDO_MYSQL-1.0.2.tgz
cd PDO_MYSQL-1.0.2/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql
make && make install
cd ../
tar zxvf ImageMagick.tar.gz
cd ImageMagick-6.5.1-2/
./configure
make && make install  
cd ../
tar zxvf imagick-2.3.0.tgz
cd imagick-2.3.0/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install  
cd ../

7. 修改php.ini文件,让php模块生效

cp /lnmp/php-5.2.14/php.ini-dist /usr/local/php/etc/php.ini
vi php.ini
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"
extension = "memcache.so"
extension = "pdo_mysql.so"
extension = "imagick.so"
再查找output_buffering = Off 修改为output_buffering = On
再查找; cgi.fix_pathinfo=0 修改为cgi.fix_pathinfo=0,防止Nginx文件类型错误解析漏洞

8. 在php.ini中配置eAccelerator加速PHP

mkdir -p /usr/local/eaccelerator_cache
#准备eaccelerator缓存目录
Vi php.ini
[eaccelerator]
zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size="64"
eaccelerator.cache_dir="/usr/local/eaccelerator_cache"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="3600"
eaccelerator.shm_prune_period="3600"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"

9.准备php-cgi和nginx进程执行者用户

Useradd nginx



10. 创建php-fpm配置文件- php-fpm.conf

vi /usr/local/php/etc/php-fpm.conf
<value name=&quot;display_errors&quot;>0</value>
#0改成1,页面上会输出错误日志
Unix user of processes
<value name=&quot;user&quot;>nginx</value>
Unix group of processes
<value name=&quot;group&quot;>nginx</value>
<value name=&quot;max_children&quot;>128</value>
#最大子进程数128,如果内存小于2G,则64个最佳
<value name=&quot;rlimit_files&quot;>65535</value>
# Set open file desc rlimit,同时打开的文件数,linux系统允许同时打开的文件数为1024,修改linux系统中允许同时打开的文件,ulimit -SHn 65535,而且这个参数重启后还能生效,加到/etc/profile全局配置文件的最后,开机就会生效,ulimit -a查看open files 65535
<value name=&quot;max_requests&quot;>1024</value>
#最大请求数, How much requests each process should execute before respawn.一个子进程能够回应1042个请求

11. 启动php-cgi(fastcgi)进程,监听127.0.0.1的9000端口,进程数为128(如果服务器内存小于3GB,可以只开启64个进程),用户为nginx:

/usr/local/php/sbin/php-fpm start
#启动php-cgi
/usr/local/php/sbin/php-fpm reload
#重新加载配置文件
/usr/local/php/sbin/php-fpm stop
#关闭php-fpm,此时nginx肯定不上php

12. 安装Nginx所需的pcre库

tar zxvf pcre-8.10.tar.gz
cd pcre-8.10/
./configure
make && make install
cd ../

13. 安装Nginx

tar zxvf nginx-0.8.46.tar.gz
cd nginx-0.8.46/
./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
make && make install
cd ../

14. 修改Nginx配置文件

vi /usr/local/nginx/conf/nginx.conf
user nginx nginx;
worker_processes 8;
#相当于cpu个数
error_log logs/nginx_error.log
pid /usr/local/nginx/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 65535;
events {
use epoll;
worker_connections 65535;
}
http {
include mime.types;
default_type application/octet-stream;
#charset gb2312;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 8m;
sendfile on;
tcp_nopush on;
keepalive_timeout 65;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
#limit_zone crawler $binary_remote_addr 10m;
server {
listen 80;
server_name test.com;
index index.html index.htm index.php;
root /www;
#limit_conn crawler 20;
location ~ .*\.(php|php5)?$ {
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
expires 30d;
}
location ~ .*\.(js|css)?$ {
expires 1h;
}
log_format access '$remote_addr - $remote_user [$time_local] &quot;$request&quot; '
'$status $body_bytes_sent &quot;$http_referer&quot; '
'&quot;$http_user_agent&quot; $http_x_forwarded_for';
access_log /data1/logs/access.log access;
}
}

15. 在/usr/local/nginx/conf/目录中创建fastcgi_params文件

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;



#建议把fastcgi_param写到nginx.conf中而不是把它写到fastcgi_params配置文件中,否则配置不够灵活,比如后面默认php设置和alias php设置中,他们的php页面的系统地址是不同的,比如:



默认php文件->/usr/local/nginx/html/index.php

Alias php文件->/mnt/bbs/index.php



这个时候你会发现fastcgi_params中的SCRIPT_FILENAME的&#20540;是相同的,这样会导致alias php的页面出不来,而配置在nginx.conf中各自配置各自的php系统地址,这样比较灵活.

#如果你觉得每个连接php的配置中都要加这一句话有点冗余,那就把它加入到fastcgi_params文件中,这样只需要加一次,其他所有的nginx.conf中的有关连接fastcgi的一块就不用加fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name这一句话了.



16.配置开机启动nginx,php-fpm,ulimit

1)nginx
Vi /etc/rc.local
/usr/local/nginx/sbin/nginx
2)php-fpm
Vi /etc/rc.local
/usr/local/php/sbin/php-fpm start
3)ulimit
Vi /etc/profile
Ulimit -SHn 65535

17.检查nginx配置文件语句错误

/usr/local/nginx/sbin/nginx -t



18.平滑重启nginx进程

1)Pkill -HUP nginx

2)kill -HUP `pgrep -uroot nginx`

3)/usr/local/nginx/sbin/nginx -s reload



19. 编写每天定时切割Nginx日志的脚本



1、创建脚本/usr/local/nginx/sbin/cut_nginx_log.sh

vi /usr/local/nginx/sbin/cut_nginx_log.sh
#!/bin/bash # This script run at 00:00
# The Nginx logs path
logs_path=&quot;/usr/local/nginx/logs/&quot;
mkdir -p ${logs_path}$(date -d &quot;yesterday&quot; +&quot;%Y&quot;)/$(date -d &quot;yesterday&quot; +&quot;%m&quot;)/
mv ${logs_path}access.log ${logs_path}$(date -d &quot;yesterday&quot; +&quot;%Y&quot;)/$(date -d &quot;yesterday&quot; +&quot;%m&quot;)/access_$(date -d &quot;yesterday&quot; +&quot;%Y%m%d&quot;).log
kill -USR1 `cat /usr/local/nginx/nginx.pid`

2、设置crontab,每天凌晨00:00切割nginx访问日志

crontab -e

00 00 * * * /bin/bash /usr/local/nginx/sbin/cut_nginx_log.sh



20.配置nginx虚拟主机

Vi /usr/local/nginx/conf/nginx.conf

server {
listen 80;
server_name www.test.com;
index index.html index.php index.htm;
root /web/baidu;
location ~ .*\.(php|php5)?$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
expires 30d;
}
#设置图片在客户端缓存时间为30days
location ~ .*\.(js|css)?$ {
expires 1h;
}
#设置js和css文件在客户端的缓存时间为1hour
log_format access '$remote_addr - $remote_user [$time_local] &quot;$request&quot; '
'$status $body_bytes_sent &quot;$http_referer&quot; '
'&quot;$http_user_agent&quot; $http_x_forwarded_for';
access_log logs/access.log access;
#自定义日志区域
}



21.列表页显示

location / {

autoindex on; #打开列表页

root html;

index index.html index.php index.htm;

}



22.虚拟目录设置

location /bbs{

alias /mnt/bbs/;

}

#这样配置html静态文件是可以出来的,但是php动态页面出不来,而且会浏览器的页面上会显示&quot; No input file specified. &quot;的报错,其实是php系统文件地址( SCRIPT_FILENAME)找不到,也就是说fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;中的$document_root$fastcgi_script_name不是真正的/mnt/bbs/index.php的地址,这可怎么解决:

location /bbs {

alias /mnt/bbs/;

index bbs.php index.html index.php;

}

location ~ ^/bbs/ {

root /mnt/;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

log_format bbs '$document_root$fastcgi_script_name ';

access_log logs/bbs.access.log bbs;

}

#后面两行是关于日志的,就是为了更好的观察由nginx提交给fastcgi的php的系统地址SCRIPT_FILENAME,在这里我用$request_filename来给SCRIPT_FILENAME赋&#20540;,在日志中的结果为/mnt/bbs/index.php,在这里我发现一个问题就是$request_filename中的root设置为/mnt,否则$request_filename的&#20540;为:/mnt/bbs/bbs/index.php.

由以上可以得到一个结论,就是默认php设置也可以这样设置关于SCRIPT_FILENAME:

location ~ \.php$ {

root html;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

log_format php '$document_root$fastcgi_script_name ';

access_log logs/php.access.log php;

}

#此时从日志中可以看到,$request_filename的&#20540;为/usr/local/nginx/html/index.php,而以前默认的/scripts$fastcgi_script_name显然是错的php系统地址,日志中显示为/scripts/index.php



23.nginx状态监控

location /nginxstatus{

stub_status on;

access_log off;

}

#客户端访问网址:http://www.test.com/nginxstatus

active connections – 活跃的连接数量

server accepts handled requests — 总共处理了111个连接 , 成功创建110次握手, 总共处理了110个请求

reading — 读取客户端的连接数.

writing — 响应数据到客户端的数量

waiting — 开启 keep-alive 的情况下,这个&#20540;等于 active – (reading&#43;writing), 意思就是 Nginx 已经处理完正在等候下一次请求指令的驻留连接.







24.rewrite正则过滤

location ~ \.php$ {

proxy_pass http://127.0.0.1;

}

Rewrite指令最后一项参数为flag标记,支持的flag标记如下:

Last 标示完成rewrite规则

Break 不再匹配后面的规则

Redirect 302临时重定向

Permanent 301永久重定向

Last和break用来实现uri重写,浏览器地址栏的url地址不变,但在服务器访问的路径发生了变化,redirect和permanent用来实现url跳转,浏览器地址栏会显示跳转后的url地址,使用alias指令时必须使用last标记,使用proxy_pass指令时要使用break标记,last标记在本条rewrite规则执行完毕后,会对其所在的server{}标签重新发起请求,而break标记则在本条规则匹配完成后,终止匹配,不再匹配后面的规则.

在匹配的过程中,nginx将首先匹配字符串,然后再匹配正则表达式,匹配到第一个正则表达式后,会停止搜索,如果匹配到正则表达式,则使用正则表达式的搜索结果,如果没有匹配到正则表达式,则使用字符串的搜索结果.

可以使用前缀&quot;^~&quot;来禁止匹配到字符串后,再去检查正则表达式,匹配到url后,将停止查询.

使用前缀&quot;=&quot;可以进行精确的url匹配,如果找到匹配的uri,则停止查询,例如&quot;location=/&quot;,只能匹配到&quot;/&quot;,而&quot;/test.html&quot;则不能被匹配.

正则表达式的匹配,按照它们在配置文件中的顺序进行,写在前面的优先.

Location = / {

#仅仅匹配 /

[configuration A]

}

Location / {

#匹配任何以/开头的查询,但是正则表达式及较长的字符串(/bbs/)将被优先匹配.

[configuration B]

}

Location ^~ /images/ {

#匹配任何以/images/开头的字符串,并且停止搜索,所以正则表达式将不会被检查.

[configuration C]

}

Location ~* \.(gif|jpg|jpeg)$ {

#匹配以.gif、.jpg、.jpeg结尾的任何请求,但是,/images/内的请求将使用configuration c的配置

[configuratoin D]

}

请求处理匹配结果示例:

/ -> configuration A;

/documents/document.html -> configuration B;

/images/1.gif -> configuration c;

/documents/1.jpg -> configuration D;



26.模块设置

Error_log
#错误日志
Include
#包含子配置文件,0.6版本以后子配置文件放在nginx.conf所在的路径下
Pid
#主进程id号
User
#nginx nginx表明nginx进程的执行者和组
Worker_processes
#与cpu个数相同,4核cpu为4
Worker_rlimit_nofile 65535
#打开的文件描述符,不过提前得设置ulimit -SHn 65535,即linux允许的打开文件个数
Worker_connectiones 65535
#客户端最大连接数65535
Alias
#虚拟目录
Error_page
#404,500错误跳转页面
Index
#index index.html,设置默认首页
Keepalive_timeout
#即tcp持续连接超时时间
Limit_rate
#limit _rate 100k,即限速为100KB/s
Limit_rate_after
#limit_rate_after 1m,即下载文件超过1m,则进入limit_rate限速阶段
Listen
#listen 192.168.100.1:80,即设置ip和端口
Location
#该指令允许对不同的uri进行不同的配置,可以是字符串、正则表达式
Resolver
#resolver 8.8.8.8,为nginx设置dns域名指向
Root
#设置网站根目录
Send_timeout
#超时时间是指进行了两次tcp握手,还没有转为established状态的时间,如果超过这个时间,客户没有响应,nginx则关闭连接,可以用来防止ddos攻击
Sendfile
#启用或禁用sendfile()函数,作用于拷贝两个文件描述符之间的操作函数,这个拷贝是在内核中操作的,比read和write拷贝高效得多
Server
#普通web配置或虚拟主机的配置的区域
Server_name
#根据客户端请求header头信息中的host域名,来匹配该请求应该由哪个虚拟主机配置或服务器的ip
Tcp_nodelay
#封装tcp/ip数据包的等待时间,也叫纳格算法,在keepalive开启才有用
Tcp_nopush
#要求sendfile开启的时候才起作用,设置该选择的原因是nginx在linux上,试图在一个包中发送它的httpd应答头
Allow
#allow 192.168.100.254,只允许192.168.100.254访问
Deny
#deny all,拒绝其他任何人访问
Autoindex
#autoindex on,即开启列表页功能
Charset
#charset utf8;source_charset gbk,把服务器上的gbk网页编码转换成utf8输出给客户端
Fastcgi_pass
#fastcgi_pass 127.0.0.1:9000;
#fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
#include fastcgi_params;
#fastcgi_pass后跟的是php-cgi进程的ip和端口
Access_log
#正确日志
Proxy_pass
# proxy_pass http://myweb1,即后跟的是nginx代理负载池upstream中的服务器
Proxy_set_header
# proxy_set_header Host $host,设置把$host带给后端的nginx服务器
Proxy_temp_path
#用户指定一个本地目录缓冲较大的代理请求,类似于client_body_temp_path
Stub_status
# stub_status on,即开户状态监控
Image_filter
#它指定适用于图片的转换类型



PHP-version > 5.3.3:



在./configure 时 加上
--enable-fpm
使用PHP-FPM来控制PHP-CGI的FastCGI进程

/usr/local/php/sbin/php-fpm{start|stop|quit|restart|reload|logrotate}
--start 启动php的fastcgi进程
--stop 强制终止php的fastcgi进程
--quit 平滑终止php的fastcgi进程
--restart 重启php的fastcgi进程
--reload 重新平滑加载php的php.ini
--logrotate 重新启用log文件

或者:



master进程可以理解以下信号



INT, TERM 立刻终止 QUIT 平滑终止 USR1 重新打开日志文件 USR2 平滑重载所有worker进程并重新载入配置和二进制模块



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`



查看php-fpm进程数:

ps aux | grep -c php-fpm





命令行下执行php,提示找不到命令

-bash: /usr/bin/php: No such file or directory

vi /etc/profile



在文件底部增加一行配置

export PATH=/usr/local/php/bin:$PATH

source /etc/profile

版权声明:本文为博主原创文章,未经博主允许不得转载。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-139820-1-1.html 上篇帖子: lnmp加入mongodb支持(pecl no found,php-config not found) 下篇帖子: ubuntu 12.04 LNMP 配置
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表