Wordpress 500 - Internal server error (edit) - windows

I'm receiving "500 - Internal server error." on the domain of my WordPress site.
Installed WordPress locally through Web Platform Installer in IIS (Win7).
Developed a landing page in Firefox locally, then FTP'd the site to the web server (which also hosts multiple sites from various domains).
Used MySQL Workbench 5.2 CE to create and export the database, which was also uploaded onto the server. Database was tested.
I've read all the posts relating to "Wordpress" and "500 - Internal server error.", none have helped.
I've tried creating the .htaccess file with the following contained:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
All file paths in IIS are correct.
Below is the wp-config.php file
<?php
/**
* The base configurations of the WordPress.
*
* This file has the following configurations: MySQL settings, Table Prefix,
* Secret Keys, WordPress Language, and ABSPATH. You can find more information
* by visiting {#link http://codex.wordpress.org/Editing_wp-config.php Editing
* wp-config.php} Codex page. You can get the MySQL settings from your web host.
*
* This file is used by the wp-config.php creation script during the
* installation. You don't have to use the web site, you can just copy this file
* to "wp-config.php" and fill in the values.
*
* #package WordPress
*/
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'zxcvb');
/** MySQL database username */
define('DB_USER', 'zxcvb');
/** MySQL database password */
define('DB_PASSWORD', 'zxcvb');
/** MySQL hostname */
define('DB_HOST', 'localhost');
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');
/**##+
* Authentication Unique Keys and Salts.
*
* Change these to different unique phrases!
* You can generate these using the {#link https://api.wordpress.org/secret-key/1.1 /salt/ WordPress.org secret-key service}
* You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
*
* #since 2.6.0
*/
define('AUTH_KEY', 'put your unique phrase here');
define('SECURE_AUTH_KEY', 'put your unique phrase here');
define('LOGGED_IN_KEY', 'put your unique phrase here');
define('NONCE_KEY', 'put your unique phrase here');
define('AUTH_SALT', 'put your unique phrase here');
define('SECURE_AUTH_SALT', 'put your unique phrase here');
define('LOGGED_IN_SALT', 'put your unique phrase here');
define('NONCE_SALT', 'put your unique phrase here');
/**##-*/
/**
* WordPress Database Table prefix.
*
* You can have multiple installations in one database if you give each a unique
* prefix. Only numbers, letters, and underscores please!
*/
$table_prefix = 'wp_';
/**
* WordPress Localized Language, defaults to English.
*
* Change this to localize WordPress. A corresponding MO file for the chosen
* language must be installed to wp-content/languages. For example, install
* de_DE.mo to wp-content/languages and set WPLANG to 'de_DE' to enable German
* language support.
*/
define('WPLANG', '');
/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*/
define('WP_DEBUG', false);
/* That's all, stop editing! Happy blogging. */
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');
Please help!
Thanks

Wordpress stores some domain-specific settings in its options table. If you did the installation locally and then exported it to an external hosting provider it is very likely that those settings are still misconfigured in your WordPress DB and setup for a local installation.
Check the options table in WordPress (add your prefix as needed). Look through the rows for those options that make references to your local installation (its URL or resources) and update them with the corresponding values appropriate for your hosting.
In particular, I'd suggest you check the rows with the following option_names:
siteurl
home
Once those are setup correctly you should be able to access WP's installation and fix others (like image URLs and some other things like that) from its admin interface.

Related

Vite Production Error - Mixed Content The page at 'https://example.herokuapp.com/' was loaded over HTTPS, but requested an insecure stylesheet

