Linux 安装Nginx详细步骤
1. 下载nginx http://nginx.org/download/nginx-1.18.0.tar.gz 并将下载的压缩包scp到指定服务器
2.选定安装目录 ,下载安装依赖
cd /usr/loca/src
yum install gcc
yum install pcre-devel
yum install zlib zlib-devel
yum install openssl openssl-devel
3. 安装nginx
cd /usrl/local
解压nginx包
cd /nginx
执行配置 ./configure --with-http_ssl_module
编译安装 make && make install
4. 启动 进入sbin 目录 然后执行 ./nginx
报错:nginx: [alert] could not open error log file: open() "/usr/local/nginx/logs/error.log" failed (2: No such file or directory) 2020/06/03 16:13:36 [emerg] 24173#0: open() "/usr/local/nginx/logs/access.log" failed (2: No such file or directory)
原来是没有找到日志目录,解决方法 新建logs目录。再次启动 ./nginx
默认端口是80 访问到,则说明安装启动成功。
Wellcome to nginx!
5. 其他nginx命令
./nginx -t 检测配置文件
./nginx -s reload 重启
./nginx -s stop 关闭nginx
ps -ef | grep nginx 查看nginx 进程
kill -HUP [Nginx主进程号(即ps命令查到的PID)] 平滑重启