LNMP环境搭建之一--nginx

LNMP是 Linux、Nginx、MySQL 和 PHP 的缩写

安装Nginx

[root@VM_88_143_centos ~]# yum install nginx -y
Loaded plugins: fastestmirror, security
Setting up Install Process
Determining fastest mirrors
epel                                                                                                                                                                  | 4.7 kB     00:00     
epel/primary_db                                                                                                                                                       | 6.0 MB     00:00     
extras                                                                                                                                                                | 3.4 kB     00:00     
extras/primary_db                                                                                                                                                     |  29 kB     00:00     
os                                                                                                                                                                    | 3.7 kB     00:00     
os/primary_db                                                                                                                                                         | 4.7 MB     00:00     
updates                                                                                                                                                               | 3.4 kB     00:00     
updates/primary_db                                                                                                                                                    | 5.3 MB     00:00     
Resolving Dependencies
--> Running transaction check
---> Package nginx.x86_64 0:1.10.2-1.el6 will be installed
--> Processing Dependency: nginx-all-modules = 1.10.2-1.el6 for package: nginx-1.10.2-1.el6.x86_64
--> Processing Dependency: nginx-filesystem = 1.10.2-1.el6 for package: nginx-1.10.2-1.el6.x86_64
--> Processing Dependency: nginx-filesystem for package: nginx-1.10.2-1.el6.x86_64
--> Running transaction check
---> Package nginx-all-modules.noarch 0:1.10.2-1.el6 will be installed
--> Processing Dependency: nginx-mod-http-geoip = 1.10.2-1.el6 for package: nginx-all-modules-1.10.2-1.el6.noarch
--> Processing Dependency: nginx-mod-http-image-filter = 1.10.2-1.el6 for package: nginx-all-modules-1.10.2-1.el6.noarch
--> Processing Dependency: nginx-mod-http-perl = 1.10.2-1.el6 for package: nginx-all-modules-1.10.2-1.el6.noarch
--> Processing Dependency: nginx-mod-http-xslt-filter = 1.10.2-1.el6 for package: nginx-all-modules-1.10.2-1.el6.noarch
--> Processing Dependency: nginx-mod-mail = 1.10.2-1.el6 for package: nginx-all-modules-1.10.2-1.el6.noarch
--> Processing Dependency: nginx-mod-stream = 1.10.2-1.el6 for package: nginx-all-modules-1.10.2-1.el6.noarch
---> Package nginx-filesystem.noarch 0:1.10.2-1.el6 will be installed
--> Running transaction check
---> Package nginx-mod-http-geoip.x86_64 0:1.10.2-1.el6 will be installed
--> Processing Dependency: GeoIP for package: nginx-mod-http-geoip-1.10.2-1.el6.x86_64
--> Processing Dependency: libGeoIP.so.1()(64bit) for package: nginx-mod-http-geoip-1.10.2-1.el6.x86_64
---> Package nginx-mod-http-image-filter.x86_64 0:1.10.2-1.el6 will be installed
--> Processing Dependency: gd for package: nginx-mod-http-image-filter-1.10.2-1.el6.x86_64
--> Processing Dependency: libgd.so.2()(64bit) for package: nginx-mod-http-image-filter-1.10.2-1.el6.x86_64
---> Package nginx-mod-http-perl.x86_64 0:1.10.2-1.el6 will be installed
---> Package nginx-mod-http-xslt-filter.x86_64 0:1.10.2-1.el6 will be installed
--> Processing Dependency: libxslt.so.1(LIBXML2_1.0.11)(64bit) for package: nginx-mod-http-xslt-filter-1.10.2-1.el6.x86_64
--> Processing Dependency: libxslt.so.1(LIBXML2_1.0.18)(64bit) for package: nginx-mod-http-xslt-filter-1.10.2-1.el6.x86_64
--> Processing Dependency: libexslt.so.0()(64bit) for package: nginx-mod-http-xslt-filter-1.10.2-1.el6.x86_64
--> Processing Dependency: libxslt.so.1()(64bit) for package: nginx-mod-http-xslt-filter-1.10.2-1.el6.x86_64
---> Package nginx-mod-mail.x86_64 0:1.10.2-1.el6 will be installed
---> Package nginx-mod-stream.x86_64 0:1.10.2-1.el6 will be installed
--> Running transaction check
---> Package GeoIP.x86_64 0:1.6.5-1.el6 will be installed
--> Processing Dependency: GeoIP-data for package: GeoIP-1.6.5-1.el6.x86_64
--> Processing Dependency: geoipupdate for package: GeoIP-1.6.5-1.el6.x86_64
---> Package gd.x86_64 0:2.0.35-11.el6 will be installed
--> Processing Dependency: libpng12.so.0(PNG12_0)(64bit) for package: gd-2.0.35-11.el6.x86_64
--> Processing Dependency: libpng12.so.0()(64bit) for package: gd-2.0.35-11.el6.x86_64
--> Processing Dependency: libjpeg.so.62()(64bit) for package: gd-2.0.35-11.el6.x86_64
--> Processing Dependency: libfreetype.so.6()(64bit) for package: gd-2.0.35-11.el6.x86_64
--> Processing Dependency: libfontconfig.so.1()(64bit) for package: gd-2.0.35-11.el6.x86_64
--> Processing Dependency: libXpm.so.4()(64bit) for package: gd-2.0.35-11.el6.x86_64
--> Processing Dependency: libX11.so.6()(64bit) for package: gd-2.0.35-11.el6.x86_64
---> Package libxslt.x86_64 0:1.1.26-2.el6_3.1 will be installed
--> Running transaction check
---> Package GeoIP-GeoLite-data.noarch 0:2017.07-1.el6 will be installed
--> Processing Dependency: GeoIP-GeoLite-data-extra = 2017.07-1.el6 for package: GeoIP-GeoLite-data-2017.07-1.el6.noarch
---> Package fontconfig.x86_64 0:2.8.0-5.el6 will be installed
---> Package freetype.x86_64 0:2.3.11-17.el6 will be installed
---> Package geoipupdate.x86_64 0:2.2.1-2.el6 will be installed
---> Package libX11.x86_64 0:1.6.4-3.el6 will be installed
--> Processing Dependency: libX11-common = 1.6.4-3.el6 for package: libX11-1.6.4-3.el6.x86_64
--> Processing Dependency: libxcb.so.1()(64bit) for package: libX11-1.6.4-3.el6.x86_64
---> Package libXpm.x86_64 0:3.5.10-2.el6 will be installed
---> Package libjpeg-turbo.x86_64 0:1.2.1-3.el6_5 will be installed
---> Package libpng.x86_64 2:1.2.49-2.el6_7 will be installed
--> Running transaction check
---> Package GeoIP-GeoLite-data-extra.noarch 0:2017.07-1.el6 will be installed
---> Package libX11-common.noarch 0:1.6.4-3.el6 will be installed
---> Package libxcb.x86_64 0:1.12-4.el6 will be installed
--> Processing Dependency: libXau.so.6()(64bit) for package: libxcb-1.12-4.el6.x86_64
--> Running transaction check
---> Package libXau.x86_64 0:1.0.6-4.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================================================================
 Package                                                    Arch                                  Version                                          Repository                           Size
