You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

基于Plesk的PHP版本迁移、Laravel部署及SSH访问问题咨询

问题解决方案汇总

Hey there, let's break down each of your issues one by one and get you sorted out:

1. PHP 5 → PHP 7+ 迁移报错修复

Migrating from PHP 5 to 7+ often hits compatibility issues due to deprecated functions, stricter type checks, and changed behaviors. Here are the most common fixes to tackle your errors:

  • Replace deprecated functions:
    • Ditch mysql_* functions (removed in PHP7) and switch to mysqli_* or PDO for database connections.
    • Replace ereg()/eregi() with preg_match() (PCRE regex functions are now standard).
    • If you used $HTTP_RAW_POST_DATA, replace it with file_get_contents('php://input') (the former was removed in PHP7.0).
  • Adjust for stricter type handling:
    • PHP7+ enforces stricter type declarations for function parameters and return values. If you see "TypeError" messages, either update your code to match the expected types, or add declare(strict_types=0) at the top of your scripts to loosen type checks (not recommended long-term, but useful for quick fixes).
  • Fix variable and loop behavior changes:
    • foreach no longer modifies the original array when using value iteration (unless you explicitly use references).
    • isset() now returns false for uninitialized array elements with null values, which might break old conditional checks.
  • Update error handling:
    • PHP7+ uses the Throwable interface to catch both exceptions and fatal errors. Wrap risky code in try-catch blocks that catch Throwable instead of just Exception to handle more cases.

For your specific errors, check the web server logs in Plesk (under Logs > Web Server Logs) — they'll give you exact line numbers and error messages to target. The screenshots you shared:

  • Plesk服务器子域名设置仪表盘:Confirm that the subdomain is configured to use your target PHP 7+ version here (look for the PHP settings section in this dashboard).
  • 链接打开错误:This generic error usually points to a PHP fatal error or misconfigured document root. The server logs will reveal the root cause.

2. Deploying Laravel on Plesk (Yes, It's Possible!)

Plesk's "no official support" note just means there's no one-click installer — you can absolutely deploy Laravel manually, and it's a common setup. Here's how:

  1. Check server requirements: Ensure your Plesk server has PHP 7.4+ (Laravel 9+ requires 8.0+), plus these extensions: BCMath, Ctype, JSON, Mbstring, OpenSSL, PDO, Tokenizer, XML. Enable them via Plesk's PHP settings.
  2. Configure your domain/subdomain:
    • Create the domain in Plesk, then set the Document Root to the public folder of your Laravel project (critical to protect sensitive files like .env).
  3. Upload your code:
    • Use FTP, or (once SSH is fixed) git clone your Laravel repo directly to the server.
  4. Set permissions:
    • Make sure the storage and bootstrap/cache directories have write permissions (usually 755 or 777, depending on your server's user/group setup). You can adjust this via Plesk's File Manager or command line.
  5. Configure environment:
    • Copy .env.example to .env, fill in your database credentials, APP_URL, and other settings.
    • Generate an app key with php artisan key:generate (run this via Plesk's built-in Terminal or SSH).
  6. Set up rewrite rules:
    • Go to Apache & nginx Settings for your domain, add this to the "Additional nginx directives" section:
      location / {
          try_files $uri $uri/ /index.php?$query_string;
      }
      
    This ensures Laravel's routing works correctly.

3. Fixing PuTTY SSH Timeouts & Hidden Input

Let's troubleshoot the SSH access issue step by step:

  • Check network and firewall rules:
    • Verify your server's firewall (and cloud provider's security group, if applicable) allows inbound traffic on port 22 (default SSH port). Test connectivity with telnet your-server-ip 22 from your local machine — if it fails, the port is blocked.
  • Adjust PuTTY settings:
    • In the PuTTY Session window, go to Terminal > Local Echo and select "Force on" — this will make your input visible.
    • Go to Connection > Seconds between keepalives and set it to 30 — this sends periodic packets to prevent the connection from timing out.
  • Check server SSH configuration:
    • If you can access the server via Plesk's built-in Terminal (under Tools & Settings > Terminal), edit /etc/ssh/sshd_config:
      • Ensure PermitRootLogin is set to yes (or prohibit-password if you use key-based auth).
      • Make sure PasswordAuthentication is set to yes if you're logging in with a password.
      • Restart the SSH service with systemctl restart sshd.
  • Update PuTTY: If you're using an old version, download the latest release — outdated clients can cause compatibility issues.

内容的提问来源于stack exchange,提问作者imrab19

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 07:16:05