currently i deploy a laravue app on heroku, and i got an error like this
mixed Content: The page at 'https://example.herokuapp.com/' was loaded
over HTTPS, but requested an insecure stylesheet
'http://example.herokuapp.com/build/assets/app.55a1010a.css'. This
request has been blocked; the content must be served over HTTPS.
the problem caused by vite production importing assets file via http not https.
and this is how i import my assets file how to fix this problem?
#vite(['resources/js/app.js', 'resources/css/app.css'])
S1. Open .htaccess file and add the following line Header always set Content-Security-Policy "upgrade-insecure-requests;"
S2. remove these lines from your htaccess:
RewriteCond %{SERVER_PORT} ^443$
RewriteRule (.*) http://www.example.com/$1
Please note that 443 port number is used for HTTPS requests.
As you are deploying to Heroku, you are probably behind a proxy.
So you have to set Trusted Proxies. (See doc at https://laravel.com/docs/9.x/requests#configuring-trusted-proxies)
You can open the file /app/Http/Middleware/TrustProxies.php and then enable all ip if you don't know the proxy IP.
/**
* The trusted proxies for this application.
*
* #var array<int, string>|string|null
*/
protected $proxies = '*';

AWS Application Load Balancer real user ip problem

I run laravel application on AWS Elasticbeanstalk, I use Application Load Balancer.
Route::get('/what-is-my-ip', function(){
return request()->ip();
});
When I run this code, my ip doesn't show, it shows the load balancer's ip addresses.
Those who used the same problem with cloudflare also experienced and have solutions for cloudflare, but I couldn't find a solution for the AWS Application Load Balancer.
I am having trouble getting users' ip addresses and adding --allow-ip in maintenance mode.
function real_IP() {
$real_IP = '';
if (getenv('HTTP_CLIENT_IP'))
$real_IP = getenv('HTTP_CLIENT_IP');
else if(getenv('HTTP_X_FORWARDED_FOR'))
$real_IP = getenv('HTTP_X_FORWARDED_FOR');
else if(getenv('HTTP_X_FORWARDED'))
$real_IP = getenv('HTTP_X_FORWARDED');
else if(getenv('HTTP_FORWARDED_FOR'))
$real_IP = getenv('HTTP_FORWARDED_FOR');
else if(getenv('HTTP_FORWARDED'))
$real_IP = getenv('HTTP_FORWARDED');
else if(getenv('REMOTE_ADDR'))
$real_IP = getenv('REMOTE_ADDR');
else
$real_IP = 'UNKNOWN';
return $real_IP;
}
when i run this code it gives the correct ip address, i want to fix it across laravel.
You'll need to trust the AWS load balancers as a proxy.
If you are using AWS Elastic Load Balancing, your $headers value should be Request::HEADER_X_FORWARDED_AWS_ELB. For more information on the constants that may be used in the $headers property, check out Symfony's documentation on trusting proxies.
If you are using Amazon AWS or another "cloud" load balancer provider,
you may not know the IP addresses of your actual balancers. In this
case, you may use * to trust all proxies:
protected $proxies = '*';
Two common issues when you use AWS or any other cloud Load Balancer:
HTTPS (Laravel asset and route): You applied SSL/TLS and the URL is protected in the browser but Laravel doesn't load your asset and throw an error. The error look like it blocks the URLS because of you are trying to load http URL http request. Most of the people facing this issue when use AWS or any other cloud Load Balancer. When running your applications behind a load balancer that terminates TLS / SSL certificates, you may notice your application sometimes does not generate HTTPS links when using the url helper. Typically this is because your application is being forwarded traffic from your load balancer on port 80 and does not know it should generate secure links.
IP: Another issue is IP issue. You can't get the user/visitor IP and it returns always server IP. This issue also happen because of proxies.
Solution: When you are using AWS or any cloud Load Balancer then you may not know the exact IP address of your actual Loads Balancer so should allow all proxies like below example.
Use * to allow trust all proxies in your TrustProxies middleware. Here is your middleware app/Http/Middlewares/TrustProxies.php.
namespace App\Http\Middleware;
use Fideloper\Proxy\TrustProxies as Middleware;
use Illuminate\Http\Request;
class TrustProxies extends Middleware
{
/**
* The trusted proxies for this application.
*
* #var string|array
*/
protected $proxies = '*';
/**
* The headers that should be used to detect proxies.
*
* #var int
*/
protected $headers = Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_HOST | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO;
If you are using AWS Elastic Load Balancing, your $headers value should be Request::HEADER_X_FORWARDED_AWS_ELB. For more information on the constants that may be used in the $headers property, check out Symfony's documentation on trusting proxies.
namespace App\Http\Middleware;
use Fideloper\Proxy\TrustProxies as Middleware;
use Illuminate\Http\Request;
class TrustProxies extends Middleware
{
/**
* The trusted proxies for this application.
*
* #var array|string
*/
protected $proxies = '*';
/**
* The headers that should be used to detect proxies.
*
* #var int
*/
protected $headers = Request::HEADER_X_FORWARDED_AWS_ELB;
I think it solves your HTTPS, IP and other proxy related issue. To read more details read Laravel doc. If you face any other issue or need improvements comments below.

Laravel Spatie/Newsletter doesn't add contact in Mailchimp

I am working on an integration between my laravel 5.2 app and MailChimp. I have downloaded and installed the spatie/newsletter https://github.com/spatie/laravel-newsletter but form some reasons the integration doesn't work meaning a contact is not created in mailchimp. I have added the providers and aliases in the config/app.php file, config/larave-newsletter.php file contain the proper settings
/*
* The api key of a MailChimp account. You can find yours here:
* https://us10.admin.mailchimp.com/account/api-key-popup/
*/
'apiKey' => env('MAILCHIMP_APIKEY'),
/*
* When not specifying a listname in the various methods, use the list with this name
*/
'defaultListName' => 'ListName',
/*
* Here you can define properties of the lists you want to
* send campaigns.
*/
'lists' => [
/*
* This key is used to identify this list. It can be used
* in the various methods provided by this package.
*
* You can set it to any string you want and you can add
* as many lists as you want.
*/
'subscribers' => [
/*
* A mail chimp list id. Check the mailchimp docs if you don't know
* how to get this value:
* http://kb.mailchimp.com/lists/managing-subscribers/find-your-list-id
*/
'id' => env('MAILCHIMP_LIST_ID'),
],
],
/*
* If you're having trouble with https connections, set this to false.
*/
'ssl' => true,
My controller contains the following:
Newsletter::subscribe($user->email, ['FNAME'=>$user->first_name, 'LNAME'=>$user->last_name]);
The strange thing is when I use tinker to add a contact, it does work
Newsletter::subscribe($user->email, ["FNAME"=>$user->first_name, "LNAME"=>$u
ser->last_name]);
Is there a workaround for this issue and how can I solve it? Thanks
I was able to fix the issue by changing the default ssl setting from true to false. It appears my server was having some issues with https connections.
Should one experience a similar issue, they can try setting 'ssl'=>false in the config/laravel-newsletter.php file maybe it'll fix their issue.
I solved the same problem
run this commandes :
composer install
php artisan config:cache
php artisan route:cache
I was able to get this working by setting 'endpoint' to null instead of an empty string (as specified in the install instructions) in config/newsletter.php

Laravel 5.6 signed url won't work in APP_ENV=production

I've setup two routes
Route::get('/bugreport', 'SomeController#create')
->middleware('signed')
->name('bugreport');
Route::get('/getlink', function() {
return dd(\URL::signedRoute('bugreport', ['data' => 3]));
});
When APP_ENV=local I can visit /getlink then hit the resulting url and have it show. When APP_ENV=production (the actual physical environment has not changed when changing the variable) this no longer works... stating invalid signature. Any suggestions?
UPDATE:
We do have... which might be part of it
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* #return void
*/
public function boot()
{
if (!config('app.is_local')) {
URL::forceScheme('https');
}
}
Note: removing the above code actually does fix this issue, but then it breaks e.g. login... so either need to understand why, or this isn't an option :(.
Update Update:
The environment is heroku and the .htaccess has (as per https://help.heroku.com/J2R1S4T8/can-heroku-force-an-application-to-use-ssl-tls)
#### FORCE SSL
## see - https://help.heroku.com/J2R1S4T8/can-heroku-force-an-application-to-use-ssl-tls
RewriteCond %{HTTP_HOST} !=localhost
# If we receive a forwarded http request from a proxy...
RewriteCond %{HTTP:X-Forwarded-Proto} =http [OR]
# ...or just a plain old http request directly from the client
RewriteCond %{HTTP:X-Forwarded-Proto} =""
RewriteCond %{HTTPS} !=on
# Redirect to https version
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
### End Force SSL
I had a similar problem - it can be solved very easy if you use the TrustedProxy Middleware.
If you are on Heroku or AWS behind Load Balancers, and you have SSL offloaded to load balancers, you might want to Trust all proxies, so that Laravel's Request can detect that you are actually on a SSL connection.
Then Signed URL Validation will work.
You can see the doku here:
Laravel 5.7 https://laravel.com/docs/5.7/requests#configuring-trusted-proxies
Laravel 5.6 https://laravel.com/docs/5.6/requests#configuring-trusted-proxies
Update: Use the accepted answer instead.
I finally isolated this down to the Heroku changing the protocol on the requests, so that even when the client makes a request in https laravel will always receive it as http in the request object. The workaround was
if (!config('app.is_local') && strpos($request->url(), 'http:') !== false)
{
$url = str_replace('http:', 'https:', $request->fullUrl());
$request = Request::create($url);
}
if (!$request->hasValidSignature()) {
return abort(403);
}
This was sufficient for my needs.

How to create the documentation of laravel project?

I have a simple website on Laravel with different types of entries and categories.
I need to create documentation for him.
I tried to install phpDocumentor, but it is not installed on Laravel latest version.
Also I should clarify that this is not the API of the project a simple website.
What other solutions do you have for automatically generating documentation?
If you want to create documentation for routes, you can try laravel-routes.
This package can be installed with composer with the next command:
composer require gussrw/laravel-routes
You can generate the HTML file from the console with the next artisan command.
php artisan route:docs
This command creates an HTML file in Project/docs.
Route description
The description is optional, but if you want to add them create a PHP comment over each route in the web.php file with #description.
/**
* #description Show the home page of the site
*/
Route::get('/home', 'HomeController#index') -> name('home.index');
Resources routes
The descriptions in the resource type routes are identified by their method in the controller.
/**
* #index Show the main view
* #create Show the view to create a photo
* #store Save a photo in database
* #edit Show the view to edit a photo
* #update Update photo data in database
* #destroy Delete a photo in database
*/
Route::resource('photos', 'PhotoController');
Params
Routes params are defined with #param name Description, you can use #param in resource type routes.
/**
* #description Download photo with the photo id.
* #param id ID of the photo in database
*/
Route::get('/photo/{id}/download', 'PhotoController#download');

Resources