# 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
Type the following yum command to install nginx web-server:
# yum install nginx
Step #3: Turn on nginx service
Type the following command:
# 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:
Set or update worker_processes as follows (this must be set to CPU(s) in your system. Use thelscpu | grep '^CPU(s)' command to list the number of CPUs in the server)
# vi /etc/nginx/nginx.conf
Set or update worker_processes as follows (this must be set to CPU(s) in your system. Use thelscpu | 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:
Set IP address and TCP port number:
# 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:
Verify that everything is working:
# 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:
Add the following lines, ensuring that they appear before the final LOG and DROP lines for the INPUT chain to open port 80:
# 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
ไม่มีความคิดเห็น:
แสดงความคิดเห็น