服务器环境搭建
更新系统sudoaptupdate&&sudoaptupgrade-y安装MySQLsudoaptinstallmysql-server-ysudomysql_secure_installation
在运行mysql_secure_installation时,设置一个强密码,并📝确保启用所有安全选项。
安装PHPsudoaptinstallphpphp-mysqlphp-cliphp-fpm-y安装Apache或Nginx
添加以下内容:
ServerAdminwebmaster@localhostDocumentRoot/path/to/your-projectServerNameyourdomain.comOptionsIndexesFollowSymLinksAllowOverrideAllRequireallgrantedErrorLog${APACHE_LOG_DIR}/error.logCustomLog${APACHE_LOG_DIR}/access.logcombined
ginx配置:
server{listen443ssl;server_nameyourdomain.com;ssl_certificate/etc/letsencrypt/live/yourdomain.com/fullchain.pem;ssl_certificate_key/etc/letsencrypt/live/yourdomain.com/privkey.pem;root/path/to/your-project;indexindex.phpindex.html;location/{try_files$uri$uri//index.php?$query_string;}location~\.php${includesnippets/fastcgi-php.conf;fastcgi_passunix:/var/run/php/php7.4-fpm.sock;}location~/\.ht{denyall;}}防止SQL注入和XSS攻击
pache配置:
ServerAdminwebmaster@localhostDocumentRoot/path/to/your-projectServerNameyourdomain.comSSLEngineonSSLCertificateFile/etc/letsencrypt/live/yourdomain.com/fullchain.pemSSLCertificateKeyFile/etc/letsencrypt/live/yourdomain.com/privkey.pemOptionsIndexesFollowSymLinksAllowOverrideAllRequireallgrantedErrorLog${APACHE_LOG_DIR}/error.logCustomLog${APACHE_LOG_DIR}/access.logcombined
添加以下内容:
server{listen80;server_nameyourdomain.com;root/path/to/your-project;indexindex.phpindex.html;location/{try_files$uri$uri//index.php?$query_string;}location~\.php${includesnippets/fastcgi-php.conf;fastcgi_passunix:/var/run/php/php7.4-fpm.sock;}location~/\.ht{denyall;}}
校对:方保僑(f3J1ePQDlzHhwh44q38w4Ima2E3XrDq)


