linux环境nginx、php相关的经常使用命令

  • linux相关

一、路径添加到环境变量php

$vi /etc/profile
#执行生效
$source /etc/profile

二、添加新用户node

#添加www用户并设置组
$useradd www

$chown -R www:www /home/www/src/testweb/

三、查看文件夹下各个文件的大小linux

$du -h *

四、查看硬盘及分区nginx

$lsblk
NAME   MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda    253:0    0  50G  0 disk 
└─vda1 253:1    0  50G  0 part /

$fdisk -l
Disk /dev/vda: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0005fc9a

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048   104857599    52427776   83  Linux

五、cache缓存清除web

对于小内存系统,常常发现cache被占满,致使系统很卡,可手动进行清理redis

#查看默认值 0
$cat /proc/sys/vm/drop_caches

#清除前将缓存内容写入到磁盘
$sync 
#写入参数值
$echo 3 > /proc/sys/vm/drop_caches

参数官方文档解释缓存

Writing to this will cause the kernel to drop clean caches, dentries and inodes from memory, causing that memory to become free.
To free pagecache:
* echo 1 > /proc/sys/vm/drop_caches
To free dentries and inodes:
* echo 2 > /proc/sys/vm/drop_caches
To free pagecache, dentries and inodes:
* echo 3 > /proc/sys/vm/drop_caches
As this is a non-destructive operation, and dirty objects are notfreeable, the user should run "sync" first in order to make sure allcached objects are freed.
This tunable was added in 2.6.16.swoole

  • php相关

一、查看php已有的扩展模块ide

$php -m #或/usr/local/php/bin/php -m

二、启动php-fpmphp-fpm

$service php-fpm start #或/usr/local/php/sbin/php-fpm 

$service php-fpm restart #重启

$service php-fpm stop #中止

$killall php-fpm #中止

$ps aux |grep php-fpm #查看php-fpm进程启动是否ok

三、查看php信息

#查看ini配置
$php --ini
#查看php信息
$php -i #可根据须要grep 或 php --info|grep swoole

四、查看php版本

$php -v #或/usr/local/php/bin/php -v

五、phpize

phpize是用来扩展php扩展模块的,经过phpize能够创建php的外挂模块

$phpize 

#编译
$./configure 

#安装
$make && make install
  • nginx相关

一、查看nginx版本

$nginx -v

#查看完成的nginx配置信息
$nginx -V
nginx version: nginx/1.12.2
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC) 
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --with-http_stub_status_module --with-pcre --with-http_ssl_module --with-http_gzip_static_module --with-http_gunzip_module --with-stream

二、检查ngix.conf配置文件

$nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successfu

三、启动nginx

$service nginx start #nginx -s reload 或/usr/local/nginx/sbin/nginx 或nginx

$service nginx restart #重启

$nginx -s stop #中止
  • redis相关

一、统计某个key值数量

redis-cli -p 6379 -h 192.168.10.234 -n 2 keys "kmads:km_wechat_subscribe:custom:*"|wc -l

相关文章
相关标签/搜索