【开发基础】nginx/postgresql/php/redis/ssdb的启动/关闭/重启命令及配置文件修改

【开发基础】nginx/postgresql/php/redis/ssdb的启动/关闭/重启命令及配置文件修改

小破孩
2025-07-30 / 0 评论 / 3 阅读 / 正在检测是否收录...

以下是 Nginx、PostgreSQL、PHP、Redis 和 SSDB 在 Linux 系统下的常用管理命令及配置文件位置总结:

1. Nginx

启动/关闭/重启

# 使用 systemd(CentOS 7+/Ubuntu 16.04+)
systemctl start nginx      # 启动
systemctl stop nginx       # 停止
systemctl restart nginx    # 重启
systemctl reload nginx     # 重新加载配置
systemctl status nginx     # 查看状态

# 使用 service(旧版系统)
service nginx start|stop|restart|reload

# 直接调用 nginx 命令(需 root 权限)
nginx                      # 启动
nginx -s stop              # 快速停止
nginx -s quit              # 优雅停止
nginx -s reload            # 重新加载配置

配置文件

  • 主配置文件/etc/nginx/nginx.conf
  • 站点配置目录/etc/nginx/conf.d//etc/nginx/sites-enabled/
  • 修改后检查配置并重启

    nginx -t                 # 检查配置语法
    systemctl reload nginx   # 重新加载配置

2. PostgreSQL

启动/关闭/重启

# 使用 systemd
systemctl start postgresql-<版本号>  # 启动(如:postgresql-14)
systemctl stop postgresql-<版本号>   # 停止
systemctl restart postgresql-<版本号> # 重启
systemctl status postgresql-<版本号>  # 查看状态

# Ubuntu/Debian 通用命令
systemctl start|stop|restart postgresql

# 手动控制(需切换到 postgres 用户)
sudo -u postgres pg_ctl -D /var/lib/pgsql/<版本号>/data start|stop|restart

配置文件

  • 主配置文件/var/lib/pgsql/<版本号>/data/postgresql.conf
  • 认证配置/var/lib/pgsql/<版本号>/data/pg_hba.conf
  • 修改后重启服务

    systemctl restart postgresql-<版本号>

3. PHP-FPM

启动/关闭/重启

# 使用 systemd(PHP-FPM 通常作为 FastCGI 进程管理器)
systemctl start php-fpm        # 启动(CentOS/RHEL)
systemctl start php<版本号>-fpm # 启动(Ubuntu/Debian,如:php8.1-fpm)
systemctl stop|restart|status php-fpm

# 直接调用 php-fpm 命令
php-fpm -D                     # 后台启动
php-fpm -t                     # 检查配置语法
kill -USR2 `cat /run/php-fpm.pid`  # 优雅重启

配置文件

  • 主配置文件/etc/php-fpm.conf/etc/php/<版本号>/fpm/php-fpm.conf
  • 池配置目录/etc/php-fpm.d//etc/php/<版本号>/fpm/pool.d/
  • PHP .ini 文件/etc/php.ini/etc/php/<版本号>/fpm/php.ini
  • 修改后重启服务

    systemctl restart php-fpm

4. Redis

启动/关闭/重启

# 使用 systemd
systemctl start redis          # 启动
systemctl stop redis           # 停止
systemctl restart redis        # 重启
systemctl status redis         # 查看状态

# 手动启动(需指定配置文件)
redis-server /etc/redis.conf   # 前台启动
redis-server /etc/redis.conf & # 后台启动

# 关闭 Redis(通过客户端)
redis-cli shutdown

配置文件

  • 主配置文件/etc/redis.conf
  • 修改后重启服务

    systemctl restart redis

5. SSDB

启动/关闭/重启

# 使用 systemd(需手动创建 service 文件)
systemctl start ssdb           # 启动
systemctl stop ssdb            # 停止
systemctl restart ssdb         # 重启

# 手动控制(通过 ssdb-server 命令)
/opt/ssdb/ssdb-server /opt/ssdb/ssdb.conf -d  # 后台启动
/opt/ssdb/ssdb-cli -h 127.0.0.1 -p 8888 shutdown  # 关闭

配置文件

  • 主配置文件/opt/ssdb/ssdb.conf
  • 修改后重启服务

    systemctl restart ssdb

注意事项

  1. 路径差异:不同 Linux 发行版或安装方式(源码/包管理器)可能导致配置文件路径不同,建议通过 whereisfind 命令查找。
  2. 权限问题:操作服务时需确保用户有足够权限(如使用 sudo)。
  3. 配置检查:修改配置文件后,建议先检查语法再重启服务。
  4. 版本兼容性:部分命令可能因软件版本不同而略有差异。
0

评论 (0)

取消