=============================================================================================================================================================================================
Installing:
 nginx                                                      x86_64                                1.10.2-1.el6                                     epel                                462 k
Installing for dependencies:
 GeoIP                                                      x86_64                                1.6.5-1.el6                                      epel                                113 k
 GeoIP-GeoLite-data                                         noarch                                2017.07-1.el6                                    epel                                492 k
 GeoIP-GeoLite-data-extra                                   noarch                                2017.07-1.el6                                    epel                                 24 M
 fontconfig                                                 x86_64                                2.8.0-5.el6                                      os                                  186 k
 freetype                                                   x86_64                                2.3.11-17.el6                                    os                                  361 k
 gd                                                         x86_64                                2.0.35-11.el6                                    os                                  142 k
 geoipupdate                                                x86_64                                2.2.1-2.el6                                      epel                                 28 k
 libX11                                                     x86_64                                1.6.4-3.el6                                      os                                  587 k
 libX11-common                                              noarch                                1.6.4-3.el6                                      os                                  171 k
 libXau                                                     x86_64                                1.0.6-4.el6                                      os                                   24 k
 libXpm                                                     x86_64                                3.5.10-2.el6                                     os                                   51 k
 libjpeg-turbo                                              x86_64                                1.2.1-3.el6_5                                    os                                  174 k
 libpng                                                     x86_64                                2:1.2.49-2.el6_7                                 os                                  182 k
 libxcb                                                     x86_64                                1.12-4.el6                                       os                                  180 k
 libxslt                                                    x86_64                                1.1.26-2.el6_3.1                                 os                                  452 k
 nginx-all-modules                                          noarch                                1.10.2-1.el6                                     epel                                7.7 k
 nginx-filesystem                                           noarch                                1.10.2-1.el6                                     epel                                8.5 k
 nginx-mod-http-geoip                                       x86_64                                1.10.2-1.el6                                     epel                                 14 k
 nginx-mod-http-image-filter                                x86_64                                1.10.2-1.el6                                     epel                                 16 k
 nginx-mod-http-perl                                        x86_64                                1.10.2-1.el6                                     epel                                 26 k
 nginx-mod-http-xslt-filter                                 x86_64                                1.10.2-1.el6                                     epel                                 16 k
 nginx-mod-mail                                             x86_64                                1.10.2-1.el6                                     epel                                 43 k
 nginx-mod-stream                                           x86_64                                1.10.2-1.el6                                     epel                                 36 k

