Install nginx and FDFS configuration under Ubuntu19

Install nginx and FDFS configuration under Ubuntu19

One, nginx installation**

1. The nginx and fdfs installation packages and related dependencies:
link: https://pan.baidu.com/s/1H3uy1WxYcRq_99eJkRN9oQ
extraction code: gywq Insert picture description here
2. First install the dependencies:
apt-get install build-essential
apt-get install libtool
apt-get install libpcre3 libpcre3-dev
apt-get install zlib1g-dev
apt-get install openssl
apt-get install libssl-dev
3. Configure nginx
(1) Execute tar -zxvf nginx-1.10.tar.gz to decompress the file
(2) Enter the nginx directory: cd nginx-1.10
(3) Execute the configuration file command in this directory:
./configure --prefix=/usr/local/nginx --with-http_ssl_module
(4) Execute make to compile,
Insert picture description here
(6) After the compilation is complete, execute make install to install nginx (you can also use make && make install)
(7) After the installation is complete, you can see the nginx folder under the usr/local folder that we configured before Insert picture description here
(8) enter usr/local You can see the configuration file nginx.conf in the /nginx/conf directory, modify this fileInsert picture description here
(9) Start nginx:
Insert picture description here
(10) Pause nginx: service nginx stop
(11) Restart loading: nginx -s reload
(12) Check the process number Insert picture description here
(13) Verify that the nginx configuration file is correct:
Type ./nginx -t to Insert picture description here
see the above The figure shows that the configuration is correct.
(14) File location after installation:

/usr/sbin/nginx: main program

/etc/nginx: store configuration files

/usr/share/nginx: store static files

/var/log/nginx: Store logs
(15) Set the service script to have execution authority
sudo chmod +x /etc/init.d/nginx #register
service
cd /etc/init.d/
sudo update-rc.d nginx defaults

Second, the installation of FDFS

[1] FastDFS installation
Install fastdfs dependency package:
unzip libfastcommon-master.zip, execute unzip libfastcommon-master.zip
into the libfastcommon-master directory,
execute ./make.sh && ./make.sh install
[2] install fastdfs
unzip fastdfs-master.zip: execute tar -xvf FastDFS_v5.08.tar.gz to
enter the fastdfs-master directory
execute ./make.sh && ./make.sh install
[3] enter the /etc/fdfs/ directory Next, check if there are these two files
Insert picture description here
[3] Configure the tracking server tracker and storage
cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf
cp /etc/fdfs/storage.conf.sample / etc/fdfs/storage.conf
[4] Open tracker.confand modify the base_pathconfiguration:
base_path=/leyou/fdfs/tracker # Tracker’s data and log storage directory
[5] Create a directory, the directory just configured may not exist, we create
sudo mkdir -p /leyou/fdfs/tracker
[6] Start tracker
sudo service fdfs_trackerd start # Start the fdfs_trackerd service, stop using stop
[7] Configure the tracking server storage
sudo cp storage.conf.sample storage.conf
sudo vim storage.conf
open storage.conf, modify the base_pathconfiguration
base_path=/leyou/fdfs/storage # storage data And log storage directory
store_path0=/leyou/fdfs/storage # storage upload file storage path
tracker_server=xxx.xxx.xxx.xxx:22122 # tracker address (xxx is the virtual machine address)
the directory just configured may not exist, we Created to
start storage: sudo service fdfs_storaged start # start fdfs_storaged service, stop using stop and
finally, ps -ef | grep fdfsview the process through : ()

Three, install Nginx and FastDFS module

(1) Unzip fastdfs-nginx-module_v1.16.tar.gz:
tar -xvf fastdfs-nginx-module_v1.16.tar.gz
(2) Configure config file:
enter the configuration directory
cd /home/leyou/fdfs/fastdfs- nginx-module/src/
modify the configuration: vim config
execute the following command (change /usr/local in the configuration to /usr):
:%s+/usr/local/+/usr/+g (remember to add:)
( 3) Configure mod_fastdfs.conf
to copy mod_fastdfs.conf in the src directory to the /etc/fdfs directory:
sudo cp mod_fastdfs.conf /etc/fdfs/
(4) Edit the file
sudo vim /etc/fdfs/mod_fastdfs.cof, modify The following configuration:
connect_timeout=10
tracker_server=xxx.xxx.xxx.xxx:22122
url_have_group_name=true
store_path0=/leyou/fdfs/storage
(5) Copy part of the FastDFS configuration file to the /etc/fdfs directory
cd /home/leyou/fdfs /FastDFS/conf/
cp http.conf mime.types /etc/fdfs/
(6) Enter the nginx installation directory and execute the command:
sudo ./configure --prefix=/opt/nginx --sbin-path=/usr/bin/nginx --add-module=/home/leyou/fdfs/fastdfs-nginx -module/src is
compiling, no need to install:
(7) Just execute make
(8) Modify the /usr/local/nginx/nginx.conf file and
add the following code
server { listen 80; server_name image.taotao. com;

	# 监听域名中带有group的,交给FastDFS模块处理
    location ~/group([0-9])/ {
        ngx_fastdfs_module;
    }

    location / {
        root   html;
        index  index.html index.htm;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }
    
}
(9)重新启动nginx: nginx -s reload # 重新加载配置

At this point, complete! ! ! ! !

Guess you like

Origin blog.csdn.net/Anna_Liqi/article/details/105019013