记录实际工作中用到的一点东西。避免忘记,也给大家参考
按顺序执行以下步骤
1.安装gcc gcc是用来编译下载下来的nginx源码
yum install gcc-c++
2.安装pcre和pcre-devel
PCRE(Perl Compatible Regular Expressions) 是一个Perl库,包括 perl 兼容的正则表达式库。
nginx 的 http 模块使用 pcre 来解析正则表达式,pcre-devel 是使用 pcre 开发的一个二次开发库。
yum install -y pcre pcre-devel
3.安装zlib zlib提供了很多压缩和解方式,nginx需要zlib对http进行gzip
yum install -y zlib zlib-devel
4.安装openssl openssl是一个安全套接字层密码库,nginx要支持https,需要使用openssl
yum install -y openssl openssl-devel
5 .cd到usr/local目录下面,下载nginx (没有wget的话就先yum install wget)
wget http://nginx.org/download/nginx-1.14.0.tar.gz
6.解压
tar -zxvf nginx-1.14.0.tar.gz
7.编译(全部复制用)
./configure --prefix=/usr --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/tem/nginx/client --http-proxy-temp-path=/var/tem/nginx/proxy --http-fastcgi-temp-path=/var/tem/nginx/fcgi --with-http_stub_status_module
9.安装
make && make install
10.启动
nginx -c /etc/nginx/nginx.conf
11 . 如果出现[emerg] getpwnam(“nginx”) failed 错误 执行
useradd -s /sbin/nologin -M nginx
id nginx
12.如果出现 [emerg] mkdir() “/var/temp/nginx/client” failed (2: No such file or directory) 错误 执行
sudo mkdir -p /var/tem/nginx/client
最后进localhost:8080 看一下是否启动。
后续关闭后再打开的方法:
whereis nginx
cd 到对对应的目录下面 执行 ./nginx 就ok了