导航:首页 > 程序命令 > centos7nginx重启命令

centos7nginx重启命令

发布时间:2023-06-01 06:16:49

‘壹’ centos中nginx怎么启动

Nginx的启动 /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf 其中-c参数指定配置文件路径。 Nginx的停止 Nginx支持以下几种信号控制: TERM, INT 快速关闭 QUIT 从容关闭 HUP 平滑重启 USR1 重新打开日志文件,在切割文件时用处大 USR2 平滑升级 WINCH 从容关闭工作进程 我们可以通过信号停止Nginx主进程,首先,我们需要通过ps-ef|grep命令获得master进程的PID,或者通过cat pid文件获得主进程号。

Nginx的启动

‘贰’ centos7.x设置nginx开机自启动

第一步:进入到/lib/systemd/system/目录

第二步:创建nginx.service文件,并编辑

Description:描述服务
After:描述服务类别
[Service]服务运行参数的设置
Type=forking是后台运行的形式
ExecStart为服务的具体运行命令
ExecReload为重启命令
ExecStop为停止命令
PrivateTmp=True表示给服务分配独立的临时空间
注意:[Service]的启动、重启、停止命令全此源部要求使核绝用绝对路径
[Install]运行级别下服务安装的相关设置,可设置为多用户,即系统运行级别为3

保存退出。
:wq

第三步:加入开机自启动

第四步:服务的启动/停止/刷新配置文件/查看状态

第五步 查看开改扒姿机启动项目

一个常见的错误
Warning: nginx.service changed on disk. Run 'systemctl daemon-reload' to reload units.
直接按照提示执行命令systemctl daemon-reload 即可。

‘叁’ centos 7.2 yum安装nginx 怎么重启

如果你nginx是rpm包安装的,直接用如下命令: nginx -V 如果你是源码编译安装,假如你的安装路径是/usr/local/nginx,那么你可以使用: /usr/local/nginx/sbin/nginx -V 注意是大写的V,这样你就可以看到nginx已经加载的模块了。

‘肆’ 如何在 centos 7/cpanel 服务器上配置 nginx 反向代理

注:本配置环境在CentOS下实现,其他方法请参考官方帮助文件

一、安装Nginx软件
Nginx官方网站:http://nginx.org
我们使用yum安装(配置和升级方便),需要配置官方的yum源,Nginx官方源配置提供的配置方法如下:

1.创建一个更新源
#vim /etc/yum.repos.d/nginx.repo

2.加入如下内容:
[nginx]
name=nginx repo baseurl=http://nginx.org/packages/OS/EOSRELEAS/$basearch/
gpgcheck=0
enabled=1

3.把上面蓝色字段换成的操作系统类型,比如rhel或者centos,把绿色部分替换成发行的主版本号,比如“5” 或者 “6”, 分别代表 5.x 或 6.x 对应的版本。

其他版本的系统(Debian/Ubuntu)也可以参考nginx官方的方法配置(英文内容)。

4.配置完以上三部,就可以开始用我们熟悉的yum命令安装nginx了(默认安装最新的nginx稳定发行版本)。
#yum install nginx

5.安装完毕看看都生成了哪些文件,配置文件都放在哪里
#rpm -ql nginx
/etc/logrotate.d/nginx
/etc/nginx
/etc/nginx/conf.d
/etc/nginx/conf.d/default.conf
/etc/nginx/conf.d/example_ssl.conf
/etc/nginx/fastcgi_params
/etc/nginx/koi-utf
/etc/nginx/koi-win
/etc/nginx/mime.types
/etc/nginx/nginx.conf
/etc/nginx/scgi_params
/etc/nginx/uwsgi_params
/etc/nginx/win-utf
/etc/rc.d/init.d/nginx
/etc/sysconfig/nginx
/usr/sbin/nginx
/usr/share/nginx
/usr/share/nginx/html
/usr/share/nginx/html/50x.html
/usr/share/nginx/html/index.html
/var/cache/nginx
/var/log/nginx

以上是我安装完的配置文件位置,安装的版本是1.4.2版本(查看版本:nginx -v) ,如下图:

6.检查是否安装成功
启动nginx服务,输入服务器ip访问是否能打开默认网站:
#service nginx restart

如果nginx服务启动成功,但打不开网站,排除如果不是网络问题,可能是因为iptables,iptables开放80端口即可:
#vim /etc/sysconfig/iptables
加入:-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT 如下图:

