You can use pagoda
dist包上传服务器
, FileZilla, manual upload, etc.
- Enter the panel interface after having a Tencent Cloud server
Then install Nginx
请一步一步,紧跟步骤
-
first step
Install the gcc-c++ compiler. nginx depends on the pcre and zlib packages
yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel -
ok no problem the second step
Command download file
wget http://nginx.org/download/nginx-1.18.0.tar.gz解压文件 tar -zxvf nginx-1.18.0.tar.gz 解压之后把nginx-1.18.0文件手动移动到 /usr/local目录中 进入安装目录 cd /usr/local/nginx-1.18.0
After entering the directory, enter ./configure
make && make install Compile and install will generate an nginx file at the same level
cd /usr/local/nginx/sbin Enter the directory
sudo ./nginx start the test
Enter the server address and the access is successful
- After the installation is complete, enter the nginx.conf file in the conf file in the nginx directory
- The server can be regarded as a separate Vue project configuration,
which mainly configures the port number file directory
server {
listen 8080;//端口号
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /root/gitee_go/deploy/dist;//文件目录
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
若果需要是不同端口不同项目直接复制serve放至下边只需修改端口号、dist文件位置即可
ps 每次修改nginx.conf文件后都需要重启服务
First enter the sbin folder under nginx, such as cd local/nginx/sbin
restart command ==> sudo ./nginx -s reload
last.
Enter the server interface, select the firewall
and add the corresponding port number to access successfully.
Access may also be 403.
Add user root in the conf file to
ps 有时候服务器重启服务起不来报错 nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or directory)
enter /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx .conf Specify the directory and then restart nginx
============
Storing static resource files to the server
Create a new server in the conf file
# 资源文件
server {
listen 35; 端口
server_name localhost;
# 存放文件的目录
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /root/gitee_go/deploy; 对应的资源文件夹
# index index.html index.htm;
autoindex on;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
After the configuration is complete, restart the service to access,
for example