Ubuntu下安装nginx的步骤分享

2020-02-03 10:50:41王振洲

}
do_stop() {
echo "Shutting down $NAME ..."
kill 'cat $PIDFILE'
}
do_reload() {
echo "Reloading $NAME ..."
kill -HUP 'cat $PIDFILE'
}
case "$1" in
start)
[ ! -f "$PIDFILE" ] && do_start || echo "nginx already running"
echo -e ".ndone"
;;
stop)
[ -f "$PIDFILE" ] && do_stop || echo "nginx not running"
echo -e ".ndone"
;;
restart)
[ -f "$PIDFILE" ] && do_stop || echo "nginx not running"
do_start
echo -e ".ndone"
;;
reload)
[ -f "$PIDFILE" ] && do_reload || echo "nginx not running"
echo -e ".ndone"
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|reload}" >&2
exit 1
;;
esac
exit 0

红色部分,根据自己的路径修改。

6)、常用命令

重启nginx:service nginx restart
启动:service nginx start
关闭:service nginx stop

7)、linux常用命令
tar(z-用 gzip 对存档压缩或解压;x-从存档展开文件;v-详细显示处理的文件;f-指定存档或设备)
tar –zxvf nginx-0.8.54.tar.gz

ip查看
ifconfig

编译
make

安装编译好的源码包
make install

编辑文件
sudo gedit /etc/profile

修改根限:chmod说明(u:与文件属主拥有一样的权限[a:所有人];+:增加权限;rwx:可读可写可执行)
-R:递归所有目录和文件
sudo chmod a+rwx -R logs

检查是库是否安装成功
dpkg --list|grep openssl

下载安装库
sudo apt-get install libtool

检查服务启动是否正常
ps -ef|grep

查找openssl安装路径
whereis openssl

更新源
sudo apt-get update

更新已安装的包
sudo apt-get upgrade