Two Methods for installing nginx on centos 7

Source: Internet
Author: User

Two Methods for installing nginx on centos 7
Centos7: Install nginx using yum

Directly install nginx through yum. Because yum does not have nginx, add the nginx source to yum first.

Run the following command:

1. Put nginx In the yum repro Library [root @ localhost ~] # Rpm-ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm2 . View nginx information [root @ localhost ~] # Yum info nginx3. use yum to install ngnix [root @ localhost ~] # Yum install nginx: [root @ localhost ~] # Yum install nginx loaded plug-ins: fastestmirror, langpacksLoading mirror speeds from cached hostfile * base: mirrors.usc.edu * extras: 2.16.raystedman.net * updates: mongo.metrocast.net is working on the dependency --> checking the transaction --> the software package nginx. the x86_64.1.1.10.1-1.el7.ngx will be installed... installing: 1: nginx-1.10.1-1.el7.ngx.x86_64 Thanks for using nginx! Please find the official documentation for nginx here :* http://nginx.org/en/docs/Commercial Subscriptions for nginx are available on :* http://nginx.com/products/---------------------------------------------------------------------- Verify: 1: nginx-1.10.1-1.el7.ngx.x86_64 1/1 installed: nginx. x86_64. 10.1-1. el7.ngx complete! 4. Start nginx [root @ localhost ~] # Service nginx start5. view nginx version [root @ localhost ~] # Nginx-v6. access nginx. Now you can view the information returned by the nginx service through the public ip address (localhost/or 127.0.0.1. [Root @ localhost ~] # Curl-I localhost !. · 7. the nginx configuration file is located at/etc/nginx/[root @ localhost/] # ll/etc/nginx/total usage of 32drwxr-xr-x. 2 root 25 13:11 conf. d-rw-r --. 1 root 1007 May 31 22:09 fastcgi_params-rw-r -- r --. 1 root 2837 May 31 22:09 koi-utf-rw-r --. 1 root 2223 May 31 22:09 koi-win-rw-r --. 1 root 3957 May 31 22:09 mime. typeslrwxrwxrwx. 1 root 29 October 12 13:11 modules-> .. /.. /usr/lib64/nginx/modules-rw-r --. 1 root 643 May 31 22:08 nginx. conf-rw-r --. 1 root 636 May 31 22:09 scgi_params-rw-r -- r --. 1 root 664 May 31 22:09 uwsgi_params-rw-r -- r --. 1 root 3610 May 31 22:09 win-utf8. practice: Objective: To modify the service name and then access the service from the outside. Operation:. modify the nginx configuration file [root @ localhost nginx] # vim/etc/nginx/conf. d/default. modify server_name in conf: server_name yytest.com; B. heavy Load service [root @ localhost nginx] #/usr/sbin/nginx-s reload c. access the nginx Service (192.168.10.11) from the outside, such as in the client (192.168.10.10) Browser: http://yytest.comd . You can't find the access. Cause 1: You didn't map in the hosts file; cause 2: You ing in the hosts file in time, because port 80 of the nginx server is blocked or the firewall is not off. e. solution: Step 1: Modify the hosts file of the client (192.168.10.10) and use the SwitchHosts tool to add 192.168.10.11 yytest.com. Step 2: Disable the firewall. start common nginx operations: $/usr/sbin/nginx or run service nginx start in any path (centos7 is systemctl start nginx. service) restart: $/usr/sbin/nginx-s reload stop: $/usr/sbin/nginx-s stop to test whether the configuration file is normal: $/usr/sbin/nginx-t
Possible problems:

The specific situation is as follows: 1. The local machine can ping Virtual Machine 2. The VM can also ping the host 3. The virtual machine can access its web 4. The local machine cannot access the virtual web. This problem occurs because port 80 of the server is not enabled or the firewall is not disabled.

Solution
If centos6 is used, the solution is as follows:/sbin/iptables-I INPUT-p tcp -- dport 80-j ACCEPT and then save:/etc/rc. d/init. d/iptables save and restart Firewall/etc/init. d/iptables restart: Disable the CentOS firewall and close its service. Then, you can view the CentOS Firewall Information:/etc/init. d/iptables status disable the CentOS Firewall Service:/etc/init. d/iptables stop permanently disable the firewall: chkconfig-level 35 iptables off if it is centos7 [root @ rhel7 ~] # Systemctl status firewalld. service [root @ rhel7 ~] # Systemctl stop firewalld. service [root @ rhel7 ~] # Systemctl disable firewalld. service [root @ rhel7 ~] # Systemctl status firewalld. service
Extended knowledge:
Start a service: systemctl start firewalld. service to close a service: systemctl stop firewalld. restart a service: systemctl restart firewalld. the service displays the status of a service: systemctl status firewalld. the service enables a service: systemctl enable firewalld. A service is disabled when it is started: systemctl disable firewalld. service to check whether the service is started: systemctl is-enabled firewalld. service; echo $? View the list of started services: systemctl list-unit-files | grep enabled
Method 2: manually download the installation package and decompress the package.
1. Download The nginx package. [Root @ localhost ~] # Wget http://nginx.org/download/nginx-1.10.1.tar.gz2.copy the package to your installation directory root@localhost ~] # Cp nginx-1.10.1.tar.gz/usr/local/3. Unzip [root @ localhost ~] # Tar-zxvf nginx-1.10.1.tar.gz [root @ localhost ~] # Cd nginx-1.10.14. Start nginx [root @ localhost ~] #/Usr/local/nginx/sbin/nginx5. view version s [root @ localhost ~] # Nginx-v6.url access nginx localhost or 127.0.0.1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.