Transaction Summary
=============================================================================================================================================================================================
Install      24 Package(s)

Total download size: 28 M
Installed size: 60 M
Downloading Packages:
(1/24): GeoIP-1.6.5-1.el6.x86_64.rpm                                                                                                                                  | 113 kB     00:00     
(2/24): GeoIP-GeoLite-data-2017.07-1.el6.noarch.rpm                                                                                                                   | 492 kB     00:00     
(3/24): GeoIP-GeoLite-data-extra-2017.07-1.el6.noarch.rpm                                                                                                             |  24 MB     00:00     
(4/24): fontconfig-2.8.0-5.el6.x86_64.rpm                                                                                                                             | 186 kB     00:00     
(5/24): freetype-2.3.11-17.el6.x86_64.rpm                                                                                                                             | 361 kB     00:00     
(6/24): gd-2.0.35-11.el6.x86_64.rpm                                                                                                                                   | 142 kB     00:00     
(7/24): geoipupdate-2.2.1-2.el6.x86_64.rpm                                                                                                                            |  28 kB     00:00     
(8/24): libX11-1.6.4-3.el6.x86_64.rpm                                                                                                                                 | 587 kB     00:00     
(9/24): libX11-common-1.6.4-3.el6.noarch.rpm                                                                                                                          | 171 kB     00:00     
(10/24): libXau-1.0.6-4.el6.x86_64.rpm                                                                                                                                |  24 kB     00:00     
(11/24): libXpm-3.5.10-2.el6.x86_64.rpm                                                                                                                               |  51 kB     00:00     
(12/24): libjpeg-turbo-1.2.1-3.el6_5.x86_64.rpm                                                                                                                       | 174 kB     00:00     
(13/24): libpng-1.2.49-2.el6_7.x86_64.rpm                                                                                                                             | 182 kB     00:00     
(14/24): libxcb-1.12-4.el6.x86_64.rpm                                                                                                                                 | 180 kB     00:00     
(15/24): libxslt-1.1.26-2.el6_3.1.x86_64.rpm                                                                                                                          | 452 kB     00:00     
(16/24): nginx-1.10.2-1.el6.x86_64.rpm                                                                                                                                | 462 kB     00:00     
(17/24): nginx-all-modules-1.10.2-1.el6.noarch.rpm                                                                                                                    | 7.7 kB     00:00     
(18/24): nginx-filesystem-1.10.2-1.el6.noarch.rpm                                                                                                                     | 8.5 kB     00:00     
(19/24): nginx-mod-http-geoip-1.10.2-1.el6.x86_64.rpm                                                                                                                 |  14 kB     00:00     
(20/24): nginx-mod-http-image-filter-1.10.2-1.el6.x86_64.rpm                                                                                                          |  16 kB     00:00     
(21/24): nginx-mod-http-perl-1.10.2-1.el6.x86_64.rpm                                                                                                                  |  26 kB     00:00     
(22/24): nginx-mod-http-xslt-filter-1.10.2-1.el6.x86_64.rpm                                                                                                           |  16 kB     00:00     
(23/24): nginx-mod-mail-1.10.2-1.el6.x86_64.rpm                                                                                                                       |  43 kB     00:00     
(24/24): nginx-mod-stream-1.10.2-1.el6.x86_64.rpm                                                                                                                     |  36 kB     00:00     
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                         33 MB/s |  28 MB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : GeoIP-GeoLite-data-extra-2017.07-1.el6.noarch                                                                                                                            1/24 
  Installing : GeoIP-GeoLite-data-2017.07-1.el6.noarch                                                                                                                                  2/24 
  Installing : freetype-2.3.11-17.el6.x86_64                                                                                                                                            3/24 
  Installing : fontconfig-2.8.0-5.el6.x86_64                                                                                                                                            4/24 
  Installing : nginx-filesystem-1.10.2-1.el6.noarch                                                                                                                                     5/24 
  Installing : libxslt-1.1.26-2.el6_3.1.x86_64                                                                                                                                          6/24 
  Installing : libXau-1.0.6-4.el6.x86_64                                                                                                                                                7/24 
  Installing : libxcb-1.12-4.el6.x86_64                                                                                                                                                 8/24 
  Installing : libjpeg-turbo-1.2.1-3.el6_5.x86_64                                                                                                                                       9/24 
  Installing : libX11-common-1.6.4-3.el6.noarch                                                                                                                                        10/24 
  Installing : libX11-1.6.4-3.el6.x86_64                                                                                                                                               11/24 
  Installing : libXpm-3.5.10-2.el6.x86_64                                                                                                                                              12/24 
  Installing : 2:libpng-1.2.49-2.el6_7.x86_64                                                                                                                                          13/24 
  Installing : gd-2.0.35-11.el6.x86_64                                                                                                                                                 14/24 
  Installing : geoipupdate-2.2.1-2.el6.x86_64                                                                                                                                          15/24 
  Installing : GeoIP-1.6.5-1.el6.x86_64                                                                                                                                                16/24 
  Installing : nginx-mod-mail-1.10.2-1.el6.x86_64                                                                                                                                      17/24 
  Installing : nginx-mod-http-image-filter-1.10.2-1.el6.x86_64                                                                                                                         18/24 
  Installing : nginx-mod-stream-1.10.2-1.el6.x86_64                                                                                                                                    19/24 
  Installing : nginx-mod-http-xslt-filter-1.10.2-1.el6.x86_64                                                                                                                          20/24 
  Installing : nginx-mod-http-perl-1.10.2-1.el6.x86_64                                                                                                                                 21/24 
  Installing : nginx-1.10.2-1.el6.x86_64                                                                                                                                               22/24 
  Installing : nginx-mod-http-geoip-1.10.2-1.el6.x86_64                                                                                                                                23/24 
  Installing : nginx-all-modules-1.10.2-1.el6.noarch                                                                                                                                   24/24 
  Verifying  : nginx-mod-http-geoip-1.10.2-1.el6.x86_64                                                                                                                                 1/24 
  Verifying  : libXpm-3.5.10-2.el6.x86_64                                                                                                                                               2/24 
  Verifying  : freetype-2.3.11-17.el6.x86_64                                                                                                                                            3/24 
  Verifying  : fontconfig-2.8.0-5.el6.x86_64                                                                                                                                            4/24 
  Verifying  : geoipupdate-2.2.1-2.el6.x86_64                                                                                                                                           5/24 
  Verifying  : 2:libpng-1.2.49-2.el6_7.x86_64                                                                                                                                           6/24 
  Verifying  : GeoIP-GeoLite-data-2017.07-1.el6.noarch                                                                                                                                  7/24 
  Verifying  : GeoIP-GeoLite-data-extra-2017.07-1.el6.noarch                                                                                                                            8/24 
  Verifying  : nginx-mod-mail-1.10.2-1.el6.x86_64                                                                                                                                       9/24 
  Verifying  : nginx-all-modules-1.10.2-1.el6.noarch                                                                                                                                   10/24 
  Verifying  : nginx-mod-http-image-filter-1.10.2-1.el6.x86_64                                                                                                                         11/24 
  Verifying  : nginx-1.10.2-1.el6.x86_64                                                                                                                                               12/24 
  Verifying  : gd-2.0.35-11.el6.x86_64                                                                                                                                                 13/24 
  Verifying  : libX11-common-1.6.4-3.el6.noarch                                                                                                                                        14/24 
  Verifying  : GeoIP-1.6.5-1.el6.x86_64                                                                                                                                                15/24 
  Verifying  : nginx-mod-stream-1.10.2-1.el6.x86_64                                                                                                                                    16/24 
  Verifying  : libX11-1.6.4-3.el6.x86_64                                                                                                                                               17/24 
  Verifying  : libjpeg-turbo-1.2.1-3.el6_5.x86_64                                                                                                                                      18/24 
  Verifying  : nginx-mod-http-xslt-filter-1.10.2-1.el6.x86_64                                                                                                                          19/24 
  Verifying  : libXau-1.0.6-4.el6.x86_64                                                                                                                                               20/24 
  Verifying  : nginx-mod-http-perl-1.10.2-1.el6.x86_64                                                                                                                                 21/24 
  Verifying  : libxcb-1.12-4.el6.x86_64                                                                                                                                                22/24 
  Verifying  : libxslt-1.1.26-2.el6_3.1.x86_64                                                                                                                                         23/24 
  Verifying  : nginx-filesystem-1.10.2-1.el6.noarch                                                                                                                                    24/24 

