Hosting a web site on Oracle cloud could be tricky, Even if everything is done right and configured the Security Lists in Virtual Cloud Network so the Ingress Rules contains port 80 for http and 443 for https and the Source CIDR is 0.0.0.0/0 and the Destination Port is 80 and after all that when you try to access the website using the public IP, then the reason could be the IP table insde ubuntu itself.
Go to the terminal, and edit the iptables
sudo nano /etc/iptables/rules.v4
Then add 2 lines (better to copy an existing one
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT
Note that you have to edit the names of the extensions to match the driver files you just downloaded which match with PHP version, in my case it was 8.2 version
After saving the php.ini you must restart the apache server for changes to take effect
Now if you want to test the DB connection , you can open a terminal and go to tinker
php artisan tinker
and then type
DB::connection()->getDatabaseName()
If you get the name of the DB, then the connection is good, but wait .. that doesn’t mean you are able to read or write from the DB. For example, if you tried to do a migrate and you get an error like this:
SQLSTATE[08001]: [Microsoft][ODBC Driver 17 for SQL Server]TCP Provider: The wait operation timed out.
(Connection: sqlsrv, SQL: select * from sys.sysobjects where id = object_id(migrations) and xtype in (‘U’, ‘V’))
That means there is most probably a problem with the credentials or the port used
First, you need to make sure that the user has SQL Server authentication, not Windows authentication, you need to open SQL Server Management Studio and right on the Server from the left menu, click on Properties and then Security and choose SQL Server and Windows Authentication mode option
After clicking save, go to the left menu: Security > Login and right click on the user name and click on Properties and make sure that the option of SQL Server Authentication is active
Better to restart the SQL Server by right click on the Server name from the left menu and click on Restart.
If you still get an error message, try to stop the SQL server Process from Task manager
If you are getting the data from an external API when using Postman, but when you try the code provided by Postman in your local host you get no data. A reason for that could be the SSL, first, try to install SSL for your local hosting server. Usually, OpenSSL will do the trick. Here is a link to a step-by-step of how to install SLL over WAMP.
If you still can’t connect to the external API, the reason could be an issue with the SSL certificate validation. (after all, this is a self-signed certification). This error usually occurs when the certificate authority (CA) that issued the SSL certificate used by the server you’re trying to connect to is not recognized or trusted by your system.
If you are using cURL, to resolve this issue, you have a few options:
1- Update your CA certificates: Your system’s CA certificate bundle might be outdated. You can try updating it to include the latest CA certificates. The location of the CA certificate bundle can vary depending on your operating system and cURL installation. In some cases, it may be located at /etc/ssl/certs/ca-certificates.crt.
2-Specify the CA certificate bundle path explicitly: If you have access to the CA certificate bundle, you can specify its path explicitly using the –cacert option with cURL. For example:
3- Ignore certificate validation (not recommended): If you’re in a development or testing environment and certificate validation is not crucial, you can bypass the certificate validation check using the -k or –insecure option with cURL. However, this approach is not recommended in production environments because it exposes you to potential security risks. Example:
curl -k https://example.com
If you are using PHP, here is an example
<?php
// Create a cURL handle
$ch = curl_init();
// Set the URL
curl_setopt($ch, CURLOPT_URL, "https://example.com");
// Disable SSL certificate verification
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
// Execute the request
$response = curl_exec($ch);
// Check for errors
if ($response === false) {
$error = curl_error($ch);
echo "cURL error: " . $error;
}
// Close the cURL handle
curl_close($ch);
?>
“winget” is a command-line package manager for Windows 10 and Windows 11 operating systems. It allows users to search, install, update, and uninstall software packages from the command line or PowerShell. Winget provides a streamlined way to manage software installations and updates without requiring a separate graphical user interface.
The primary user of “winget” is developers, system administrators, and power users who prefer command-line interfaces for managing software. Here are some use cases for “winget”:
Then, update your Gulpfile.js to use gulp-dart-sass instead of gulp-sass for compiling Sass.
By following these steps, you should be able to resolve the compatibility issue with Node Sass and successfully run gulp watch without encountering the “Node Sass does not yet support your current environment” error.
Sometimes in Laravel, when you try to show a property of an object, for example :
{{ $user->name }}
you get an error like this :
Attempt to read property on null
which simply means that the object itself “user” is null and you can’t get a name property of Null. To solve this, you need to make sure that the user object is there first and then get the name but that will be a lot of coding and if statement, while there is a one-character solution to this, it is called a Nullsafe Operator and it is in PHP 8 the code will look like this
{{ $user?->name }}
you can use the same method in a chain of objects or even methods
You can easily log your data in Larave, all you have to do is to use Log, and then log whatever you want, here is an example
<?php
namespace App\Http\Controllers;
use Log;
use App\User;
use App\Http\Controllers\Controller;
class UserController extends Controller
{
/**
* Show the profile for the given user.
*
* @param int $id
* @return Response
*/
public function showProfile($id)
{
Log::info('User ID: '.$id);
return view('user.profile', ['user' => User::findOrFail($id)]);
}
}
You can also use an array of contextual data
Log::info('User failed to login.', ['id' => $user->id]);
You can view the log file at: storage/laravel.log but you may find a huge file with thousands of line as this is the main file where all the logs are saved.
If you want to create your own log file, you will need to add a new channel in the config/logging.php
If you are trying to get some data from an external API and it is working on the Postman or on the live server but is not working locally, and you may also face an error like:
SSL certificate problem: unable to get local issuer certificate