FTP error log location
August 7, 2025 Β· AI Conversations
—
### π§ **Common FTP Paths for `error_log`:**
#### 1. **Inside the Root Directory (`public_html` or `htdocs`):**
– File: `public_html/error_log`
– Often contains PHP warnings/errors from your main site.
#### 2. **Inside the Subfolder or Plugin/Theme Directory:**
– If a specific plugin or theme causes errors, you might find:
public_html/wp-content/plugins/your-plugin/error_log
public_html/wp-content/themes/your-theme/error_log
#### 3. **Inside the `wp-admin` or `wp-includes` folder** (less common but possible):
– Example: `public_html/wp-admin/error_log`
#### 4. **Server-wide error log** (outside FTP access, only via cPanel or SSH):
– **cPanel:** Go to **Metrics β Errors** or check `Logs β Error Log`.
– **SSH:** Common paths:
/var/log/apache2/error.log
/var/log/httpd/error_log
—
### π **How to Enable PHP Error Logging (if not available):**
If `error_log` is missing and you want to create it:
Add this to your `wp-config.php`:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false ); // So errors aren't shown on the frontend
This will generate:
wp-content/debug.log
—
Let me know your hosting type (cPanel, Plesk, etc.) or if you're using a managed host (like Kinsta, WP Engine), and I can give exact directions.
—
## β **Checklist to Make `error_log` Work in WordPress / PHP**
### πΉ 1. **Enable WP Debug Mode**
Open `wp-config.php` and ensure these lines are set **before** `/* That's all, stop editing! Happy publishing. */`:
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false); // This hides errors from frontend
β This will write errors to `wp-content/debug.log` (not `error_log`).
—
### πΉ 2. **Check File Permissions**
Ensure the server has permission to write the log file.
#### For `wp-content/debug.log`:
– Set folder `wp-content` permission to `755`
– If `debug.log` exists, set its permission to `644`
– If it doesnβt exist, WordPress will create it automatically.
—
### πΉ 3. **Check `php.ini` Configuration (Server-Level PHP Settings)**
If using a custom server or VPS, ensure the following are set:
log_errors = On
error_log = /path/to/your/error_log
> If `error_log` path is not set, it defaults to the server's default error log (usually not inside FTP-visible folders).
To check this, create a `phpinfo.php` file:
<?php phpinfo(); ?>
Look for:
– `log_errors`
– `error_log` (the current path)
– `display_errors`
—
### πΉ 4. **Try Manual Logging**
Add this line in your PHP or WordPress file to test
—
## β How to Enable Error Logging in Core PHP
### πΉ 1. **Edit your PHP script to enable error logging**
At the top of your main PHP file (like `index.php`), add:
ini_set('display_errors', 0); // Don't show errors on screen
ini_set('log_errors', 1); // Enable error logging
ini_set('error_log', __DIR__ . '/error_log'); // Log file in current folder
error_reporting(E_ALL); // Log all errors
> π Replace `__DIR__ . '/error_log'` with a full path if needed.
—
### πΉ 2. **Trigger a test error**
Add a line like this to check if logging works:
non_existing_function(); // This will throw a fatal error
Then check your FTP for `error_log` file in the same folder.
—
### πΉ 3. **File and Folder Permissions**
Make sure PHP can write the file:
– Folder: `755`
– File (if exists): `644`
– Owner should be the web server (e.g. `www-data` on Linux)
—
### πΉ 4. **No error_log file appearing? Try system-wide log**
If `error_log` still isnβt created, the server may be logging to a default system path. Check:
– **Via cPanel:** `Metrics > Errors` or `Logs > Error Log`
– **Via SSH** (if available): Common log file locations:
– `/var/log/apache2/error.log`
– `/var/log/httpd/error_log`
—
## π Summary
| Step | Task |
|——|——|
| β
| Add `ini_set('log_errors', 1);` and set `error_log` path |
| β
| Trigger an error manually |
| β
| Check for `error_log` file in FTP |
| β
| Ensure correct file permissions |
—
If you're on shared hosting and still donβt see it, let me know your hosting provider β Iβll give you the exact path.
—
## β Example
If your CodeIgniter folder structure looks like this:
/var/www/html/myproject/
βββ application/
βββ system/
βββ index.php
Then:
echo APPPATH;
Will output:
/var/www/html/myproject/application/
—
## π§ Common Uses of `APPPATH`
You can use `APPPATH` in your code to refer to files or directories inside the application:
### β Load a config file manually:
require_once(APPPATH . 'config/custom_config.php');
### β Write a log file:
file_put_contents(APPPATH . 'logs/my_log.txt', "Hello Log!");
### β Include a library or helper:
include_once(APPPATH . 'libraries/MyLibrary.php');
—
## π Defined In:
`APPPATH` is defined in `index.php` of CodeIgniter:
define('APPPATH', $application_folder . DIRECTORY_SEPARATOR);
So it's always available throughout your entire application.
—
Let me know if you need help using `APPPATH` in a specific file or use case.
In **CodeIgniter 3**, `APPPATH` points to the **server-side path** (like `/var/www/html/myproject/application/`) β it is **not directly accessible via a public URL** for security reasons.
—
## β Summary:
| Constant / Folder | What it is | Public URL Accessible? |
|——————|——————————–|————————-|
| `APPPATH` | Full server path to `/application/` | β No |
| `BASEPATH` | Full server path to `/system/` | β No |
| `FCPATH` | Full server path to `/index.php` (front controller) | β
Yes (indirectly) |
| `/application/` | Your app logic (controllers, models, views) | β No |
| `/assets/`, `/public/`, etc. | Static files you create (CSS/JS/images) | β
Yes (if placed correctly) |
—
## π If You Want to Access Public Assets
You should **not expose `application/`** to the web.
Instead, place **publicly accessible files** (images, CSS, JS) in a folder like this:
/var/www/html/myproject/assets/
Then access them via a public URL like:
http://yourdomain.com/assets/css/style.css
—
## π‘ Security Tip
Never expose the `application/` or `system/` folders to the public via URL. If someone can open this in the browser:
http://yourdomain.com/application/config/config.php
That means your server is misconfigured.
To protect it, ensure:
– `.htaccess` blocks access to `application/` and `system/` if you're using Apache.
– Or move them outside the `public_html/` folder.
—
If you tell me your folder structure and hosting setup (shared, VPS, etc.), I can help you set the correct public path for assets.
1. **Generate the QR code** (as an image or string).
2. **Save it to a file or keep it in memory**.
3. **Attach it using PHPMailer's `addAttachment()` or `addStringAttachment()`**.
—
## β Step-by-Step Code (Using Endroid QR Code + PHPMailer)
### 1. **Install required packages via Composer**
composer require phpmailer/phpmailer
composer require endroid/qr-code
—
### 2. **PHP Script to Generate and Send Email with QR Code**
<?php
use PHPMailerPHPMailerPHPMailer;
use EndroidQrCodeBuilderBuilder;
use EndroidQrCodeWriterPngWriter;
require 'vendor/autoload.php';
// Generate QR Code Image (to string or file)
$result = Builder::create()
->writer(new PngWriter())
->data('https://yourdomain.com/verify?id=12345')
->size(300)
->build();
// Option 1: Save to file
$filePath = __DIR__ . '/qrcode.png';
file_put_contents($filePath, $result->getString());
// OR Option 2: Use in-memory image string
$imageData = $result->getString();
$mail = new PHPMailer(true);
try {
// Server settings
$mail->isSMTP();
$mail->Host = 'smtp.yourhost.com';
$mail->SMTPAuth = true;
$mail->Username = 'your@email.com';
$mail->Password = 'yourpassword';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
// Recipients
$mail->setFrom('your@email.com', 'Your Name');
$mail->addAddress('user@example.com', 'Recipient');
// Content
$mail->isHTML(true);
$mail->Subject = 'Here is your QR Code';
$mail->Body = 'Please find the QR code attached.';
// Attach QR (choose one)
// Option A: attach saved file
$mail->addAttachment($filePath, 'qrcode.png');
// Option B: attach in-memory image
// $mail->addStringAttachment($imageData, 'qrcode.png', 'base64', 'image/png');
$mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo "Mailer Error: {$mail->ErrorInfo}";
}
—
## β Output
– The email will include `qrcode.png` as an attachment.
– You can also embed it inline with `addEmbeddedImage()` if you want it inside the email body.
—
## Let me know:
– If you want the QR embedded instead of attached.
– If you're not using Composer.
– Or want to generate QR code without `endroid/qr-code`.
I can adjust accordingly.