1.创建用于管理网站服务的系统账户。
-M参数不创建对应的家目录,-s参数指定登录后的Shell解释器为/sbin/nologin,确保不能通过这个账号登录主机。
[root@dsrw lnmp]# useradd nginx -M -s /sbin/nologin
[root@dsrw lnmp]# id nginx
uid=1001(nginx) gid=1001(nginx) 组=1001(nginx)
2.编译安装Nginx网站服务程序。
[root@dsrw lnmp]# tar xzvf nginx-1.16.0.tar.gz
[root@dsrw lnmp] cd nginx-1.16.0
[root@dsrw nginx-1.16.0]./configure --prefix=/usr/local/nginx --with-http_ssl_module
[root@dsrw nginx-1.16.0]make
[root@dsrw nginx-1.16.0]make install
[root@dsrw nginx-1.16.0]cd ..
3.配置Nginx(/usr/local/nginx)
[root@dsrw ~]# vim /usr/local/nginx/conf/nginx.conf
2 user nginx nginx;
45 index index.php index.html index.htm;
65 location ~ \.php$ {
66 root html;
67 fastcgi_pass 127.0.0.1:9000;
68 fastcgi_index index.php;
69 fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
70 include fastcgi_params;
71 }
4.配置/usr/local/nginx/sbin路径加入到PATH变量中,只需要输入nginx命令即可启动网站服务。
[root@dsrw ~]# vim ~/.bash_profile
PATH=$PATH:$HOME/bin:/usr/local/nginx/sbin
[root@dsrw ~]# source ~/.bash_profile
[root@dsrw ~]# nginx
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
[root@dsrw sbin]# killall -9 nginx
[root@dsrw ~]# nginx
[root@dsrw ~]# fuser -k 80/tcp
[root@dsrw ~]# sudo fuser -k 80/tcp
[root@dsrw ~]# nginx
5.浏览器输入本机IP
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
请登录后查看评论内容