nginx二进制:
1.下载方式有两种:
(1)yum -y install nginx //这个版本一般不太新
(2)自己配置nginx源:去nginx官网www.nginx.org 点击稳定版本,有配置文档,在vim /etc/yum.repos.d/nginx.repo注意要更改的地方,最后yum -y install nginx 安装的就是新版本了。
2.启动方式:systemctl start nginx
3.自启动脚本:不需要写自启动脚本,默认在 /usr/lib/systemd/system/nginx.service
4.nginx默认命令的使用:安装上直接可以使用
5.配置文件路径:主配置文件/etc/nginx/nginx.conf 子配置文件/etc/nginx/conf.d/default.conf 有两个配置文件
6.默认首页路径:/usr/share/nginx/html
nginx源码:
1.下载方式:wget http://nginx.org/download/nginx-1.15.3.tar.gz 编译安装
还需要安装gcc提供一个编译环境
[root@nginx nginx-1.15.3]# ./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/tmp/nginx/client \
--http-proxy-temp-path=/var/tmp/nginx/proxy \
--http-fastcgi-temp-path=/var/tmp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
--http-scgi-temp-path=/var/tmp/nginx/scgi \
--with-pcre \
--with-file-aio \
--with-http_secure_link_module\ // 模块很多,这只是其中一部分,用到什么添加什么模块就行
2.启动方式:/usr/local/nginx/sbin/nginx
并在/etc/rc.d/rc.local 下写上/usr/local/nginx/sbin/nginx,并记得给/etc/rc.d/rc.local 执行权限
3.自启动方式:需要自己 vim /usr/lib/systemd/system/nginx.service脚本
[root@nginx nginx]# cat /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target
[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/bin/kill -s 21449
ExecStop=/bin/kill -s 21449
[Install]
WantedBy=multi-user.target
4.nginx默认命令的使用:不能直接使用,需在/etc/bashrc或/etc/profile中重新配置环境变量
export PATH=$PATH:/usr/local/nginx/sbin/
5.配置文件路径:/usr/local/nginx/conf/nginx.conf 源码主配置文件和自配置文件都在nginx.conf中写着,只有一个配置文件
6.首页路径:/usr/local/nginx/html/