环境:
操作系统版本:openEuler release 20.03 (LTS)
nginx版本:nginx-1.24.0
操作:
1.tar -zxvf nginx-1.24.0.tar.gz
2.cd nginx-1.24.0
3. ./configure --prefix=/usr/local/nginx(可能会出现error,情况如下)
情形一:
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
解决方式:
yum install -y pcre pcre-devel
情形二:
./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.
解决方式:
yum -y install zlib zlib-devel
情形三:
缺少gcc
解决方式:
yum install -y gcc
没有errors的回显如下:
Configuration summary
+ using system PCRE library
+ OpenSSL library is not used
+ using system zlib library
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx modules path: "/usr/local/nginx/modules"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
4.make and make install
到此基础安装操做基本结束。
启动方式:
进入安装好的目录 cd /usr/local/nginx
ls的输出如下:
conf html logs sbin
命令:(基于该路径下 /usr/local/nginx/sbin)
./nginx (启动)
./nginx -s stop (快速停止)
./nginx -s quit (退出前完成已经接受的连接请求)
./nginx -s reload (重新加载)
查看启动状态:
[root@localhost sbin]# ps -ef | grep nginx
root 17449 1 0 03:00 ? 00:00:00 nginx: master process ./nginx
nobody 17451 17449 0 03:00 ? 00:00:00 nginx: worker process
root 17476 11400 0 03:00 pts/0 00:00:00 grep --color=auto nginx
[root@localhost sbin]#
此时curl ip 返回结果为403
解决方式:vi nginx.conf 将user设为root
user root;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
页面验证结果:
Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.
Thank you for using nginx.