进程相关

搜索某一个进程(以进程Server为例)

ps -ef | grep 进程名 # 根据进程名查看进程信息

netstat -tunlp | grep 端口号 # 根据端口查看对应进程,查看占用8080端口的进程id

举例

ps -ef | grep Server

netstat -tunlp | grep 8080

关闭进程

kill -9 端口号

举例:例如要关闭端口号为8088的进程

kill -9 8088

防火墙相关

放行端口

firewall-cmd --zone=public --add-port=4568/tcp --permanent   # 开放4568端口

firewall-cmd --zone=public --remove-port=4567/tcp --permanent #关闭4567端口

firewall-cmd --reload # 配置立即生效

基本命令

查看当前命令

pwd

用管理员权限打开文件管理器

sudo nautilus
chmod +x /etc/rc.d/init.d/xiaomiqiu_start.sh
cd /etc/rc.d/init.d
chkconfig --add xiaomiqiu_start.sh
sudo chkconfig --level 345 xiaomiqiu_start.sh on
sed -i 's/\r$//' xiaomiqiu_start.sh

sudo chmod +x /etc/rc.d/rc.local
sudo chmod +x /etc/rc.d/init.d/xiaomiqiu_start.sh
ps -ef | grep xiaomiqiu
(./xiaomiqiu -auth-token= 8fff3441a28b4df6847b19246fb02182 -log=stdout -log-level=info start-all &)

Nginx

刷新配置文件

nginx -t
nginx -s reload

#user nobody;
worker_processes 1;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;


events {
worker_connections 1024;
}


http {
include mime.types;
default_type application/octet-stream;

#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';

#access_log logs/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;

#gzip on;

upstream nginxboot{
# 30s内检查心跳发送两次包,未回复就代表该机器宕机,请求分发权重比为1:2
server 192.168.3.173:8778; #家里的IP地址
server 192.168.1.106:8778; #学校的IP地址
# 这里的IP请配置成你WEB服务所在的机器IP
}

server {
listen 80;
server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;
location / {
root html;
# 正常放行
index index.html index.htm;
proxy_pass http://nginxboot;
# 添加跨域支持
#CORS 配置
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE';
#是否允许cookie传输
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Headers' 'Authorization,Content-Type,Accept,Origin,User-Agent,DNT,Cache-Control,X-Mx-ReqToken,X-Data-Type,X-Requested-With,X-Data-Type,X-Auth-Token';

#针对浏览器的options预请求直接返回200,否则会被403 forbidden--invalie CORS request
# if ( $request_method = 'OPTIONS' ) {
# return 200;
# }
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}


# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;

# location / {
# root html;
# index index.html index.htm;
# }
#}


# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;

# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;

# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;

# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;

# location / {
# root html;
# index index.html index.htm;
# }
#}
}