nginx-1.24手动安装基于类centos系统环境安装

将下载的 nginx-1.24.0.tar.gz 放到 /root/to_install

1、在 /usr/local/ 下创建 nginx⽂件夹并进⼊

cd /usr/local/
mkdir nginx
cd nginx

2、将 Nginx 安装包解压到 /usr/local/nginx中即可

 tar zxvf /root/to_install/nginx-1.24.0.tar.gz -C ./

预先安装额外依赖

yum -y install pcre-devel
yum -y install openssl openssl-devel

ubuntu额外安装的对应openssl

apt-get install libssl-dev

编译安装nginx

cd nginx-1.17.10
./configure
make && make install

安装完成后nginx可执行文件位于该目录下

/usr/local/nginx/sbin/

如果想停⽌Nginx服务,可执⾏:

/usr/local/nginx/sbin/nginx -s stop

如果修改了配置⽂件后想重新加载Nginx,可执⾏:

/usr/local/nginx/sbin/nginx -s reload

配置文件位于

/usr/local/nginx/conf/nginx.conf

验证配置文件

/usr/local/nginx/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

 /usr/local/nginx/sbin/nginx

服务器上验证

 curl 127.0.0.1
<html>
<head><title>403 Forbidden</title></head>
<body>
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx/1.24.0</center>
</body>
</html>

问题错误
访问不到nginx的登录欢迎界面,发现进程中的用户不同

参考解决方案
https://blog.csdn.net/m0_37477061/article/details/82979041

修改nginx配置

# user nobody;
user  root; # 所有权修改为root

........
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;
}
......

posted @ 2024-06-26 16:41  Justin99  阅读(100)  评论(0编辑  收藏  举报