二、配置文件
1.由上面的步骤,我们看到配置文件放置在/etc/nginx/目录下:
主要配置文件:/etc/nginx/nginx.conf 内容如下图
扩展配置文件:/etc/nginx/conf.d/*.conf

图中的主配置文件的末尾,加载所有扩展配置文件里面以.conf结尾的文件。所以我们不要修改主要配置文件(不需要修改),用户配置都放到了/etc/nginx/conf.d/目录下,里面默认有两个配置文件,一个普通的配置,一个是ssl配置。

2.为一个域名配置一个文件(文件名任意,以.conf结尾即可)
#cd /etc/nginx/conf.d/
#vim www.test.com.conf
把内容修改如下:
---------------------------------------------------------------------------
server {
listen 80;
server_name www.test.com;

charset utf8;
access_log /var/log/nginx/www.test.com.access.log main;

location / {
proxy_pass http://192.168.1.20:80;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
---------------------------------------------------------------------------
如图:

3.重启nginx服务,检查配置文件并生效(nginx -t)
#service nginx restart

4.如果没出意外,你应该已经成功实现Nginx反向代理服务了!

三、其他帮助
1.帮助命令

2.官方帮助文档:http://nginx.org/en/docs/

‘伍’ centos7怎么编译安装nginx

安装环境为:最小化安装的centos7,关闭seliunx。
最小化安装centos:
关闭selinux
sed –i ‘s/SELINUX=enforcing/SELINUX=disabled/g’ /etc/selinux/config

开始安装nginx1.7.8
创建群组
groupadd www
创建一个用户,不允许登陆和不创主目录
useradd -s /sbin/nologin -g www -M www
#下载最新版nginx
wget -C http://nginx.org/download/nginx-1.7.8.tar.gz
tar zxvf nginx-1.7.8.tar.gz
#编译基本能运行的nginx
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_mole --with-http_ssl_mole --with-http_gzip_static_mole
make
make install

如果有错误提示:
./configure: error: C compiler cc is not found
解决方法:
yum install gcc gcc-c++

如果有错误提示:
./configure: error: the HTTP rewrite mole requires the PCRE library.
You can either disable the mole by using –without-http_rewrite_mole
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using –with-pcre=<path> option.
解决方法:
yum install pcre-devel

如果有错误提示:
./configure: error: SSL moles require the OpenSSL library.
You can either do not enable the moles, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using –with-openssl=<path> option.
解决方法:
yum install openssl-devel

以上错误提示依次解决后:再一次的运行
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_mole --with-http_ssl_mole --with-http_gzip_static_mole
make
meke install

编译参数解释:
#指定运行权限的用户
--user=www
#指定运行的权限用户组
--group=www
#指定安装路径
--prefix=/usr/local/nginx
#支持nginx状态查询
--with-http_stub_status_mole
#开启ssl支持
--with-http_ssl_mole
#开启GZIP功能
--with-http_gzip_static_mole

因此要顺利的通过nginx编译安装必须安装的依赖关系有:
yum install gc gcc gcc-c++ pcre-devel zlib-devel openssl-devel

2、在 centos7 中为nginx的启动、重启、重载配置添加脚本
nginx直接启动的方法:
/usr/local/nginx/sbin/nginx

但是不是很方便,因此使用下面的脚本来控制nginx的启动关闭重载更加合理一些。
编辑文件:vim /usr/lib/systemd/system/nginx.service 添加下面的脚本,注意路径 !
[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

systemctl的一些使用方法:
systemctl is-enabled servicename.service #查询服务是否开机启动
systemctl enable xxx.service #开机运行服务
systemctl disable xxx.service #取消开机运行
systemctl start xxx.service #启动服务
systemctl stop xxx.service #停止服务
systemctl restart xxx.service #重启服务
systemctl reload xxx.service #重新加载服务配置文件
systemctl status xxx.service #查询服务运行状态
systemctl --failed #显示启动失败的服务

因此,添加上面脚本后,centos7 中操作nginx的方法有
systemctl is-enabled nginx.service #查询nginx是否开机启动
systemctl enable nginx.service #开机运行nginx
systemctl disable nginx.service #取消开机运行nginx
systemctl start nginx.service #启动nginx
systemctl stop nginx.service #停止nginx
systemctl restart nginx.service #重启nginx
systemctl reload nginx.service #重新加载nginx配置文件
systemctl status nginx.service #查询nginx运行状态
systemctl --failed #显示启动失败的服务

‘陆’ linux centos7 怎么重启php-fpm

/etc/init.d/php-fpmstart
/etc/init.d/php-fpmstop
/etc/init.d/php-fpmrestart
/etc/init.d/php-fpmreload

‘柒’ centos7的服务启动命令是啥

service 服务名 start 不过,后面centos7 ,改成用systemctl了
在 centos7 版本中的 各项服务启动命令:
服务管理命令
1、Apache 服务管理命令启动:
systemctl start httpd关闭:
systemctl stop httpd重启:
systemctl restart httpd状态:
systemctl status httpd

阅读全文

与centos7nginx重启命令相关的资料

热点内容
喷油螺杆制冷压缩机 浏览:579
python员工信息登记表 浏览:377
高中美术pdf 浏览:161
java实现排列 浏览:513
javavector的用法 浏览:982
osi实现加密的三层 浏览:233
大众宝来原厂中控如何安装app 浏览:916
linux内核根文件系统 浏览:243
3d的命令面板不见了 浏览:526
武汉理工大学服务器ip地址 浏览:149
亚马逊云服务器登录 浏览:525
安卓手机如何进行文件处理 浏览:71
mysql执行系统命令 浏览:930
php支持curlhttps 浏览:143
新预算法责任 浏览:444
服务器如何处理5万人同时在线 浏览:251
哈夫曼编码数据压缩 浏览:426
锁定服务器是什么意思 浏览:385
场景检测算法 浏览:617
解压手机软件触屏 浏览:350