1 locate nginx.conf
2 如果服务器中存在多个nginx.conf文件,必须找到实际调用的配置文件。
a)ps aux|grep nginx
在结果列表中,找到master process之后的目录,
copy一份, -t,回车,即可查看到实际调用的nginx.conf。
b)nginx -t 找到实际调用的配置文件路径及是否调用有效。
在控制台输入nginx -t
回车即可看到所在目录,直接vi 目录 即可查看
Linux环境下,怎么确定Nginx是以那个config文件启动的?
输入命令行: ps -ef | grep nginx
摁回车,将出现如下图片:
master process 后面的就是 nginx的目录。
怎么查看服务器上安装的nginx版本号,主要是通过ngix的-v或-V选项,查看方法如下图所示:
-v 显示 nginx 的版本。
-V 显示 nginx 的版本,编译器版本和配置参数。
如何联系我:【万里虎】www.bravetiger.cn 【QQ】3396726884 (咨询问题100元起,帮助解决问题500元起) 【博客】http://www.cnblogs.com/kenshinobiy/
Nginx 安装与部署
一 准备
腾讯云服务器/centos7系统
Nginx:nginx-1.13.1
二 安装
Nginx依赖
-gcc、gcc-c++
yum install gcc
yum install gcc-c++
-pcre、zlib
yum -y install pcre*
yum -y install zlib*
-openssl
yum -y install openssl
yum -y install openssl-devel
-Nginx安装
下载Nginx安装包
wget http://nginx.org/download/nginx-1.13.1.tar.gz
解压
tar -z -xv -f nginx-1.13.1.tar.gz
配置
cd nginx-1.13.1
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-pcre //会报错
./configure --prefix=/usr/local/nginx //那就执行这个
–prefix:设置安装路径
–with-http_stub_status_module:支持nginx状态查询
–with-http_ssl_module:支持https
–with-pcre:为了支持rewrite重写功能,必须制定pcre
编译
make
make install
make install 这条指令需要当前文件夹下有Makefile才能成功
启动
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
测试(关闭防火墙)
访问http://ip/
Nginx 多域名绑定
实现最终结果:一个ip绑定多个域名
准备
-安装好Nginx
还未安装好可参考博主的另一文章:Nginx 安装与部署
-域名
申请的域名需要实名验证备案通过才可以使用,详情咨询服务商
实现
找到nginx.conf配置文件
# nginx安装位置查找
[root@VM_0_3_centos ~]# find / -name nginx.conf
/usr/local/nginx/conf/nginx.conf
/usr/local/nginx/conf/beifen/nginx.conf
/root/nginx-1.13.1/conf/nginx.conf
# nginx配置文件所在地
[root@VM_0_3_centos ~]# cd /usr/local/nginx/conf/
[root@VM_0_3_centos conf]# ls
beifen koi-utf nginx.conf.default vhost
fastcgi.conf koi-win scgi_params win-utf
fastcgi.conf.default mime.types scgi_params.default
fastcgi_params mime.types.default uwsgi_params
fastcgi_params.default nginx.conf uwsgi_params.default
打开配置文件
[root@VM_0_3_centos conf]# vi nginx.conf
...
http{
...
#新增一句话 目录自定义
#nginx会自动执行一遍vhost目录下的所有配置文件 使之生效
include ./vhost/*.conf;
server {
...
}
...
}
...
进入自定义路径中添加配置文件
配置好 站点域名 网站运行的目录 网站运行的html
[root@VM_0_3_centos conf]# cd vhost/
[root@VM_0_3_centos vhost]# ls
nginx_fk.conf nginx_hctf.conf nginx_map.conf
[root@VM_0_3_centos vhost]# cat nginx_fk.conf
server {
listen 80; # 监听端口
server_name fk.creatorhy.com creatorhy.com; # 站点域名
root /usr/local/nginx/html/fangkuai/; # 站点根目录
index index.html index.htm index.php; # 默认导航页
location / {
# WordPress固定链接URL重写
if (!-e $request_filename) {
rewrite (.*) /index.php;
}
}
# PHP配置
location ~ .php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
域名解析配好
Nginx指令
[root@VM_0_3_centos ~]# cd /usr/local/nginx/sbin/
# nginx配置文件是否有错
[root@VM_0_3_centos sbin]# ./nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
# nginx重启服务
[root@VM_0_3_centos sbin]# ./nginx -s reload
到此已经配置好,可直接使用域名登录相应的项目
1 locate nginx.conf
2 如果服务器中存在多个nginx.conf文件,必须找到实际调用的配置文件。
a)ps aux|grep nginx
在结果列表中,找到master process之后的目录,
copy一份, -t,回车,即可查看到实际调用的nginx.conf。
b)nginx -t 找到实际调用的配置文件路径及是否调用有效。
转载于:https://www.cnblogs.com/mydesky2012/p/11460608.html
{"moduleinfo":{"card_count":[{"count_phone":1,"count":1}],"search_count":[{"count_phone":4,"count":4}]},"card":[{"des":"阿里云文件存储NAS是一个可共享访问,弹性扩展,高可靠,高性能的分布式文件系统。广泛应用于容器存储、大数据分析、Web 服务和内容管理、应用程序开发和测试、媒体和娱乐工作流程、数据库备份。支持冷热数据分级存储,平均有效存储成本可低至 0.19元/月GB","link1":"https://www.aliyun.com/product/nas","link":"https://www.aliyun.com/product/nas","icon":"https://img.alicdn.com/tfs/TB1SisTRFXXXXbEXpXXXXXXXXXX-128-128.png","btn2":"折扣套餐","tip":"高性价比NAS新品上线,容量型NAS限时99元起! 立即查看","btn1":"立即开通","link2":"https://www.aliyun.com/product/nas","title":"文件存储 NAS"}],"search":[{"txt":"NAS新手入门","link":"https://m.aliyun.com/markets/aliyun/nas_edu01"},{"txt":"产品价格","link":"https://www.aliyun.com/price/product?spm=5176.149973.776685.6.ID90rH#/nas/detail"},{"txt":"最佳实践","link":"https://help.aliyun.com/document_detail/54998.html"},{"txt":"常见问题","link":"https://help.aliyun.com/knowledge_list/42175.html?spm=5176.59209.972911.4.3f6d3f62SVIECT"}],"countinfo":{"search":{"length_pc":0,"length":0},"card":{"length_pc":0,"length":0}},"simplifiedDisplay":"newEdition","newCard":[{"ifIcon":"icon","link":"https://img.alicdn.com/tfs/TB1XY8hGYr1gK0jSZFDXXb9yVXa-1740-328.png","icon":"nas","title":"文件存储 NAS","contentLink":"https://www.aliyun.com/product/nas?spm=5176.10695662.776724.1.27543d3eTvR5Bi","des":"阿里云文件存储(Network Attached Storage)是面向阿里云ECS、HPC和Docker的共享文件存储服务,支持linux和window客户端多种标准文件访问协议,无限容量及性能扩展、单一命名空间,企业级安全防护。","btn1":"立即开通","link1":"https://www.aliyun.com/product/nas?spm=5176.10695662.776724.2.27543d3eTvR5Bi","btn2":"产品文档","link2":"https://help.aliyun.com/product/27516.html?spm=5176.cnnas.0.0.42216689Kvc7ZO","link3":"https://nasnext.console.aliyun.com/overview?spm=5176.cnnas.0.0.42216689Kvc7ZO","btn3":"管理控制台","infoGroup":[{"infoName":"产品入门","infoContent":{"firstContentName":"NAS使用流程","firstContentLink":"https://help.aliyun.com/document_detail/148430.html?spm=a2c4g.11174283.6.564.b9c74da2J1uIZi","lastContentName":"挂载NAS到系统","lastContentLink":"https://help.aliyun.com/document_detail/27526.html?spm=a2c4g.11186623.6.566.1872495fTbU32y"}},{"infoName":"最新动态","infoContent":{"firstContentName":"极速型性能提升340%","firstContentLink":"https://yq.aliyun.com/articles/761833?spm=5176.cnnas.0.0.25216689DjruaG","lastContentName":"NAS低频型发布","lastContentLink":"https://yq.aliyun.com/articles/762197?spm=5176.cnnas.0.0.25216689DjruaG"}}]}]}
{"$env":{"JSON":{}},"$page":{"env":"production"},"$context":{"moduleinfo":{"card_count":[{"count_phone":1,"count":1}],"search_count":[{"count_phone":4,"count":4}]},"card":[{"des":"阿里云文件存储NAS是一个可共享访问,弹性扩展,高可靠,高性能的分布式文件系统。广泛应用于容器存储、大数据分析、Web 服务和内容管理、应用程序开发和测试、媒体和娱乐工作流程、数据库备份。支持冷热数据分级存储,平均有效存储成本可低至 0.19元/月GB","link1":"https://www.aliyun.com/product/nas","link":"https://www.aliyun.com/product/nas","icon":"https://img.alicdn.com/tfs/TB1SisTRFXXXXbEXpXXXXXXXXXX-128-128.png","btn2":"折扣套餐","tip":"高性价比NAS新品上线,容量型NAS限时99元起! 立即查看","btn1":"立即开通","link2":"https://www.aliyun.com/product/nas","title":"文件存储 NAS"}],"search":[{"txt":"NAS新手入门","link":"https://m.aliyun.com/markets/aliyun/nas_edu01"},{"txt":"产品价格","link":"https://www.aliyun.com/price/product?spm=5176.149973.776685.6.ID90rH#/nas/detail"},{"txt":"最佳实践","link":"https://help.aliyun.com/document_detail/54998.html"},{"txt":"常见问题","link":"https://help.aliyun.com/knowledge_list/42175.html?spm=5176.59209.972911.4.3f6d3f62SVIECT"}],"countinfo":{"search":{"length_pc":0,"length":0},"card":{"length_pc":0,"length":0}},"simplifiedDisplay":"newEdition","newCard":[{"ifIcon":"icon","link":"https://img.alicdn.com/tfs/TB1XY8hGYr1gK0jSZFDXXb9yVXa-1740-328.png","icon":"nas","title":"文件存储 NAS","contentLink":"https://www.aliyun.com/product/nas?spm=5176.10695662.776724.1.27543d3eTvR5Bi","des":"阿里云文件存储(Network Attached Storage)是面向阿里云ECS、HPC和Docker的共享文件存储服务,支持linux和window客户端多种标准文件访问协议,无限容量及性能扩展、单一命名空间,企业级安全防护。","btn1":"立即开通","link1":"https://www.aliyun.com/product/nas?spm=5176.10695662.776724.2.27543d3eTvR5Bi","btn2":"产品文档","link2":"https://help.aliyun.com/product/27516.html?spm=5176.cnnas.0.0.42216689Kvc7ZO","link3":"https://nasnext.console.aliyun.com/overview?spm=5176.cnnas.0.0.42216689Kvc7ZO","btn3":"管理控制台","infoGroup":[{"infoName":"产品入门","infoContent":{"firstContentName":"NAS使用流程","firstContentLink":"https://help.aliyun.com/document_detail/148430.html?spm=a2c4g.11174283.6.564.b9c74da2J1uIZi","lastContentName":"挂载NAS到系统","lastContentLink":"https://help.aliyun.com/document_detail/27526.html?spm=a2c4g.11186623.6.566.1872495fTbU32y"}},{"infoName":"最新动态","infoContent":{"firstContentName":"极速型性能提升340%","firstContentLink":"https://yq.aliyun.com/articles/761833?spm=5176.cnnas.0.0.25216689DjruaG","lastContentName":"NAS低频型发布","lastContentLink":"https://yq.aliyun.com/articles/762197?spm=5176.cnnas.0.0.25216689DjruaG"}}]}]}}