您的位置:首页 > 运维架构 > Nginx

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

2017-12-05 00:00 459 查看
linux相关

1、路径添加到环境变量

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

2、添加新用户

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

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

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

$du -h *

4、查看硬盘及分区

$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

5、cache缓存清除

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

#查看默认值 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.

php相关

1、查看php已有的扩展模块

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

2、启动php-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

3、查看php信息

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

4、查看php版本

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

5、phpize

phpize是用来扩展php扩展模块的,通过phpize可以建立php的外挂模块

$phpize

#编译
$./configure

#安装
$make && make install


nginx相关

1、查看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

2、检查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

3、启动nginx

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

$service nginx restart #重启

$nginx -s stop #停止
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: