nginx安装笔记
安装nginx
1、yum安装相关库、编译工具。
[root@test /]# yum install {prce-devel,pcre,openssl-devel,openssl,gcc} -y
2、创建程序账户。
[root@test /]# useradd nginx -s /bin/nologin -M
3、下载安装包、解压、安装、编译。
[root@test /]# wget https://nginx.org/download/nginx-1.21.6.tar.gz
[root@test /]# tar -xf nginx-1.21.6.tar.gz
[root@test /]# cd nginx-1.6.0/
[root@test nginx-1.6.0]# ./configure --prefix=/app/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module
##有以下输出:
Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ md5: using OpenSSL library
+ sha1: using OpenSSL library
+ using system zlib library
nginx path prefix: "/app/nginx"
nginx binary file: "/app/nginx/sbin/nginx"
nginx configuration prefix: "/app/nginx/conf"
nginx configuration file: "/app/nginx/conf/nginx.conf"
nginx pid file: "/app/nginx/logs/nginx.pid"
nginx error log file: "/app/nginx/logs/error.log"
nginx http access log file: "/app/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"
[root@test nginx-1.6.0]# make && make install
##有以下输出
......
x/conf/nginx.conf'
cp conf/nginx.conf '/app/nginx/conf/nginx.conf.default'
test -d '/app/nginx/logs' || mkdir -p '/app/nginx/logs'
test -d '/app/nginx/logs' || mkdir -p '/app/nginx/logs'
test -d '/app/nginx/html' || cp -R html '/app/nginx'
test -d '/app/nginx/logs' || mkdir -p '/app/nginx/logs'
make[1]: Leaving directory `/root/nginx/nginx-1.6.0'
4、启动、检查是否启动。
[root@test sbin]# /app/nginx/sbin/nginx
[root@test sbin]# ps -ef | grep nginx
root 22396 1 0 19:30 ? 00:00:00 nginx: master process /app/nginx/sbin/nginx
nginx 22397 22396 0 19:30 ? 00:00:00 nginx: worker process
root 22521 121489 0 19:30 pts/1 00:00:00 grep --color=auto nginx
5、访问测试。
[root@test nginx]# curl 192.168.184.150:80
Welcome to nginx!
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.
6、常用文件。
/app/nginx/html/index.html #html文件
/app/nginx/sbin/nginx #nginx的脚本文件
/app/nginx/conf/nginx.conf #nginx的配置文件
/app/nginx/logs/access.log #nginx的访问日志