Linux配置Nginx

假设什么都没安。

1、# yum install gcc-c++

nginx是C语言开发的,在官网上下的源码需要编译,依赖gcc环境。

2、# yum install -y pcre pcre-devel

pcre是一个Perl库,包括Perl兼容的正则表达式库,nginx的http模块使用pcre来解析正则表达式 。

3、# yum install -y zlib zlib-devel

zlib库提供了很多压缩和解压缩的方式,nginx用zlib对http包进行gzip。

4、# yum install -y openssl openssl-devel

openssl是一个安全套接字层密码库,nginx支持http协议和https协议(在ssl协议上传输http)。

5、# wget http://nginx.org/download/nginx-1.8.0.tar.gz

(这是下载的1.8.0版本的)

6、# tar -zxvf nginx-1.8.0.tar.gz

解压压缩文件。

7、# cd nginx-1.8.0

进入到解压的文件下,进行操作。

8、一大波操作哦。。。。

# ./configure \

>--prefix=/usr/local/nginx \

>--pid-path=/var/run/nginx/nginx.pid \

>--lock-path=/var/lock/nginx.lock \

>--error-log-path=/var/log/nginx/error.log \

>--http-log-path=/var/log/nginx/access.log \

>--with-http_gzip_static_module \

>--http-client-body-temp-path=/var/temp/nginx/client \

>--http-proxy-temp-path=/var/temp/nginx/proxy \

>--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \

>--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \

>--http-scgi-temp-path=/var/temp/nginx/scgi

9、# mkdir /var/temp/nginx

待会要用到这个目录哦。

10、# make 

# make install

编译安装

11、#cd /usr/local/nginx/sbin/

# ./nginx

启动nginx

12、# ps aux|grep nginx

查看一下进程,看到俩进程(master process、worker process)就表示成功咯!

13、在windows上输入linux IP,会看到(Welcome to nginx!)

14、# systemctl stop firewalld.service

如果看不到页面,有可能是防火墙的问题,先简单粗暴关闭防火墙。

15、# ./nginx -s stop

关闭nginx。

16、# ./nginx -s reload

可以随时刷新,运行的同时可以修改。

猜你喜欢

转载自blog.csdn.net/sanmao123456_/article/details/80377957