How to fix laravel new project not working: not installed: openssl php extension?
When creating a new Laravel project using the laravel new
command, you might encounter an error message stating that the OpenSSL PHP extension is not installed. This error occurs because Laravel relies on OpenSSL for some of its encryption and decryption functions. Here's how to fix this issue:
- Check if OpenSSL is installed:
Before attempting to install the OpenSSL PHP extension, you need to ensure that OpenSSL is installed on your system. You can check this by running the following command in your terminal or command prompt:
openssl version
If OpenSSL is installed, you should see the version number printed out. If not, you'll need to install OpenSSL first.
- Install OpenSSL:
The method for installing OpenSSL depends on your operating system. Here are some general instructions:
-
Ubuntu/Debian: Run the following command to install OpenSSL:
sudo apt-get install openssl
-
MacOS: OpenSSL is pre-installed on MacOS. However, you might need to install Homebrew and use it to install the OpenSSL PHP extension (as described below).
-
Windows: Download the OpenSSL Windows Installer from the official website (https://www.openssl.org/source/) and follow the installation instructions.
- Install the OpenSSL PHP extension:
Once OpenSSL is installed, you need to install the PHP extension. The method for installing the extension depends on your PHP configuration. Here are some general instructions:
-
Ubuntu/Debian: Run the following command to install the OpenSSL PHP extension:
sudo apt-get install php-openssl
-
MacOS (using Homebrew): Run the following commands to install the OpenSSL PHP extension:
brew install php echo 'extension=openssl.so' >> ~/.phpenv/versions/$(phpenv version)/etc/php.ini phpenv restart
-
Windows: Download the PHP OpenSSL extension from the official website (https://windows.php.net/downloads/pecl/extensions/openssl/) and follow the installation instructions.
- Verify the installation:
After installing the OpenSSL PHP extension, you should be able to create a new Laravel project without encountering the "not installed: openssl php extension" error. To verify that the extension is installed, you can run the following command in your terminal or command prompt:
php -m | grep openssl
If the OpenSSL PHP extension is installed, you should see "openssl" printed out in the list of installed modules.
- Create a new Laravel project:
Now that the OpenSSL PHP extension is installed, you should be able to create a new Laravel project without encountering the error. Run the following command to create a new project called "myproject":
laravel new myproject
This should create a new Laravel project without any issues related to the OpenSSL PHP extension.