腾讯云实操

购买(学生版)

直接在官网搜索购买即可
购买完成在面板启动
不知道root的密码的话可以充重置密码在这里插入图片描述

使用ftp工具连接服务器

按着步骤填写
ip
用户名 root
密码 : 重置之后的密码
端口 :默认是 22

简单的LAMP的部署

  1. 切换root su -
    在这里插入图片描述
  2. 在 /usr/local 文件下执行(也可以随便创个目录安装
1.安装Nginx包 (必须是root用户,Nginx版本自己定)
wget http://nginx.org/download/nginx-1.13.1.tar.gz

2.安装依赖
yum install gcc      
yum install gcc-c++
yum -y install pcre*
yum -y install zlib*
yum -y install openssl 
yum -y install openssl-devel
3.解压 
tar -z -xv -f nginx-1.13.1.tar.gz 
4.编译  (必须是root用户
cd nginx-1.13.1
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-pcre

  选项tips:
--prefix:设置安装路径 
--with-http_stub_status_module:支持nginx状态查询
--with-http_ssl_module:支持https
--with-pcre:为了支持rewrite重写功能,必须制定pcre

安装
make install
5.启动 (root权限)
安装成功之后会在目录下生成一个 名:nginx文件夹


/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
6.查看是否安装成功或启动成功过 (root权限)
安装成功之后会在目录下生成一个 名:nginx文件夹
课使用命令查看是否有开启服务,有对应的pid就开启成功
ps -C nginx -o pid
7.设置开机自启 ,前提需要有配置(root权限)
#编写nginx启动脚本,并加入系统服务
vi /etc/init.d/nginx

#写入以下内容 输入命令  i
#!/bin/bash
# chkconfig: - 30 21
# description: http service.
# Source Function Library
. /etc/init.d/functions
# Nginx Settings

NGINX_SBIN="/usr/local/nginx/sbin/nginx"
NGINX_CONF="/usr/local/nginx/conf/nginx.conf"
NGINX_PID="/usr/local/nginx/logs/nginx.pid"
RETVAL=0
prog="Nginx"

start() {
        echo -n $"Starting $prog: "
        mkdir -p /dev/shm/nginx_temp
        daemon $NGINX_SBIN -c $NGINX_CONF
        RETVAL=$?
        echo
        return $RETVAL
}

stop() {
        echo -n $"Stopping $prog: "
        killproc -p $NGINX_PID $NGINX_SBIN -TERM
        rm -rf /dev/shm/nginx_temp
        RETVAL=$?
        echo
        return $RETVAL
}

reload(){
        echo -n $"Reloading $prog: "
        killproc -p $NGINX_PID $NGINX_SBIN -HUP
        RETVAL=$?
        echo
        return $RETVAL
}

restart(){
        stop
        start
}

configtest(){
    $NGINX_SBIN -c $NGINX_CONF -t
    return 0
}

case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  reload)
        reload
        ;;
  restart)
        restart
        ;;
  configtest)
        configtest
        ;;
  *)
        echo $"Usage: $0 {start|stop|reload|restart|configtest}"
        RETVAL=1
esac

exit $RETVAL


#保存退出 接下来添加权限  输入命令 :q!
chmod 755 /etc/init.d/nginx
#添加nginx到服务
chkconfig --add nginx
#加到开机自动启动
chkconfig nginx on

重启:
systemctl restart nginx
从新加载
systemctl reload nginx

最后就在浏览器访问ip就会出现Nginx的网址

配置静态文件服务器

打开 nginx 下的 conf\nginx.conf文件

vim /usr/local/nginx/conf/nginx.conf

修改 location 这个配置
 server {
        listen       80;
        server_name  localhost;
        location /image/ {
            root   /usr/local/myImage/;
            autoindex on;
        }
    }
   :w  保存
   :q  退出
   重新加载配置
   systemctl reload nginx
   开启端口
   firewall-cmd --zone=public --add-port=1935/tcp --permanent
   重启防火墙
   3、重启防火墙
firewall-cmd --reload
关闭防火墙
systemctl stop firewalld
查看防火墙状态
systemctl status firewalld
firewall-cmd --state
查看端口号
netstat -ntlp //查看当前所有tcp端口·

netstat -ntulp |grep 1935 //查看所有1935端口使用情况·

猜你喜欢

转载自blog.csdn.net/work33/article/details/122902628