centos7通过yum安装nginx
centos7通过yum安装nginx
nginx不支持centos7通过yum直接安装~~~
1、查看操作系统位数
[root@-jenkins ~]# rpm -aq|grep centos-release
centos-release-7-4.1708.el7.centos.x86_64/
2、创建nginx的yum源
[root@-jenkins ~]# cat /etc/yum.repos.d/nginx.repo
[nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/7/x86_64/ gpgcheck=0 enabled=1
注意:上面的x86_64改为你自己的操作系统位数。
3、yum命令安装
[root@-jenkins ~]# yum install -y nginx
4、启动服务
[root@-jenkins ~]# service nginx start
或者
[root@-jenkins ~]# systemctl start nginx
Redirecting to /bin/systemctl start nginx.service
You have new mail in /var/spool/mail/root
5、查看端口默认为80
[root@-jenkins ~]# ss -lntp|grep 80
LISTEN 0 128 *:80 *:* users:(("nginx",pid=23806,fd=6),("nginx",pid=23805,fd=6))
6、发布路径
[root@-jenkins ~]#/usr/share/nginx/html/
访问: http://IP
日志切割
vim /etc/logrotate.d/nginx
/var/log/nginx/*.log { daily missingok rotate 52 compress delaycompress notifempty create 644 root root #日志权限 sharedscripts postrotate if [ -f /var/run/nginx.pid ]; then kill -USR1 `cat /var/run/nginx.pid` fi endscript }
如对您有帮助,支持下呗!
微信
支付宝