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

相關文章
相關標籤/搜索