Installed:
  nginx.x86_64 0:1.10.2-1.el6                                                                                                                                                                

Dependency Installed:
  GeoIP.x86_64 0:1.6.5-1.el6                        GeoIP-GeoLite-data.noarch 0:2017.07-1.el6   GeoIP-GeoLite-data-extra.noarch 0:2017.07-1.el6    fontconfig.x86_64 0:2.8.0-5.el6           
  freetype.x86_64 0:2.3.11-17.el6                   gd.x86_64 0:2.0.35-11.el6                   geoipupdate.x86_64 0:2.2.1-2.el6                   libX11.x86_64 0:1.6.4-3.el6               
  libX11-common.noarch 0:1.6.4-3.el6                libXau.x86_64 0:1.0.6-4.el6                 libXpm.x86_64 0:3.5.10-2.el6                       libjpeg-turbo.x86_64 0:1.2.1-3.el6_5      
  libpng.x86_64 2:1.2.49-2.el6_7                    libxcb.x86_64 0:1.12-4.el6                  libxslt.x86_64 0:1.1.26-2.el6_3.1                  nginx-all-modules.noarch 0:1.10.2-1.el6   
  nginx-filesystem.noarch 0:1.10.2-1.el6            nginx-mod-http-geoip.x86_64 0:1.10.2-1.el6  nginx-mod-http-image-filter.x86_64 0:1.10.2-1.el6  nginx-mod-http-perl.x86_64 0:1.10.2-1.el6 
  nginx-mod-http-xslt-filter.x86_64 0:1.10.2-1.el6  nginx-mod-mail.x86_64 0:1.10.2-1.el6        nginx-mod-stream.x86_64 0:1.10.2-1.el6            

