网站首页 > 技术教程 正文
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
到此已经配置好,可直接使用域名登录相应的项目
猜你喜欢
- 2024-10-11 CentOS安装nginx并配置SSL证书(nginx安装ssl模块)
- 2024-09-19 Linux(CentOS )手动搭建LNMP(Linux+Nginx+Mysql+PHP)坏境
- 2024-09-19 CentOS7.5安装nginx(centos7.5安装ftp服务)
- 2024-09-19 如何在阿里云Centos下安装Nginx(阿里云centos安装源)
- 2024-09-19 CentOS7编译安装Nginx(centos7编译安装gcc)
- 2024-09-19 Linux Centos7.4 Nginx的安装(linux nginx安装)
- 2024-09-19 Centos 7安装jdk+部署springboot项目+搭建配置nginx小白基础流程
- 2024-09-19 Nginx无脑小白教程之安装篇(Centos7&源码安装)
- 2024-09-19 centos 7 安装nginx(centos 7 安装黑屏)
- 2024-09-19 nginx 在centos 离线安装(nginx离线安装与配置详解)
你 发表评论:
欢迎- 最近发表
-
- Linux新手必看:几种方法帮你查看CPU核心数量
- linux基础命令之lscpu命令(linux中ls命令的用法)
- Linux lscpu 命令使用详解(linux常用ls命令)
- 如何查询 Linux 中 CPU 的数量?这几个命令要知道!
- 在linux上怎么查看cpu信息(linux如何查看cpu信息)
- 查看 CPU 的命令和磁盘 IO 的命令
- 如何在CentOS7上改变网卡名(centos怎么改网卡名字)
- 网工必备Linux网络管理命令(网工必备linux网络管理命令是什么)
- Linux 网络命令知多少(linux 网络 命令)
- Linux通过命令行连接wifi的方式(linux命令行连接无线网)
- 标签列表
-
- 下划线是什么 (87)
- 精美网站 (58)
- qq登录界面 (90)
- nginx 命令 (82)
- nginx .http (73)
- nginx lua (70)
- nginx 重定向 (68)
- Nginx超时 (65)
- nginx 监控 (57)
- odbc (59)
- rar密码破解工具 (62)
- annotation (71)
- 红黑树 (57)
- 智力题 (62)
- php空间申请 (61)
- 按键精灵 注册码 (69)
- 软件测试报告 (59)
- ntcreatefile (64)
- 闪动文字 (56)
- guid (66)
- abap (63)
- mpeg 2 (65)
- column (63)
- dreamweaver教程 (57)
- excel行列转换 (56)
本文暂时没有评论,来添加一个吧(●'◡'●)