linux 安装并配置 nginx
-
安装编译需要的依赖
yum -y install gcc pcre-devel zlib-devel openssl openssl-devel
-
下载nginx,可自行查看最新版本下载
wget https://nginx.org/download/nginx-1.19.2.tar.gz
-
解压
tar -zxvf nginx-1.19.2.tar.gz
-
指定编译时安装的路径
cd nginx-1.19.2 ./configure --prefix=/uer/local/nginx
-
编译安装
make //编译 make install //安装
-
启动
cd /usr/local/nginx/sbin ./nginx
-
其他命令
关闭 ./nginx -s quit 或者 ./nginx -s stop 重启 /nginx -s reload 查看进程 ps aux|grep nginx
-
查看效果,在打开了80端口之后,输入公网ip即可。
-
相关配置,修改
/usr/local/nginx/conf
里面的nginx.conf文件cd /usr/local/nginx/conf vim nginx.conf
如下图:server下面的listen 为端口,默认为80端口。
server_name 为地址,默认localhost即本机的公网ip,如果本机进行了域名解析,可用域名替代