Complete!

修改 /etc/nginx/conf.d/default.conf,去除对 IPv6 地址的监听

原始配置文件:

[root@VM_88_143_centos ~]# cat /etc/nginx/conf.d/default.conf
#
# The default server
#

server {
    listen       80 default_server;
    listen       [::]:80 default_server;
    server_name  _;
    root         /usr/share/nginx/html;

    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;

    location / {
    }

    error_page 404 /404.html;
        location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }

}
修改配置文件
[root@VM_88_143_centos ~]# vim /etc/nginx/conf.d/default.conf
[root@VM_88_143_centos ~]# cat /etc/nginx/conf.d/default.conf
#
# The default server
#

server {
    listen       80 default_server;
#    listen       [::]:80 default_server;
    server_name  _;
    root         /usr/share/nginx/html;

    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;

    location / {
    }

    error_page 404 /404.html;
        location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }

}

修改完成后,启动 Nginx:
[root@VM_88_143_centos ~]# ps -ef | grep nginx
root      2728  2318  0 21:00 pts/0    00:00:00 grep nginx
[root@VM_88_143_centos ~]# nginx
[root@VM_88_143_centos ~]# ps -ef | grep nginx
root      2739     1  0 21:00 ?        00:00:00 nginx: master process nginx
nginx     2740  2739  0 21:00 ?        00:00:00 nginx: worker process
root      2742  2318  0 21:00 pts/0    00:00:00 grep nginx

此时,可访问 HTTP 服务(http://127.0.0.1)来确认是否已经安装成功。


将 Nginx 设置为开机自动启动:

[root@VM_88_143_centos ~]# chkconfig nginx on


猜你喜欢

转载自blog.csdn.net/kongshuai19900505/article/details/78827496