In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to configure nginx and tomcat to access pictures and static pages, the article is very detailed, has a certain reference value, interested friends must read it!
In a production environment, sometimes you need to access pictures, and you normally need to use ftp, nginx and other supporting applications, but sometimes in order to simplify, you can use the following two simple visits, to be honest, just to be lazy, but the effect is there, and that's it, so do this simplified version today to facilitate your emergency use.
The first method: under nginx configuration
1. Create a file path:
[root@localhost /] # mkdir / data/soft/ [root@localhost ~] # cd / data/soft/ [root@localhost soft] # mkdir html images
2. Put the picture under the images directory
[root@localhost soft] # cd images/ [root@localhost images] # ll Total usage 80-rw-r--r--. 1 root root 9503 April 25 17:06 thPZFULFJN.jpg-rw-r--r--. 1 root root 16083 April 25 17:06 thR2C5VCMZ.jpg-rw-r--r--. 1 root root 12218 April 25 17:06 thRG3YX53T.jpg-rw-r--r--. 1 root root 15048 April 25 17:06 thSUF51VTR.jpg-rw-r--r--. 1 root root 21799 April 25 17:06 thVWSLF8ZE.jpg
3. Put a test file in the html directory
[root@localhost html] # cat index.html this is test page!
4. Install nginx and start
Choose yum or compile to see what you like. I choose to compile and make my own installation module.
Extract the three packages of pcre-8.34.tar.gz zlib-1.2.8.tar.gz openssl-1.0.1g.tar.gz and install them
Tar-zxvf pcre-8.34.tar.gz cd pcre-8.34 / configure & & make & & make install tar-zxvf zlib-1.2.8.tar.gz cd zlib-1.2.8 / configure & & make & & make install tar-zxvf openssl-1.0.1g.tar.gz cd openssl-1.0.1g / config & & make & & make install
Install Nginx
Tar-zxvf nginx-1.9.0.tar.gz cd nginx-1.9.0 #. / configure-- prefix=/data/soft/nginx\-- user=www\-- group=www\-- with-mail\-- with-mail_ssl_module\-- with-http_ssl_module\-with-http_flv_module\-- with-http_dav_module\-- with-http_sub_module\-- with-http_spdy_module\ -- with-http_realip_module\-- with-http_addition_module\-- with-http_gzip_static_module\-- with-http_stub_status_module\-- with-pcre=/data/src/pcre-8.34\-- with-zlib=/data/src/zlib-1.2.8\-with-openssl=/data/src/openssl-1.0.1g
Compile and install
Make & & make install groupadd www useradd-g www www
Modify nginx configuration file
[root@localhost nginx] # vim conf/nginx.conf server {listen 80; server_name localhost; # charset koi8-r; # access_log logs/host.access.log main; location ~. *\. (gif | jpg | jpeg | png) ${expires 24h; root / data/soft/images/;# specifies the image storage path access_log / data/soft/nginx/logs/images.log;# log storage path proxy_store on Proxy_store_access user:rw group:rw all:rw; proxy_temp_path / data/soft/images/;# image access path proxy_redirect off; proxy_set_header Host 127.0.0.1; client_max_body_size 10m; client_body_buffer_size 1280k; proxy_connect_timeout 900; proxy_send_timeout 900; proxy_read_timeout 900; proxy_buffer_size 40k; proxy_buffers 40 320k Proxy_busy_buffers_size 640k; proxy_temp_file_write_size 640k; if (!-e $request_filename) {proxy_pass http://127.0.0.1;# default port 80}} location / {root / data//soft/html; # html access path index index.html index2.htm; # html file name}} error_page 404 / 404.html
5. You can test it at this time.
First, the html page.
Looking at the picture.
Obviously, static pages and pictures can be accessed successfully under nginx settings, so let's start with tomcat access settings
The second method: tomcat
1. View the jdk version
Java-version openjdk version "1.8.0-65" OpenJDK Runtime Environment (build 1.8.0_65-b17) OpenJDK 64-Bit Server VM (build 25.65-b01, mixed mode)
2. Decompress tomcat and start it
Tar-xvf apache-tomcat-8.5.30.tar.gz [root@localhost tomcat] # sh bin/startup.sh
3. Can you access the local test
4, the above is normal, then put the page folder under wepapps, notice that there are inde.html pages in the html folder.
[root@localhost soft] # cp-rp html/ / data/soft/tomcat/webapps/
Test access to the html page
Continue to put the pictures folder under wepapps, where there are pictures under images.
[root@localhost images] # cp-rp / data/soft/images/ / data/soft/tomcat/webapps/
Visit the following directly on the browser
Summary: in this way, simple picture access and html page access can be used, very convenient, these two methods are very suitable for the intranet environment, for operation and maintenance is a good choice.
The above is all the content of the article "how to configure nginx and tomcat to access pictures and static pages". Thank you for reading! Hope to share the content to help you, more related knowledge, 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.