Warning: Error while sending QUERY packet. PID=5475 in /home/wwwroot/coco/domain/cnlamp/web/wp-includes/wp-db.php on line 1924 ubuntu nginx 配置虚拟主机 | LAMP新闻|技巧|经验|资讯站
现在的位置: 首页WEB服务器>正文
ubuntu nginx 配置虚拟主机
发表于7年前 WEB服务器 暂无评论
1、cd进入/etc/nginx/sites-available,建立一个新文件,一般以你的域名为文件名,例如:www.xx.com
2、复制代码:
   server {
listen   80; ## listen for ipv4; this line is default and implied
#listen   [::]:80 default ipv6only=on; ## listen for ipv6
root /var/www/www.xx.com; #你网站所在目录的绝对路径
index index.php index.html index.htm; #目录索引
# Make site accessible from http://localhost/
server_name www.xx.com; #网站的域名
location / {
index index.html index.htm index.php;  #目录索引
rewrite ^/(.*)$ /index.php/$1 last;  #Rewrite 隐藏index.php
}
#使nginx支持php
location ~ ^(.+\.php)(.*)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include /etc/nginx/fastcgi_params;
}
}
3、建立软连接到sites-enable里面去
ln -s /etc/nginx/sites-available/www.xxx.com /etc/nginx/sites-enabled/www.xxx.com

给我留言

留言无头像?


×
腾讯微博