(二)centos 常用命令和安装

来源:互联网 发布:传奇db数据库详解 编辑:程序博客网 时间:2024/06/05 17:29
安装   yum install screen
           yum install wget
           yum install pcre
           yum install openssl*

 查看/编辑 网络配置 vi /etc/sysconfig/network-scripts/ifcfg-eno16777736 

重启网络配置 service network restart 

切换用户 su root

在Centos中yum安装和卸载软件的使用方法
安装方法
安装一个软件时
yum -y install httpd
安装多个相类似的软件时
yum -y install httpd*
安装多个非类似软件时
yum -y install httpd php php-gd mysql
卸载一个软件时
yum -y remove httpd
卸载多个相类似的软件时
yum -y remove httpd*
卸载多个非类似软件时
yum -y remove httpd php php-gd mysql

查看端口是否开启
netstat -an |grep 443
netstat -lntp 查看监听(Listen)的端口
netstat -antp #查看所有建立的TCP连接
停掉防火墙
service iptables stop
查看是否安装
whereis nginx

执行命令找到nginx路径
ps aux | grep nginx

显示进程

ps -ef |grep nginx  

杀死进程

kill -HUP 主进程号或进程号文件路径


kill -SIGUSR2 PID

# top //找出CPU使用率高的进程PID
# strace -p PID //跟踪进程
# ll /proc/PID/fd //查看该进程在处理哪些文件
将有可疑的PHP代码修改之,如:file_get_contents没有设置超时时间。


启动ngin

cd usr/local/nginx/sbin
./nginx

重启ngin

cd /usr/local/nginx/sbin
./nginx -s reload

强制停止

pkill -9 nginx

验证ngin配置文件正确

cd /usr/local/nginx/sbin

./nginx -t

查看服务器进程使用情况 

top    shift+p 按cpu排序   shift+m 按内存排序  


查看所有进程

ps -ef


查看服务器版本

lsb_release -a

cat /etc/redhat-release

cat /etc/issue


登录mysql

mysql -u root -p


linux 所有配置文件目录

在etc文件

/bin/systemctl start  iptables.service  开启防火墙

可以实时的得到新追加到文件中的信息,常用来跟踪日志文
tail -f  17_05_05.log


mysql 远程访问不行解决方法 Host is not allowed to connect to this MySQL server

如果你想连接你的mysql的时候发生这个错误:

ERROR 1130: Host ‘192.168.1.3’ is not allowed to connect to this MySQL server

解决方法:1。 改表法。可能是你的帐号不允许从远程登陆,只能在localhost。这个时候只要在localhost的那台电脑,登入mysql后,更改 “mysql” 数据库里的 “user” 表里的 “host” 项,从”localhost”改称”%”

mysql -u root -pvmwaremysql>use mysql;mysql>update user set host = ‘%’ where user = ‘root';mysql>select host, user from user;

2. 授权法。例如,你想myuser使用mypassword从任何主机连接到mysql服务器的话。

GRANT ALL PRIVILEGES ON *.* TO ‘myuser’@’%’ IDENTIFIED BY ‘mypassword’ WITH GRANT OPTION;

如果你想允许用户myuser从ip为192.168.1.3的主机连接到mysql服务器,并使用mypassword作为密码

GRANT ALL PRIVILEGES ON *.* TO  ‘root’@’192.168.1.3′ IDENTIFIED BY ‘mypassword’ WITH GRANT OPTION;

GRANT ALL PRIVILEGES ON *.* TO ‘root’@’10.10.40.54′ IDENTIFIED BY ‘123456’ WITH GRANT OPTION;


0 0
原创粉丝点击