nginx的安装配置
安装
- 首先使用wget命令下载Nginx,前提已经安装了wget命令。已经安装过 的请忽略:
yum -y install wget
wget http://nginx.org/download/nginx-1.16.0.tar.gz
- 安装编译工具及相应的库
yum -y install vim gcc gcc-c++ automake autoconf libtool make pcre-devel openssl openssl-devel zlib zlib-devel
- .安装Nginx
cd /usr/local
mkdir nginx
cd nginx
# 1.解压文件
tar -xzvf nginx-1.16.0.tar.gz
# 2.进入目录,编译文件
cd nginx-1.16.0
# 3.编译,指定编译到/usr/local/nginx目录下
./configure --prefix=/usr/local/nginx
# 4.安装
make && make install
- 如果出现如下错误;
make: *** No rule to make targetbuild', needed by
default’. Stop. - 执行
yum install -y gcc pcre pcre-devel openssl openssl-devel gd gd-devel
- 进到nginx目录
./configure \
--prefix=/usr/local/nginx \
--pid-path=/usr/local/nginx/run \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--with-pcre \
--with-http_image_filter_module \
--with-debug \
- 再次编译
make && make install
- 访问 ip:80
- nginx -s reload 重新启动nginx (重新加载配置文件),如果报错如下:
-bash: LL: command not found
解决办法:
vi /etc/profile
#加上如下配置:
#nginx
PATH=$PATH:/usr/local/nginx/sbin
export PATH
#linux 使资源生效
source /etc/profile
报错如下:
[error] open() “/usr/local/nginx/logs/nginx.pid” failed (2: No such file or directory)
解决办法
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
- 再次执行nginx -s reload 重新启动nginx。Ok