宝塔面板安装使用

宝塔面板 lnmp 、lamp 安装参照地址  

https://www.bt.cn/bbs/thread-19376-1-1.html    

https://www.cnblogs.com/wentutu/p/8549050.html



1、安装完lnmp的配置文件路径、默认上传网站路径

1.1 查找所有nginx路径

[root@192 ~]# find / -name nginx
/etc/rc.d/init.d/nginx
/usr/bin/nginx
/usr/local/nginx
/www/server/panel/vhost/nginx
/www/server/panel/vhost/template/nginx
/www/server/panel/rewrite/nginx
/www/server/nginx
/www/server/nginx/src/objs/nginx
/www/server/nginx/sbin/nginx


1.2  nginx主配置文件位置

/www/server/nginx/conf/nginx.conf


查看主配置文件从中查找子配置文件路径、上传网站路径

[root@192 ~]# cat /www/server/nginx/conf/nginx.conf
user  www www;
worker_processes auto;
error_log  /www/wwwlogs/nginx_error.log  crit;
pid        /www/server/nginx/logs/nginx.pid;
worker_rlimit_nofile 51200;

events
    {
        use epoll;
        worker_connections 51200;
        multi_accept on;
    }

http
    {
        include       mime.types;
        #include luawaf.conf;

        include proxy.conf;

        default_type  application/octet-stream;

        server_names_hash_bucket_size 512;
        client_header_buffer_size 32k;
        large_client_header_buffers 4 32k;
        client_max_body_size 50m;

        sendfile   on;
        tcp_nopush on;

        keepalive_timeout 60;

        tcp_nodelay on;

        fastcgi_connect_timeout 300;
        fastcgi_send_timeout 300;
        fastcgi_read_timeout 300;
        fastcgi_buffer_size 64k;
        fastcgi_buffers 4 64k;
        fastcgi_busy_buffers_size 128k;
        fastcgi_temp_file_write_size 256k;
        fastcgi_intercept_errors on;

        gzip on;
        gzip_min_length  1k;
        gzip_buffers     4 16k;
        gzip_http_version 1.1;
        gzip_comp_level 2;
        gzip_types     text/plain application/javascript application/x-javascript text/javascript text/css application/xml;
        gzip_vary on;
        gzip_proxied   expired no-cache no-store private auth;
        gzip_disable   "MSIE [1-6]\.";

        limit_conn_zone $binary_remote_addr zone=perip:10m;
        limit_conn_zone $server_name zone=perserver:10m;

        server_tokens off;
        access_log off;

server
    {
        listen 888;
        server_name www.bt.cn;
        index index.html index.htm index.php;
        root  /www/server/phpmyadmin;

        #error_page   404   /404.html;
        include enable-php.conf;

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /\.
        {
            deny all;
        }

        access_log  /www/wwwlogs/access.log;
    }
include /www/server/panel/vhost/nginx/*.conf;
}



1.2  nginx子配置文件位置

/www/server/panel/vhost/nginx

[root@192 ~]# cd /www/server/panel/vhost/nginx
[root@192 nginx]# ls
phpfpm_status.conf



1.3 默认上传网站路径

/www/wwwroot/default/



2、宝塔vhost子目录正确使用nginx配置文件

2.1 不要用vim 编辑打开子配置文件 复制内容,无法保存, 试过

2.2 用echo 写入子配置文件内容


[root@192 website]# cat /www/server/panel/vhost/nginx/test1.conf
server {
        listen 8083;
        server_name www.test1.com;
    charset    utf-8;
    location / {
    root /website;
        index index.php index.html index.htm;
        }
     
        location ~ \.php$ {
        root html;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME /website;
            include fastcgi_params;
        }

}

 3、服务器搭建网站完整教程(宝塔面板+wordpress)    


参照文档

https://www.zhujibiji.com/2018/04/how-to-use-bandwagonhost-build-a-website/


4、在宝塔后台根目录下上传网站

4.1 配置nginx子配置文件

注意:不要用vim 写入,报错,没有权限

cat >> /www/server/panel/vhost/nginx/test1.conf << EOF
server {
        listen 8083;
        server_name www.test1.com;
    charset    utf-8;
    location / {
    root /www/wwwroot/website;
        index index.php index.html index.htm;
        }
     
        location ~ \.php$ {
        root html;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME /website;
            include fastcgi_params;
        }

}
EOF



4.2、创建web站点目录、index.html

注意:web站点目录必须在/www/wwwroot/ 下创建,这就是面板的局限性

[root@192 ~]# cd /www/wwwroot/
default
[root@192 wwwroot]# mkdir website
[root@192 wwwroot]# ls
default   website
[root@192 website]# echo hello >> index.html 
[root@192 website]# ls
index.html
[root@192 website]# cat index.html 
hello


4.3、重新加载nginx

[root@192 website]# nginx -t
nginx: the configuration file /www/server/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /www/server/nginx/conf/nginx.conf test is successful



4.4、测试访问静态网页

[root@192 website]# curl http://127.0.0.1:8083
hello

 

5、在宝塔后台根目录下创建目录后,进目录里面上传网站

5.1 配置nginx子配置文件

注意:不要用vim 写入,报错,没有权限

cat >> /www/server/panel/vhost/nginx/test1.conf << EOF
server {
        listen 8083;
        server_name www.test1.com;
    charset    utf-8;
    location / {
    root /www/wwwroot/website/ceshi;
        index index.php index.html index.htm;
        }
     
        location ~ \.php$ {
        root html;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME /website;
            include fastcgi_params;
        }

}
EOF



5.2、创建web站点目录、index.html

注意:web站点目录必须在/www/wwwroot/ 下创建,这就是面板的局限性

[root@192 wwwroot]# mkdir -p /www/wwwroot/website/ceshi
[root@192 ~]# cd /www/wwwroot/website/ceshi
[root@192 ceshi]# echo hello >> index.html 
[root@192 ceshi]# ls
index.html
[root@192 ceshi]# cat index.html 
hello


5.3、重新加载nginx

[root@192 website]# nginx -t
nginx: the configuration file /www/server/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /www/server/nginx/conf/nginx.conf test is successful



5.5、测试访问静态网页

[root@192 website]# curl http://127.0.0.1:8083
hello

 
















 

posted @ 2018-11-28 13:28  effortsing  阅读(1502)  评论(0编辑  收藏  举报