1. Tout d'abord, recherchez l'emplacement du fichier de configuration nginx. Le fichier nginx.conf sur Alibaba Cloud se trouve dans /alidata/server/nginx-1.4.4/conf.
2. Créez ensuite un répertoire vhosts dans le répertoire conf. Ce répertoire sert à stocker les fichiers de configuration des différents sites.
3. Ensuite, ajoutez une ligne à la fin de nginx.conf 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"'; # 加入下面一行 表示将 vhosts 下面所有的 conf 文件包含进来 include /alidata/server/nginx/conf/vhosts/*.conf; }
server { listen 80; # 这个表示 网站域名, 可以是二级甚至多级域名 server_name localhost demo.com www.demo.com test.demo.com; # 表示默认索引文件 index index.html index.htm index.php; # 该站点对应的网站根目录所在 root /alidata/www/demo; location ~ .*\.(php|php5)?$ { #fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 1h; } # 伪静态规则 include /alidata/server/nginx/conf/rewrite/phpwind.conf; access_log /alidata/log/nginx/access/phpwind.log; }
./nginx
./nginx -s reload
ps -ef | grep nginx # 查询nginx主进程号
./nginx -t
Ce qui précède est le contenu détaillé de. pour plus d'informations, suivez d'autres articles connexes sur le site Web de PHP en chinois!