Linux 安装 nginx
1. 在 Linux 上安装 nginx 所以要的依赖环境
yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
2. 下载 nginx 并放入 Linux 服务器上
http://nginx.org/en/download.html
3. 解压 nginx
tar -xvf nginx-1.20.1.tar.gz
4. 配置
- 切换进 nginx 目录下 运行 nginx 配置文件 configure
./configure
5. 编译并安装
make && make install
6. 如何启动
安装成功之后在usr 中多出local/nginx 文件夹 ,在nginx中 有 sbin 启动脚本
7.启动
在 sbin 目录下 ./nginx
启动
8.查看进程
ps -ef|grep nginx
9.如何访问
-
回退到 nginx 目录 , 在其中有一个 conf 目录 ,文件夹下 nginx.conf , 查看其端口
-
操作:
vi nginx.conf
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
- 端口为默认的 80 端口
10. 访问测试
在其他电脑浏览器访问Linux 服务器地址 并添加端口号 :80 测试