每次在Linux搭建web环境都要一顿google求参考文档,此次索性写个简单的文章记录一下。其实Linux下编译安装主要就是这几个步骤。
linux
安装编译工具、依赖包及下载源码包nginx
解压编译c++
安装web
启动centos
$ yum -y install gcc gcc-c++ autoconf automake $ yum -y install zlib zlib-devel openssl openssl-devel pcre-devel
以上安装的是一些主要的依赖包,具体可根据本身状况或者报错信息提示安装或修改bash
新建的用户组和用户主要是在编译配置的时候指定nginx运行的用户和用户组。这样指定后之后配置使用也方便。工具
$ sudo groupadd -r nginx $ sudo useradd -s /sbin/nologin -g nginx -r nginx
我通常从官网下载google
wget http://nginx.org/download/nginx-1.10.0.tar.gz
tar -zxvf nginx-1.10.0.tar.gz
./configure \ --prefix=/usr/local/nginx \ --conf-path=/etc/nginx/nginx.conf \ --user=nginx \ --group=nginx \
配置没毛病的话能够看到这些信息centos7
Configuration summary + using system PCRE library + OpenSSL library is not used + md5: using system crypto library + sha1: using system crypto library + using system zlib library nginx path prefix: "/usr/local/nginx" nginx binary file: "/usr/local/nginx/sbin/nginx" nginx modules path: "/usr/local/nginx/modules" nginx configuration prefix: "/etc/nginx" nginx configuration file: "/etc/nginx/nginx.conf" nginx pid file: "/usr/local/nginx/logs/nginx.pid" nginx error log file: "/usr/local/nginx/logs/error.log" nginx http access log file: "/usr/local/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"
以上编译参数只是配置了主要的东西,所有配置参数说明你能够经过这个命令查看./configure --help
code
$ make && make install
启动等命令
须进入到/usr/local/nginx/sbin
目录下
$ nginx
$ nginx -s stop
$ nginx -s reload
以上各个步骤报错的话根据报错提示缺啥装啥,不犯几回错误都很差意思说本身配过环境。PS:有问题可留言讨论哦