Step #1: Install nginx repo
Type the following wget command to install nginx yum configuration file:# cd /tmp
CentOS Linux v6.x user type the following command:# wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
# rpm -ivh nginx-release-centos-6-0.el6.ngx.noarch.rpm
RHEL v6.x user type the following command:# wget http://nginx.org/packages/rhel/6/noarch/RPMS/nginx-release-rhel-6-0.el6.ngx.noarch.rpm
# rpm -ivh nginx-release-rhel-6-0.el6.ngx.noarch.rpm
Sample outputs:
warning: nginx-release-rhel-6-0.el6.ngx.noarch.rpm: Header V4 RSA/SHA1 Signature, key ID 7bd9bf62: NOKEY Preparing... ########################################### [100%] 1:nginx-release-rhel ########################################### [100%]
Step #2: Install nginx web-server
Type the following yum command to install nginx web-server:# yum install nginx
Sample outputs:
Loaded plugins: product-id, rhnplugin, security, subscription-manager Updating certificate-based repositories. Unable to read consumer identity nginx | 1.3 kB 00:00 nginx/primary | 4.8 kB 00:00 nginx 33/33 Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package nginx.x86_64 0:1.2.6-1.el6.ngx will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: nginx x86_64 1.2.6-1.el6.ngx nginx 361 k Transaction Summary ================================================================================ Install 1 Package(s) Total download size: 361 k Installed size: 835 k Is this ok [y/N]: y Downloading Packages: nginx-1.2.6-1.el6.ngx.x86_64.rpm | 361 kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Warning: RPMDB altered outside of yum. Installing : nginx-1.2.6-1.el6.ngx.x86_64 1/1 ---------------------------------------------------------------------- Thanks for using NGINX! Check out our community web site: * http://nginx.org/en/support.html If you have questions about commercial support for NGINX please visit: * http://www.nginx.com/support.html ---------------------------------------------------------------------- Installed products updated. Verifying : nginx-1.2.6-1.el6.ngx.x86_64 1/1 Installed: nginx.x86_64 0:1.2.6-1.el6.ngx Complete!
Step #3: Turn on nginx service
Type the following command:
# chkconfig --add nginx
# chkconfig nginx on
How do I start / stop / restart nginx web-server?
Type the following commands:# service nginx start
# service nginx stop
# service nginx restart
# service nginx status
# service nginx reload
Step #4: Configuration files
- Default configuration directory: /etc/nginx/
- Default SSL and vhost config directory: /etc/nginx/conf.d/
- Default log file directory: /var/log/nginx/
- Default document root directory: /usr/share/nginx/html
- Default configuration file: /etc/nginx/nginx.conf
- Default server access log file: /var/log/nginx/access.log
- Default server access log file: /var/log/nginx/error.log
To edit the nginx configuration file, enter:# vi /etc/nginx/nginx.conf
Set or update worker_processes as follows (this must be set to CPU(s) in your system. Use the lscpu | grep '^CPU(s)' command to list the number of CPUs in the server)
worker_processes 2;
Turn on gzip support:
gzip on;
Save and close the file. Edit the file /etc/nginx/conf.d/default.conf, enter:# vi /etc/nginx/conf.d/default.conf
Set IP address and TCP port number:
listen 202.54.1.1.1:80;
Set server name:
server_name www.cyberciti.biz;
Save and close the file. Start the server:# service nginx start
Verify that everything is working:# netstat -tulpn | grep :80
# ps aux | grep nginx
Firewall configuration: Open TCP port # 80
Edit the file /etc/sysconfig/iptables, enter:# vi /etc/sysconfig/iptables
Add the following lines, ensuring that they appear before the final LOG and DROP lines for the INPUT chain to open port 80:
-A INPUT -m state --state NEW -p tcp --dport 80 -j ACCEPT
Save and close the file. Finally, restart the firewall:# service iptables restart
参考 http://www.cyberciti.biz/faq/install-nginx-centos-rhel-6-server-rpm-using-yum-command/
相关推荐
官网文档翻译. www.nginx.org 安装先决条件: sudo yum install yum-utils ...baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ gpgcheck=1 enabled=1 gpgkey=https://nginx.org/keys/ngin
CentOS 7.6 Linux系统环境: Nginx 1.20.1+ MySQL 5.6.50+ PHP-7.2+ Redis 将商户后台源码上传解压运行目录为Public伪静态为thinkphp访问域名傻瓜模式安装后台安装完了 sudo rpm -Uvh ...
CentOS 7.6 Linux系统环境: Nginx 1.20.1+ MySQL 5.6.50+ PHP-7.2+ Redis 将商户后台源码上传解压运行目录为Public伪静态为thinkphp访问域名傻瓜模式安装后台安装完了 sudo rpm -Uvh ...
CentOS 7.6 Linux系统环境: Nginx 1.20.1+ MySQL 5.6.50+ PHP-7.2+ Redis 将商户后台源码上传解压运行目录为Public伪静态为thinkphp访问域名傻瓜模式安装后台安装完了 sudo rpm -Uvh ...
CentOS 7.6 Linux系统环境: Nginx 1.20.1+ MySQL 5.6.50+ PHP-7.2+ Redis 将商户后台源码上传解压运行目录为Public伪静态为thinkphp访问域名傻瓜模式安装后台安装完了 sudo rpm -Uvh ...
推荐系统为:CentOS 7.6 Linux系统环境:Nginx 1.20.1+MySQL 5.6.50+PHP-7.2+Redis 将商户后台源码上传 运行目录为Public 伪静态为thinkphp 访问域名傻瓜模式安装 sudo rpm -Uvh ...
推荐系统为:CentOS 7.6 Linux系统环境:Nginx 1.20.1+MySQL 5.6.50+PHP-7.2+Redis 将商户后台源码上传解压 运行目录为Public 伪静态为Thinkphp 访问域名傻瓜模式安装 sudo rpm -Uvh ...
guacamole-install-rhel-7:用于RHEL 7和CentOS 7的Apache Guacamole安装bash脚本,包括Nginx,HTTPS,SSL,LDAP,Let's Encrypt证书等选项
centos7下nginx安装命令 echo "[nginx]" > /etc/yum.repos.d/nginx.repo echo "name=nginx repo" >> /etc/yum.repos.d/nginx.repo echo "baseurl=http://nginx.org/packages/mainline/rhel/7/\$basearch/" >> /etc/...
官方文档:https://nginx.org/en/linux_packages.html#RHEL-CentOS 安装环境:Linux 服务器 CentOS 7.3、Root 权限 1、Install the prerequisites: sudo yum install yum-utils 2、To set up the yum repository, ...
请流星RHEL/CentOS 7+ 的简单 Meteor 部署通过 SSH 在 RHEL 风格的盒子上部署您的 Meteor 应用程序,并使用systemd使您的应用程序保持活力。 您的应用程序由nginx通过反向代理提供服务。 这是我个人在生产中使用的...
实践说明:基于RHEL9系列(CentOS9,AlmaLinux9,RockyLinux9等) 模版导入服务端即可使用,包含80+监控项,60+自动发现监控项,已配置常见图表和触发器,大量采用中文简体,方便非运维识别告警信息。 一键安装包说明...
安装 来自ESSENTIAL KAOS RHEL7 / CentOS7的公共仓库[sudo] yum install -y yum install -y https://yum.kaos.st/kaos-repo-latest.el7.noarch.rpm[sudo] yum install webkaos 使用rpmbuilder ... install and ...
CentOS 7.6 Linux系统环境: Nginx 1.20.1+ MySQL 5.6.50+ PHP-7.2+ Redis 将商户后台源码上传解压运行目录为Public伪静态为thinkphp访问域名傻瓜模式安装后台安装完了 sudo rpm -Uvh ...