Buy (Student Edition)
You can search and purchase directly on the official website. After
the purchase is completed, start it on the panel.
If you don’t know the root password, you can reset the password.
Use the ftp tool to connect to the server
Follow the steps to fill in
the ip
user name root
password: Password after reset
Port: Default is 22
Simple LAMP deployment
- switch root su -
- Execute under the /usr/local file (you can also create a directory to install
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
Finally, when the browser accesses the ip, the Nginx URL will appear
Configure static file server
Open the conf\nginx.conf file under nginx
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端口使用情况·