寶塔面板 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