Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install and configure Integrated Nginx-1.13.3 for FastDFS

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

In this article, the editor introduces in detail "how to install and configure integrated Nginx-1.13.3 for FastDFS". The content is detailed, the steps are clear, and the details are handled properly. I hope that this article "how to install and configure integrated Nginx-1.13.3 for FastDFS" can help you solve your doubts.

One: download fastdfs

We need a total of three documents

1.fastdfs distributed file storage system

2.libfastcommon fastdfs function library

3.fastdfs-nginx-module connection nginx function module

Please note when downloading that the format downloaded here is .zip and not tar.gz. This is because there are errors when using the fastdfs-nginx-module module to integrate nginx, because the fastdfs version must be > = 5.11. Otherwise, an error will be reported when compiling nginx. You can take a look at the module's install file, which contains instructions. Since the maximum version released by fastdfs is only 5.10, the author has not updated the version to 5.11. But the code on github has been updated, so you can download it directly. Here is the author's github address.

Note: extracting files in zip format requires that the system has already installed unzip software. If you don't have it, you can use the command to install: yum install zip unzip

For the convenience of installation, you can switch to root permission during the operation.

After the download is complete, upload the folder to the server

Once again, remind me that the files here are in zip format. Use the command unzip filename to extract each zip file one by one. For example: unzip fastdfs-master

The following is the situation after decompression. Because I don't like the suffix with master, it is deleted after decompression. You can use commands to manipulate mv oldfilename newfilename

For example: mv fastdfs-master fastdfs

Two: install fastdfs

1. Install the fastdfs library

After decompressing, enter the libfastcommon directory cd libfastcommon first

Compile the file. / make.sh

Install:. / make.sh install

After the installation is complete, enter the same installation mode as fastdfs cd fastdfs and libfastcommon

Compile the file. / make.sh

Install:. / make.sh install

After the installation is complete, you can see two directories, which will be used later

Three: configuration

1. Configuration description

The configuration file should be configured differently according to the server. In this article, tracker server and storage server are installed on a server.

two。 Configuration file directory

After the installation is complete, a fdfs folder will be generated under / etc and go to the fast configuration file directory cd / etc/fdfs/. You can see the sample file that ends with .sample.

For convenience, use the command to delete all the above files rm-f *, and then copy all the files in the / fastdfs/conf directory to the / etc/fdfs directory.

Note: / fastdfs/conf is the decompressed fastdfs directory

3. Configure and start tracker server

Open the tracker.conf file vim. / tracker.conf, change the base_path path to your own directory, port, etc., and do not modify it without occupation.

After the modification is complete, try to start tracker / usr/bin/fdfs_trackerd / etc/fdfs/tracker.conf start

Note: the base_path path needs to be created in advance, otherwise an error will be reported: error info: no such file or directory

After the command is executed, it is found that there is no response, then use the command netstat-unltp | grep fdfs to see if it starts

You can see that tracker server has been listening on port 22122.

4. Configure and start storage server

Next, modify the storage.conf configuration file vim storage.conf. After opening the file, modify the base_path path as well as the tracker server address and store_path. The port address and group name remain unchanged.

Tracker server address:

Store_path address:

Note: the above tracker server address should be set to the corresponding address of the server. If the port has not been modified, it remains the default.

If the store_path path is not modified, the storage server service cannot be started. Without any prompts, you can open the storaged.log file in the / fastdfs/logs folder to see the error message.

Ok, after the modification is completed, start storage, / usr/bin/fdfs_storaged / etc/fdfs/storage.conf start, again without any response. Then use the command netstat-unltp | grep fdfs to see if it starts

The above figure shows that tracker server and storage server have been started successfully.

5. Test upload service

Next, open the client.conf configuration file vim client.conf, and you only need to modify base_path and tracker_server.

When the modification is complete, see if you can upload the file. There happens to be a picture in the directory.

Use the command to upload pictures

/ usr/bin/fdfs_test / etc/fdfs/client.conf upload. / anti-steal.jpg

When you see a long string of characters above, ok uploads successfully. And successfully returned the picture address. Look under the storage directory and find that there are a few more pictures. If one of the pictures has the same suffix as the product image, then the file has been stored locally.

Although the image address is returned, the http protocol is no longer supported by fastdfs. Http support has been removed in version 4.0.5, so it cannot be accessed directly through the image address. So we integrate nginx through the fastdfs module to provide http services.

four。 Integrate nginx and fastdfs

1. Integration module

It is assumed here that you have installed nginx and its dependent packages. If you have not already installed nginx, please see my other article: centos7 installing nginx

You don't need to install the fastdfs module to integrate nginx, just add the fastdfs-nginx-module module when you configure nginx. Let's start to configure nginx and go to the configuration file under the nginx directory.

. / configure-prefix=/opt/nginx-with-pcre=/home/mgame/soft/pcre-8.41-with-openssl=/home/mgame/soft/openssl-1.1.0f-with-zlib=/home/mgame/soft/zlib-1.2.11-add-module=/home/mgame/soft/fastdfs-nginx-module/src

Compile make

Install make install

If the following error occurs during installation, please check the install file in the module for the requirements for the fastdfs version (the fastdfs version of this article must be > = 5.11 as stated at the beginning).

Error: 'fdfshttpparams' has no member named' support_multi_range' (pcontext- > range_count > 1 & &! g_http_params.support_multi_range))

After the module has been added to nginx and installed, go to the nginx installation directory / opt/nginx/conf and open the nginx.conf configuration file.

Note: the nginx directory here is set when configuring nginx, please open the file according to their respective settings.

Add the following configuration to the file and leave the other port settings unchanged.

Location / group1/m00 {ngx_fastdfs_module;}

Note: / group must be preceded by a slash, otherwise when accessed, the root path is the nginx installation directory.

two。 Configure module parameters

After the setup is complete, if you start nginx directly now, you will find that it is still not accessible through the previous successfully uploaded image address. In a puzzled situation, the thought of nginx does not have a logs folder to record details such as login and error messages.

Then open the error.log file and have a look. Ok found the problem.

There are two bright error, and the first line explains the cause of the error: file / etc/fdfs/mod_fastdfs.conf not exist does not have a mod_fastdfs.conf file in the / etc/fdfs/ directory. The file is in the src directory of the module fastdfs-nginx-module

Now that you have found the file location, go to the / fastdfs-nginx-module/src directory and copy the file mod_fastdfs.conf to the / etc/fdfs/ directory command: cp mod_fastdfs.conf / etc/fdfs/

After the operation is completed, open the mod_fastdfs.conf configuration file vim mod_fastdfs.conf that you just copied, with the parameters of tracker_server, url_have_group_name, and store_path0, respectively.

Tracker_server:

Url_have_group_name:

Note: because the accessed address contains the group name group1, if the generated address does not contain the group name, you do not need to set it.

Store_path0:

After the modification is completed, go to the / opt/nginx/sbin directory, restart nginx. / nginx-s reload, and then visit the address of the image returned after the previous upload.

After configuration, the files stored in fastdfs have been successfully accessed.

After reading this, the article "how to install and configure integrated Nginx-1.13.3 for FastDFS" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself. If you want to know more about related articles, welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report