新公司网站怎么做推广,通过网站做跳板,临沂网站建设微信,自己搭建个人网站的注意事项目录 一、nginx的简介二、nginx安装实验虚拟主机的配置web服务器的主流实现方式-LAMP和LNMP 一、nginx的简介
Nginx是一款轻量级HTTP服务器#xff0c;同时也是代理邮箱服务器#xff0c;具备反向代理#xff0c;通用代理的功能。支持多个系统#xff0c;和不同操作系统。… 目录 一、nginx的简介二、nginx安装实验虚拟主机的配置web服务器的主流实现方式-LAMP和LNMP 一、nginx的简介
Nginx是一款轻量级HTTP服务器同时也是代理邮箱服务器具备反向代理通用代理的功能。支持多个系统和不同操作系统。一般用来搭建web服务器和ftp服务器。 特点
支持高并发优化后最高可支持百万并发连接内存资源消耗低高扩展性采用模块化设计并支持第三方模块高可靠性采用master—woker模式工作woker出现故障master有可以开一个新woker来提供服务。
二、nginx安装实验 nginx安装 yum install nginx 常用的nginx命令
检查nginx配置文件 nginx -t
查看nginx版本nginx -v
查看nginx版本编译器版本配置参数等nginx -V
启动niginx systemctl start nginx.service
在这里我启动不了一看是我的apache服务也开着的就需要把服务关了不然端口占用netstat -anp | grep 80 查看端口 /etc/nginx/conf.d/ -------子配置文件目录
/etc/nginx/nginx.conf-----主配置文件
/usr/share/nginx/html/----为默认的nginx网址根目录
/var/log/nginx/ ---------为默认日志目录实验我采用的阿里云服务器搭建因为我是大学生有阿里云的免费服务器
[rootgang ~]# yum install nginx -y
[rootgang ~]# systemctl start nginx.service
[rootgang ~]# cd /usr/share/nginx/html/
[rootgang html]# echo xixi index.html
一般来说云上是没有防火墙selinux的但是需要在云上加安全组去阿里云把80端口放行然后通过在浏览器输入公网ip地址能看到xixi哟。在这里我们需要注意的是目录的权限问题有时候我们在其他系统中创建一个目录是发现权限不是755这个时候会发现访问不了报403的错误
虚拟主机的配置
在nginx服务器中通过不同的端口号完成虚拟主机的配置。 在/data目录创建3个不同的目录nginx1nginx2nginx3。
[rootgang data]# mkdir nginx{1..3}
[rootgang data]# echo hello,nginx1 nginx1/index.html
[rootgang data]# echo hello,nginx2 nginx2/index.html
[rootgang data]# echo hello,nginx3 nginx3/index.html
/etc/nginx/conf.d/ 写子配置文件注意以。conf结尾
[rootgang data]# vim /etc/nginx/conf.d/vhost.conf
[rootgang data]# systemctl reload nginx.service
[rootgang data]# curl localhost:81
hello,nginx1
[rootgang data]# curl localhost:82
hello,nginx2
[rootgang data]# curl localhost:83
hello,nginx3nginx的子配置文件
server{listen 81;server_name localhost;location / {root /data/nginx1;index index.html;}
}
server{listen 82;server_name localhost;location / {root /data/nginx2;index index.html;}
}
server{listen 83;server_name localhost;location / {root /data/nginx3;index index.html;}
}基于ip的不同虚拟主机也是一样的只需要在listen 8.123.234.180就行。修改监听的参数就行后期最好给每个虚拟主机做一个日志文件。 基于名称的虚拟主机也只需要修改server_name的参数就行,还要写一个hosts。 nginx的主配置文件中的location参数有几个优先级 location (^~)(*)(location部分起始路径) (/) location模块中可开启autoindex功能表示对访问目录进行索引 注意这个目录没有index.html才行 参数 autoindex on 达到下面这种效果。 如果location是一个目录的话后面是需要跟/的。
web服务器的主流实现方式-LAMP和LNMP
Lweb服务器所依赖的操作系统 A和N表示Apache和Nginx来实现web服务器 M表示mysql用来存储数据的 Pphp以及其他编程语言
安装mysql5.7在清华镜像中下载。
wget https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-5.7-community-el7-x86_64/mysql-community-common-5.7.28-1.el7.x86_64.rpm
wget https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-5.7-community-el7-x86_64/mysql-community-libs-5.7.28-1.el7.x86_64.rpm
wget https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-5.7-community-el7-x86_64/mysql-community-client-5.7.28-1.el7.x86_64.rpm
wget https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-5.7-community-el7-x86_64/mysql-community-server-5.7.28-1.el7.x86_64.rpm[rootmanged mysql]# yum install *.rpm 安装