参考文章 https://blog.csdn.net/u012453843/article/details/69951920#comments https://blog.csdn.net/u012453843/article/details/69396434
由于FastDFS集群搭建非常复杂,对于初期学习FastDFS来说,搭建个单机版的作为入门更为实际一些。
第一步:搭建虚拟环境
FastDFS需要在Linux系统上安装,我们一般使用的都是Windows系统,这样就需要有虚拟环境,我这里使用Vmware12创建虚拟机,关于虚拟机最小化的安装大家可以参考:http://blog.csdn.net/u012453843/article/details/68947589这篇博客进行学习
第二步:配置静态IP而且要保证能上网
大家可以参考:http://blog.csdn.net/u012453843/article/details/52839105这篇博客进行学习,需要提醒的是,由于最小化安装默认是没有vim命令的,因此在配置静态IP时使用vi命令即可。
第三步:安装vim命令
之所以安装vim命令是因为在安装它的同时会自动帮我们安装perl,而perl在进行编译安装时是必须要有的。安装vim的命令是:yum install vim-enhanced
第四步:安装gcc
使用命令:yum install make cmake gcc gcc-c++进行安装即可
第五步:上传安装文件到Linux服务器
为了便于管理,我们在Linux服务器上新建一个/usr/local/software目录,专门用于存放安装包,如下所示
下面我们把需要用到的安装包都上传到/usr/local/software目录下,我们可以使用XShell和Xftp5相结合来方便的进行上传下载操作,大家可以参考http://blog.csdn.net/u012453843/article/details/68951776这篇博客进行学习。也可以通过安装rzsz命令来进行上传下载操作,安装rzsz的命令是yum install lrzsz,安装完之后,rz表示上传,sz 文件表示下载。
[root@fastdfs ~]# mkdir /usr/local/software [root@fastdfs ~]#
大家可以到http://download.csdn.net/detail/u012453843/9802538这个地址下载需要的安装包,上传完之后,如下所示
[root@fastdfs software]# ll 总用量 1248 -rw-r--r--. 1 root root 17510 11月 28 00:19 fastdfs-nginx-module_v1.16.tar.gz -rw-r--r--. 1 root root 345400 11月 28 00:20 FastDFS_v5.05.tar.gz -rw-r--r--. 1 root root 102378 11月 28 00:19 libfastcommon-master.zip -rw-r--r--. 1 root root 804164 11月 28 01:11 nginx-1.6.2.tar.gz [root@fastdfs software]#
第六步:安装zip和unzip命令
由于解压.zip结尾的文件需要用到unzip命令,因此我们需要安装,安装命令是yum install zip unzip
第七步:安装libfastcommon1、解压
[root@fastdfs software]# unzip libfastcommon-master.zip -d /usr/local/fast/
2、进入目录
3、编译
[root@fastdfs software]# cd /usr/local/fast/libfastcommon-master/ [root@fastdfs libfastcommon-master]# ll 总用量 28 -rw-r--r--. 1 root root 2913 2月 27 2015 HISTORY -rw-r--r--. 1 root root 582 2月 27 2015 INSTALL -rw-r--r--. 1 root root 1342 2月 27 2015 libfastcommon.spec -rwxr-xr-x. 1 root root 2151 2月 27 2015 make.sh drwxr-xr-x. 2 root root 4096 2月 27 2015 php-fastcommon -rw-r--r--. 1 root root 617 2月 27 2015 README drwxr-xr-x. 2 root root 4096 2月 27 2015 src [root@fastdfs libfastcommon-master]#
[root@fastdfs libfastcommon-master]# ./make.sh
4、安装
[root@fastdfs libfastcommon-master]# ./make.sh install
第八步:创建软链接
FastDFS主程序设置的目录为/usr/local/lib/,所以我们需要创建/ usr/lib64/下的一些核心执行程序的软连接文件。如下所示。
第九步:安装FastDFS
[root@fastdfs libfastcommon-master]# ln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so [root@fastdfs libfastcommon-master]# ln -s /usr/lib64/libfastcommon.so /usr/lib/libfastcommon.so [root@fastdfs libfastcommon-master]# ln -s /usr/lib64/libfdfsclient.so /usr/local/lib/libfdfsclient.so [root@fastdfs libfastcommon-master]# ln -s /usr/lib64/libfdfsclient.so /usr/lib/libfdfsclient.so
1、进入到cd /usr/local/software下,解压FastDFS_v5.05.tar.gz文件
2、编译安装
[root@fastdfs fast]# cd /usr/local/software/ [root@fastdfs software]# ll 总用量 1248 -rw-r--r--. 1 root root 17510 4月 11 03:28 fastdfs-nginx-module_v1.16.tar.gz -rw-r--r--. 1 root root 345400 4月 11 03:28 FastDFS_v5.05.tar.gz -rw-r--r--. 1 root root 102378 4月 11 03:28 libfastcommon-master.zip -rw-r--r--. 1 root root 804164 4月 11 03:29 nginx-1.6.2.tar.gz [root@fastdfs software]# tar -zxvf FastDFS_v5.05.tar.gz -C /usr/local/fast/
安装完后,服务脚本位置如下
[root@fastdfs software]# cd /usr/local/fast/FastDFS/ [root@fastdfs FastDFS]# ./make.sh [root@fastdfs FastDFS]# ./make.sh install
配置文件位置如下:
[root@fastdfs FastDFS]# cd /etc/init.d/ && ls | grep fdfs fdfs_storaged fdfs_trackerd [root@fastdfs init.d]#
FastDFS一系列执行脚本如下,可以看到有上传文件脚本、下载文件脚本等等。
[root@fastdfs init.d]# cd /etc/fdfs/ [root@fastdfs fdfs]# ll 总用量 20 -rw-r--r--. 1 root root 1461 4月 11 04:10 client.conf.sample -rw-r--r--. 1 root root 7829 4月 11 04:10 storage.conf.sample -rw-r--r--. 1 root root 7102 4月 11 04:10 tracker.conf.sample [root@fastdfs fdfs]#
3、因为FastDFS服务脚本设置的bin目录为/usr/local/bin/下,但是实际我们安装在了/u sr/bin/下面。所以我们需要修改FastDFS配置文件中的路径,也就是需要修改两个配置文件
[root@fastdfs fdfs]# cd /usr/bin/ && ls | grep fdfs fdfs_appender_test fdfs_appender_test1 fdfs_append_file fdfs_crc32 fdfs_delete_file fdfs_download_file fdfs_file_info fdfs_monitor fdfs_storaged fdfs_test fdfs_test1 fdfs_trackerd fdfs_upload_appender fdfs_upload_file [root@fastdfs bin]#
使用命令vim /etc/init.d/fdfs_storaged进入编辑模式,然后直接输入":",光标会定位到最后一行,在":"后输入"%s+/usr/local/bin+/usr/bin",如下图所示。输入完之后回车,会提示修改了7处。为了确保所有的/usr/local/bin都被替换了,我们可以再打开文件确认一下。 接着修改第二个配置文件,我们使用命令vim /etc/init.d/fdfs_trackerd进入编辑模式,接着按照上面那样输入":%s+/usr/local/bin+/usr/bin "并按回车,同样会提醒我们修改了7处。
第十步:配置跟踪器
1、进入到/etc/fdfs目录并且复制一份tracker.conf.sample并命名为tracker.conf,如下所示。
2、使用命令vim /etc/fdfs/tracker.conf进入编辑模式,然后修改base_path的值为/fastdfs/tracker,如下图所示。
[root@fastdfs bin]# cd /etc/fdfs/ [root@fastdfs fdfs]# ll 总用量 20 -rw-r--r--. 1 root root 1461 4月 11 04:10 client.conf.sample -rw-r--r--. 1 root root 7829 4月 11 04:10 storage.conf.sample -rw-r--r--. 1 root root 7102 4月 11 04:10 tracker.conf.sample [root@fastdfs fdfs]# cp tracker.conf.sample tracker.conf [root@fastdfs fdfs]#
/ 3、我们在上图配置文件中配置的/fastdfs/tracker目前是不存在的,因此我们需要创建一下该目录
[root@fastdfs fdfs]# mkdir -p /fastdfs/tracker [root@fastdfs fdfs]#
4、配置防火墙,放开tracker使用的端口22122,使用命令vim /etc/sysconfig/iptables进入编辑模式,添加一行内容-A INPUT -m state --state NEW -m tcp -p tcp --dport 22122 -j ACCEPT,如下图所示。
5、重启防火墙
6、在启动tracker之前,/fastdfs/tracker目录下是没有任何文件的,如下所示
[root@fastdfs fdfs]# service iptables restart iptables:将链设置为政策 ACCEPT:filter [确定] iptables:清除防火墙规则: [确定] iptables:正在卸载模块: [确定] iptables:应用防火墙规则: [确定] [root@fastdfs fdfs]#
启动tracker,启动完之后,可以看到这个目录下多了两个目录data和logs。如下所示。
[root@fastdfs tracker]# cd /fastdfs/tracker/ && ll 总用量 0 [root@fastdfs tracker]#
7、设置开机自启动,在rc.local文件中添加/etc/init.d/fdfs_trackerd start,如下所示。
[root@fastdfs tracker]# /etc/init.d/fdfs_trackerd start Starting FastDFS tracker server: [root@fastdfs tracker]# cd /fastdfs/tracker/ && ll 总用量 8 drwxr-xr-x. 2 root root 4096 4月 11 05:01 data drwxr-xr-x. 2 root root 4096 4月 11 05:01 logs [root@fastdfs tracker]#
第十一步:配置FastDFS存储
[root@fastdfs tracker]# vim /etc/rc.d/rc.local #!/bin/sh # # This script will be executed *after* all the other init scripts. # You can put your own initialization stuff in here if you don't # want to do the full Sys V style init stuff. touch /var/lock/subsys/local /etc/init.d/fdfs_trackerd start
1、进入/etc/fdfs目录,复制一份storage.conf.sample文件并命名为storage.conf,如下所示。
2、修改storage.conf文件 ,我们使用命令vim /etc/fdfs/storage.conf进入编辑模式,对以下四项进行修改,192.168.156.13是我的虚拟机的IP,大家根据自己虚拟机的IP自行设置。
[root@fastdfs tracker]# cd /etc/fdfs/ [root@fastdfs fdfs]# ll 总用量 28 -rw-r--r--. 1 root root 1461 4月 11 04:10 client.conf.sample -rw-r--r--. 1 root root 7829 4月 11 04:10 storage.conf.sample -rw-r--r--. 1 root root 7098 4月 11 04:45 tracker.conf -rw-r--r--. 1 root root 7102 4月 11 04:10 tracker.conf.sample [root@fastdfs fdfs]# cp storage.conf.sample storage.conf [root@fastdfs fdfs]# ll 总用量 36 -rw-r--r--. 1 root root 1461 4月 11 04:10 client.conf.sample -rw-r--r--. 1 root root 7829 4月 11 05:07 storage.conf -rw-r--r--. 1 root root 7829 4月 11 04:10 storage.conf.sample -rw-r--r--. 1 root root 7098 4月 11 04:45 tracker.conf -rw-r--r--. 1 root root 7102 4月 11 04:10 tracker.conf.sample [root@fastdfs fdfs]#
3、创建存储目录,如下所示。
base_path=/fastdfs/storage store_path0=/fastdfs/storage tracker_server=192.168.156.13:22122 http.server_port=8888
4、配置防火墙,允许外界访问storage的默认端口23000,如下所示。
[root@fastdfs fdfs]# mkdir -p /fastdfs/storage [root@fastdfs fdfs]#
添加完之后,重启防火墙,如下所示。
[root@fastdfs fdfs]# vim /etc/sysconfig/iptables # Firewall configuration written by system-config-firewall # Manual customization of this file is not recommended. *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 22122 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 23000 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT
5、在启动storage之前,/fastdbf/storage目录下是没有任何文件的
[root@fastdfs fdfs]# service iptables restart iptables:将链设置为政策 ACCEPT:filter [确定] iptables:清除防火墙规则: [确定] iptables:正在卸载模块: [确定] iptables:应用防火墙规则: [确定] [root@fastdfs fdfs]#
启动storage,启动后再看/fastdfs/storage目录,可以看到多了data和logs。
[root@fastdfs fdfs]# cd /fastdfs/storage/ && ll 总用量 0 [root@fastdfs storage]#
6、查看FastDFS tracker和storage 是否启动成功,当看到如下所示信息时说明都启动成功了。
[root@fastdfs storage]# /etc/init.d/fdfs_storaged start Starting FastDFS storage server: [root@fastdfs storage]# cd /fastdfs/storage/ && ll 总用量 8 drwxr-xr-x. 68 root root 4096 4月 11 05:21 data drwxr-xr-x. 2 root root 4096 4月 11 05:20 logs [root@fastdfs storage]#
7、我们进入到 /fastdfs/storage/data/目录下,可以看到两级共256*256个目录,每级都是从00到FF,如下只是列出了第一级的目录,点进去每个目录都还有00到FF共256个目录。
[root@fastdfs storage]# ps -ef | grep fdfs root 2124 1 0 05:01 ? 00:00:00 /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf root 2228 1 0 05:21 ? 00:00:00 /usr/bin/fdfs_storaged /etc/fdfs/storage.conf root 2238 1360 0 05:22 pts/0 00:00:00 grep fdfs [root@fastdfs storage]#
8、设置storage开机自启动,添加一行/etc/init.d/fdfs_storaged start,如下所示。
[root@fastdfs storage]# cd /fastdfs/storage/data/ && ls 00 09 12 1B 24 2D 36 3F 48 51 5A 63 6C 75 7E 87 90 99 A2 AB B4 BD C6 CF D8 E1 EA F3 FC 01 0A 13 1C 25 2E 37 40 49 52 5B 64 6D 76 7F 88 91 9A A3 AC B5 BE C7 D0 D9 E2 EB F4 FD 02 0B 14 1D 26 2F 38 41 4A 53 5C 65 6E 77 80 89 92 9B A4 AD B6 BF C8 D1 DA E3 EC F5 fdfs_storaged.pid 03 0C 15 1E 27 30 39 42 4B 54 5D 66 6F 78 81 8A 93 9C A5 AE B7 C0 C9 D2 DB E4 ED F6 FE 04 0D 16 1F 28 31 3A 43 4C 55 5E 67 70 79 82 8B 94 9D A6 AF B8 C1 CA D3 DC E5 EE F7 FF 05 0E 17 20 29 32 3B 44 4D 56 5F 68 71 7A 83 8C 95 9E A7 B0 B9 C2 CB D4 DD E6 EF F8 storage_stat.dat 06 0F 18 21 2A 33 3C 45 4E 57 60 69 72 7B 84 8D 96 9F A8 B1 BA C3 CC D5 DE E7 F0 F9 sync 07 10 19 22 2B 34 3D 46 4F 58 61 6A 73 7C 85 8E 97 A0 A9 B2 BB C4 CD D6 DF E8 F1 FA 08 11 1A 23 2C 35 3E 47 50 59 62 6B 74 7D 86 8F 98 A1 AA B3 BC C5 CE D7 E0 E9 F2 FB [root@fastdfs data]#
第十二步:测试图片上传
[root@fastdfs data]# vim /etc/rc.local #!/bin/sh # # This script will be executed *after* all the other init scripts. # You can put your own initialization stuff in here if you don't # want to do the full Sys V style init stuff. touch /var/lock/subsys/local /etc/init.d/fdfs_trackerd start /etc/init.d/fdfs_storaged start
1、进入到/etc/fdfs目录下并复制一份client.conf.sample并更名为client.conf,如下所示。
2、使用命令vim /etc/fdfs/client.conf进入编辑模式并修改如下两项内容,如下所示。
[root@fastdfs data]# cd /etc/fdfs [root@fastdfs fdfs]# ll 总用量 36 -rw-r--r--. 1 root root 1461 4月 11 04:10 client.conf.sample -rw-r--r--. 1 root root 7820 4月 11 05:12 storage.conf -rw-r--r--. 1 root root 7829 4月 11 04:10 storage.conf.sample -rw-r--r--. 1 root root 7098 4月 11 04:45 tracker.conf -rw-r--r--. 1 root root 7102 4月 11 04:10 tracker.conf.sample [root@fastdfs fdfs]# cp client.conf.sample client.conf [root@fastdfs fdfs]# ll 总用量 40 -rw-r--r--. 1 root root 1461 4月 11 05:40 client.conf -rw-r--r--. 1 root root 1461 4月 11 04:10 client.conf.sample -rw-r--r--. 1 root root 7820 4月 11 05:12 storage.conf -rw-r--r--. 1 root root 7829 4月 11 04:10 storage.conf.sample -rw-r--r--. 1 root root 7098 4月 11 04:45 tracker.conf -rw-r--r--. 1 root root 7102 4月 11 04:10 tracker.conf.sample [root@fastdfs fdfs]#
3、我们找到命令的脚本位置,并且使用命令,进行文件的上传。
base_path=/fastdfs/tracker tracker_server=192.168.156.13:22122
下面使用fdfs_upload_file脚本进行文件上传操作,如下所示。可以看到已经上传成功了,返回的是图片的保存位置:group1/M00/00/00/wKicDVjr_ayAE4VVAAHk-VzqZ6w020.jpg
[root@fastdfs bin]# cd /usr/bin/ && ls | grep fdfs fdfs_appender_test fdfs_appender_test1 fdfs_append_file fdfs_crc32 fdfs_delete_file fdfs_download_file fdfs_file_info fdfs_monitor fdfs_storaged fdfs_test fdfs_test1 fdfs_trackerd fdfs_upload_appender fdfs_upload_file [root@fastdfs bin]#
第十三步:FastDFS与nginx相结合
[root@fastdfs bin]# /usr/bin/fdfs_upload_file /etc/fdfs/client.conf /usr/local/software/3.jpg group1/M00/00/00/wKicDVjr_ayAE4VVAAHk-VzqZ6w020.jpg [root@fastdfs bin]#
1、先安装nginx,大家可以参考http://blog.csdn.net/u012453843/article/details/69396434这篇博客的第四步Nginx安装(我们已经安装过的vim、gcc等就不需要重复安装了)。
一、Nginx概念
Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,并在一个BSD-like 协议下发行。由俄罗斯的程序设计师Igor Sysoev所开发,供俄国大型的入口网站及搜索引擎Rambler(俄文:Рамблер)使用。其特点是占有内存少,并发能力强,事实上nginx的并发能力确实在同类型的网页服务器中表现较好,中国大陆使用nginx网站用户有:百度、京东、新浪、网易、腾讯、淘宝等。
二、负载均衡策略
1、使用硬件复杂均衡策略实现,如使用F5、Array等负载均衡器
2、使用软件进行负载均衡
2.1 使用阿里云服务器均衡负载SLB
2.2 使用Nginx+Keepalived
2.3 其它软件负载均衡如LVS(Linux Virtual Server)、haproxy等技术。
三、Nginx的优点
1、Nginx 可以在大多数 UnixLinux OS 上编译运行,并有 Windows 移植版。 Nginx 的1.4.0稳定版已经于2013年4月24日发布,一般情况下,对于新建站点,建议使用最新稳定版作为生产版本,已有站点的升级急迫性不高。Nginx 的源代码使用 2-clause BSD-like license。 2、Nginx 是一个很强大的高性能Web和反向代理服务器,它具有很多非常优越的特性: 在连接高并发的情况下,Nginx是Apache服务器不错的替代品:Nginx在美国是做虚拟主机生意的老板们经常选择的软件平台之一。能够支持高达 50,000 个并发连接数的响应,感谢Nginx为我们选择了 epoll and kqueue作为开发模型。
四、Nginx安装
如果大家是刚新建的虚拟机并且最小化安装的话,需要先配置静态IP并且要能上网,大家可以参考:http://blog.csdn.net/u012453843/article/details/52839105这篇博客进行学习,编辑文章用vi即可。配置好静态IP并且能上网之后需要先安装wget、vim和gcc。
yum install wget yum install vim-enhanced yum install make cmake gcc gcc-c++
1、下载nginx安装包
[root@nginx1 ~]# wget http://nginx.org/download/nginx-1.6.2.tar.gz --2017-04-07 01:44:55-- http://nginx.org/download/nginx-1.6.2.tar.gz 正在解析主机 nginx.org... 206.251.255.63, 95.211.80.227, 2606:7100:1:69::3f, ... 正在连接 nginx.org|206.251.255.63|:80... 已连接。 已发出 HTTP 请求,正在等待回应... 200 OK 长度:804164 (785K) [application/octet-stream] 正在保存至: “nginx-1.6.2.tar.gz”
2、安装依赖,其中pcre(perl compatible regular expressions)是一个pert库,包括perl兼容的正则表达式库。nginx的http模块使用pcre来解析正则表达式,所以需要在linux上安装pcre库。pcre-devel是使用pcre开发的一个二次库,nginx也需要此库。zlib库提供了很多种压缩的方式,nginx使用zlib对http包的内容进行gzip,所以需要在linux上安装zlib库。openssl是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的秘钥和证书封装管理功能及SSL协议,并提供丰富的应用程序提供测试或其它目的的使用。nginx不仅支持http协议,还支持https(即在ssl协议上传输http),所以需要在linux安装openssl库。
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel
3、解压nginx-1.6.2.tar.gz到/usr/local/目录下
[root@nginx1 ~]# tar -zxvf nginx-1.6.2.tar.gz -C /usr/local/
4、进入到/usr/local目录下,可以看到我们解压后的nginx-1.6.2文件夹了,然后我们进行configure配置,命令:cd nginx-1.6.2 && ./configure --prefix=/usr/local/nginx。可以看出,这条命令是组合命令,先进入nginx-1.6.2目录然后在执行./configure命令。如下图所示。
5、编译安装
[root@nginx1 nginx-1.6.2]# make && make install
6、启动Nginx,启动完之后检查nginx是否已经正常启动,看到如下信息说明正常启动。
如果要关闭nginx,我们可以使用如下命令:
[root@nginx1 nginx-1.6.2]# /usr/local/nginx/sbin/nginx [root@nginx1 nginx-1.6.2]# ps -ef | grep nginx root 3640 1 0 04:40 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx nobody 3641 3640 0 04:40 ? 00:00:00 nginx: worker process root 3643 1368 0 04:40 pts/0 00:00:00 grep nginx [root@nginx1 nginx-1.6.2]#
[root@nginx1 nginx-1.6.2]# /usr/local/nginx/sbin/nginx -s stop
如果想要重新热启动nginx,则使用如下命令:
[root@nginx1 nginx-1.6.2]# /usr/local/nginx/sbin/nginx -s reload
7、nginx默认的端口是80,我们需要在防火墙配置中添加80端口:"-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT"从而可以让外界访问80端口,否则防火墙将禁止外界访问80端口。如下所示。
添加完80端口之后,我们重启防火墙,如下所示。
[root@nginx1 nginx-1.6.2]# vim /etc/sysconfig/iptables # Firewall configuration written by system-config-firewall # Manual customization of this file is not recommended. *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT
[root@nginx1 nginx-1.6.2]# service iptables restart iptables:将链设置为政策 ACCEPT:filter [确定] iptables:清除防火墙规则: [确定] iptables:正在卸载模块: [确定] iptables:应用防火墙规则: [确定]
8、通过浏览器访问nginx欢迎页,我们在地址栏输入:http://192.168.156.11/(80端口不用输也可以)或http://192.168.156.11:80/,如下图所示。
五、学习nginx配置
1、当启动过nginx之后,我们到/usr/local/nginx目录下,可以看到有conf、html、logs、sbin四个文件这四个文件是刚解压后就有的,是nginx重要的文件,还可以看到几个_temp结尾的文件,这些都是启动后生成的文件,我们暂且不用去管它们。我们使用cd conf命令进入conf目录,该目录下有个nginx.conf文件,这是nginx最重要的文件,我们修改nginx就是修改该文件,如下所示。
nginx.conf文件的内容如下( 注:我把注释给加上了):
[root@nginx1 nginx-1.6.2]# cd /usr/local/nginx [root@nginx1 nginx]# ll 总用量 36 drwx------. 2 nobody root 4096 4月 7 05:16 client_body_temp drwxr-xr-x. 2 root root 4096 4月 7 04:37 conf drwx------. 2 nobody root 4096 4月 7 05:16 fastcgi_temp drwxr-xr-x. 2 root root 4096 4月 7 04:37 html drwxr-xr-x. 2 root root 4096 4月 7 05:16 logs drwx------. 2 nobody root 4096 4月 7 05:16 proxy_temp drwxr-xr-x. 2 root root 4096 4月 7 04:37 sbin drwx------. 2 nobody root 4096 4月 7 05:16 scgi_temp drwx------. 2 nobody root 4096 4月 7 05:16 uwsgi_temp [root@nginx1 nginx]# cd conf [root@nginx1 conf]# ll 总用量 60 -rw-r--r--. 1 root root 1034 4月 7 04:37 fastcgi.conf -rw-r--r--. 1 root root 1034 4月 7 04:37 fastcgi.conf.default -rw-r--r--. 1 root root 964 4月 7 04:37 fastcgi_params -rw-r--r--. 1 root root 964 4月 7 04:37 fastcgi_params.default -rw-r--r--. 1 root root 2837 4月 7 04:37 koi-utf -rw-r--r--. 1 root root 2223 4月 7 04:37 koi-win -rw-r--r--. 1 root root 3957 4月 7 04:37 mime.types -rw-r--r--. 1 root root 3957 4月 7 04:37 mime.types.default -rw-r--r--. 1 root root 2656 4月 7 04:37 nginx.conf -rw-r--r--. 1 root root 2656 4月 7 04:37 nginx.conf.default -rw-r--r--. 1 root root 596 4月 7 04:37 scgi_params -rw-r--r--. 1 root root 596 4月 7 04:37 scgi_params.default -rw-r--r--. 1 root root 623 4月 7 04:37 uwsgi_params -rw-r--r--. 1 root root 623 4月 7 04:37 uwsgi_params.default -rw-r--r--. 1 root root 3610 4月 7 04:37 win-utf [root@nginx1 conf]#
#user nobody; #开启进程数关注打赏最近更新
- 深拷贝和浅拷贝的区别(重点)
- 【Vue】走进Vue框架世界
- 【云服务器】项目部署—搭建网站—vue电商后台管理系统
- 【React介绍】 一文带你深入React
- 【React】React组件实例的三大属性之state,props,refs(你学废了吗)
- 【脚手架VueCLI】从零开始,创建一个VUE项目
- 【React】深入理解React组件生命周期----图文详解(含代码)
- 【React】DOM的Diffing算法是什么?以及DOM中key的作用----经典面试题
- 【React】1_使用React脚手架创建项目步骤--------详解(含项目结构说明)
- 【React】2_如何使用react脚手架写一个简单的页面?


微信扫码登录