In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains the "nginx server multi-site configuration", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "nginx server multi-site configuration" bar!
1. The first step is to find the location of the nginx configuration file, which is located in the nginx.conf file / alidata/server/nginx-1.4.4/conf on Ali Cloud.
2. Then create a vhosts directory under the conf directory, which is used to store configuration files for different sites.
3. Then, at the end of the nginx.conf, add a line include / alidata/server/nginx/conf/vhosts/*.conf
User www www; worker_processes 1; error_log / alidata/log/nginx/error.log crit; pid / alidata/server/nginx/logs/nginx.pid; # specifies the value for maximum file descriptors that can be opened by this process. Worker_rlimit_nofile 65535; events {use epoll; worker_connections 65535;} http {include mime.types; default_type application/octet-stream; # charset gb2312; server_names_hash_bucket_size 128; client_header_buffer_size 32k; large_client_header_buffers 4 32k; client_max_body_size 8m; sendfile on; tcp_nopush on; keepalive_timeout 60; tcp_nodelay on; fastcgi_connect_timeout 300 Fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 64k; fastcgi_buffers 4 64k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 128k; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.0; gzip_comp_level 2; gzip_types text/plain application/x-javascript text/css application/xml; gzip_vary on; # limit_zone crawler $binary_remote_addr 10m Log_format'$remote_addr-$remote_user [$time_local] "$request"'$status $body_bytes_sent "$http_referer"'"$http_user_agent"$http_x_forwarded_for"; # add the following line to include all conf files under vhosts include / alidata/server/nginx/conf/vhosts/*.conf;}
4. Then, write the conf file of your corresponding site in the vhosts directory. Here is an example
Server {listen 80; # this represents the domain name of the website, which can be a second-level or even multi-level domain name server_name localhost demo.com www.demo.com test.demo.com; # represents the default index file index index.html index.htm index.php; # the root / alidata/www/demo where the root directory of the site corresponds to the site Location ~. *\. (php | php5)? ${# fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_pass 127.0.0.1 fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_pass 9000; fastcgi_index index.php; include fastcgi.conf;} location ~. *\. (gif | jpg | jpeg | png | swf) ${expires 30d;} location ~. *\. (js | css)? ${expires 1h } # pseudo static rule include / alidata/server/nginx/conf/rewrite/phpwind.conf; access_log / alidata/log/nginx/access/phpwind.log;}
5. If you want to continue to add, copy the file directly. Then modify server_name, root, and access_log (if necessary) to ok.
6. Then, instead of restarting nginx immediately, you should first test whether the nginx configuration file is working. Find the sbin directory of nginx. Notice that this place is nginx's sbin directory (this directory is the same level as nginx's conf directory). There are many directories with the same name as sbin under linux. It's easy to get wrong. The default directory on Ali CVM is / alidata/server/nginx-1.4.4/sbin.
7. Enter cd / alidata/server/nginx-1.4.4/sbin, and then enter. / nginx- t. If the console displays the following two lines, the configuration is successful, otherwise please continue to check the configuration file according to the prompts.
Nginx: the configuration file / alidata/server/nginx/conf/nginx.conf syntax is ok
Nginx: configuration file / alidata/server/nginx/conf/nginx.conf test is successful
8. After the configuration is successful, you need to restart the nginx server. Type the command:. / nginx-s reload in the sbin directory, and the whole process is done.
In addition, summarize a few common nginx commands:
Start
. / nginx
Restart
. / nginx-s reload
Close
Ps-ef | grep nginx # query nginx main process number
Stop the kill-quit main process number calmly
Quick stop kill-term main process number
Forcibly stop kill-9 nginx
If nginx.conf is configured with the pid file path, if not, then under the logs directory
Kill-signal type'/ usr/local/nginx/logs/nginx.pid'
Determine whether the configuration file is correct
. / nginx-t Thank you for reading, the above is the content of "how to configure nginx server multi-site". After the study of this article, I believe you have a deeper understanding of how to configure nginx server multi-site, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.