Ubuntu 搭建LNMP环境图文教程 安装Nginx服务器
<p>跟MySQL安装一样,先进入“/usr/local/src”中,键入“cd /usr/local/src”回车,进入到文件夹中,接着键入“sudo wget http://nginx.org/download/nginx-0.8.37.tar.gz”回车,等待下载完毕。<br>
下载完毕后,执行“sudo tar zxvf nginx-0.8.37.tar.gz”回车解压文件。<br><img style="max-width:100%!important;height:auto!important;"title="Ubuntu 搭建LNMP环境图文教程 安装Nginx服务器" alt="Ubuntu 搭建LNMP环境图文教程 安装Nginx服务器" data-image="5919" id="image-5919" src="https://zhuji.jb51.net/uploads/img/20230519/1720bf17956039db0ad6d9e0e49d0fc8.jpg"><br>
然后进入nginx源码目录,配置安装操作。键入“cd nginx-0.8.37”回车,再执行“sudo ./configure --prefix=/usr/local/server/nginx --with-http_stub_status_module”。<br><img style="max-width:100%!important;height:auto!important;"title="Ubuntu 搭建LNMP环境图文教程 安装Nginx服务器" alt="Ubuntu 搭建LNMP环境图文教程 安装Nginx服务器" data-image="5920" id="image-5920" src="https://zhuji.jb51.net/uploads/img/20230519/0a21f08d4edfef027eec491f74f45575.jpg"><br>
配置完成后,开始编译源码包。键入“sudo make && make install”回车,等待操作结束。<br><img style="max-width:100%!important;height:auto!important;"title="Ubuntu 搭建LNMP环境图文教程 安装Nginx服务器" alt="Ubuntu 搭建LNMP环境图文教程 安装Nginx服务器" data-image="5921" id="image-5921" src="https://zhuji.jb51.net/uploads/img/20230519/28d05473524104b0cb324480629fe27c.jpg"><br>
将附件中的nginx.sh复制到/etc/init.d/nginx,键入“sudo cp nginx.sh /etc/init.d/nginx”回车,再执行“sudo chmod +x /etc/init.d/nginx”。<br><img style="max-width:100%!important;height:auto!important;"title="Ubuntu 搭建LNMP环境图文教程 安装Nginx服务器" alt="Ubuntu 搭建LNMP环境图文教程 安装Nginx服务器" data-image="5922" id="image-5922" src="https://zhuji.jb51.net/uploads/img/20230519/6dcb83baabd7d71f2f7639cef675f576.jpg"><br>
启动nginx,执行“sudo /etc/init.d/nginx start”启动服务器。<br><img style="max-width:100%!important;height:auto!important;"title="Ubuntu 搭建LNMP环境图文教程 安装Nginx服务器" alt="Ubuntu 搭建LNMP环境图文教程 安装Nginx服务器" data-image="5923" id="image-5923" src="https://zhuji.jb51.net/uploads/img/20230519/a39c0f7eece5031da3787cde2125bda3.jpg"><br>
浏览器输入“http://127.0.0.1”回车,显示如下页面,说明服务器成功启动。<br><img style="max-width:100%!important;height:auto!important;"title="Ubuntu 搭建LNMP环境图文教程 安装Nginx服务器" alt="Ubuntu 搭建LNMP环境图文教程 安装Nginx服务器" data-image="5924" id="image-5924" src="https://zhuji.jb51.net/uploads/img/20230519/e134202a80c281e5b59848f0977e7e5a.jpg"><br>
停止服务器输入命令“sudo /etc/init.d/nginx stop”。</p>
<p>
<span>课程附件nginx.sh</span></p>
<div>
<div>
<span><u>复制代码</u></span>
</div>
<p>
代码如下:</p>
</div>
<div id="phpcode1">
<br>
#!/bin/bash <br>
# <br>
# chkconfig: - 85 15 <br>
# description: Nginx is a World Wide Web server. <br>
# processname: nginx <br>
nginx=/usr/local/server/nginx/sbin/nginx <br>
conf=/usr/local/server/nginx/conf/nginx.conf <br>
case $1 in <br>
start) <br>
echo -n "Starting Nginx" <br>
$nginx -c $conf <br>
echo " done" <br>
;; <br>
stop) <br>
echo -n "Stopping Nginx" <br>
killall -9 nginx <br>
echo " done" <br>
;; <br>
test) <br>
$nginx -t -c $conf <br>
;; <br>
reload) <br>
echo -n "Reloading Nginx" <br>
ps auxww | grep nginx | grep master | awk '{print $2}' | xargs kill -HUP <br>
echo " done" <br>
;; <br>
restart) <br>
$0 stop <br>
$0 start <br>
;; <br>
show) <br>
ps -aux|grep nginx <br>
;; <br>
*) <br>
echo -n "Usage: $0 {start|restart|reload|stop|test|show}" <br>
;; <br>
esac </div>
頁:
[1]