Linux Basics-Unit 18th _nginx Deployment

Source: Internet
Author: User

First, the basic Environment configuration

1.1. Install common software

Yum Install Wget-y

1.2. Install Yum Repo

Mv/etc/yum.repos.d/centos-base.repo/etc/yum.repos.d/centos-base.repo.backupwget-o/etc/yum.repos.d/ Centos-base.repo Http://mirrors.aliyun.com/repo/Centos-7.repowget-O/etc/yum.repos.d/epel.repo/http Mirrors.aliyun.com/repo/epel-7.repoyum Clean Allyum Makecache

1.3. Close Firewalld

Systemctl Disable firewalldsystemctl disable NetworkManager  and sed-i ' s/selinux=enforcing/selinux=disabled/g '/ Etc/selinux/configsetenforce 0

1.4. Install common software

Yum Install net-tools vim lrzsz screen lsof tcpdump nc mtr nmap-yyum  update-y && reboot

Second, install Nginx

Website address: http://nginx.org/en/download.html

2.1, yum mode installation:

Yum Install Nginx-y

2.2. Configure Nginx

#配置nginx

[Email protected] ~]# vi/etc/nginx/nginx.conf

#指定配置文件: root/usr/share/nginx/html

#网站存放路径

[Email protected] html]# cd/usr/share/nginx/html
[email protected] html]# LL
Total 24
-rw-r--r--1 root root 3650 Mar 6 17:26 404.html
-rw-r--r--1 root root 3693 Mar 6 17:26 50x.html
-rw-r--r--1 root root June 16:28 index.html
-rw-r--r--1 root root 3700 Mar 6 17:26 Index.html.bak
-rw-r--r--1 root root 368 Mar 6 17:26 nginx-logo.png
-rw-r--r--1 root root 2811 Mar 6 17:26 poweredby.png

#改写主页

[Email protected] html]# echo "Welcome Nginx" >index.html
[email protected] html]# cat index.html
Welcome Nginx

#启动服务

[Email protected] html]# systemctl restart Nginx
[Email protected] html]# systemctl status Nginx

#访问网站

Http://192.168.56.33/welcome Nginx

#配置负载均衡

Reference website:

Http://nginx.org/en/docs/http/load_balancing.html

HTTP {    Upstream MyApp1 {        server srv1.example.com;        Server srv2.example.com;        Server srv3.example.com;    }    server {        listen;        Location/{            proxy_pass http://myapp1;}}    }

#重启服务

SystemC Reload Nginx

3. Compile and install Nginx

Reference Peak elder brother: Http://www.cnblogs.com/linhaifeng/articles/6045600.html#_label19

SOURCE installation: Yum install gcc-* glibc-* OpenSSL openssl-devel pcre pcre-devel zlib zlib-devel-ylstar xvf nginx-1.10.3.tar.gz CD ng Inx-1.10.3ls./configure./configure--sbin-path=/usr/local/nginx/nginx--conf-path=/usr/local/nginx/nginx.conf-- Pid-path=/usr/local/nginx/nginx.pid--with-http_ssl_module--without-http_rewrite_module #--without-http_rewrite_ The module representative does not use the rewrite feature, that is, the Pcre library is not referenced, and if pcre related issues occur during installation, you can specify the parameter Makemake install

#所有模块

Reference: http://nginx.org/en/docs/

Linux Basics-Unit 18th _nginx Deployment

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.