In this article, we will guide you through the process of overriding the “E45 readonly option” error when configuring the mcrypt extension in an Ubuntu server. This error typically occurs when you are trying to edit a read-only file in Vim, a text editor often used in Linux systems.
Understanding the E45 Error
The E45 error in Vim is a safety feature that prevents users from making unintentional changes to read-only files. This error can be frustrating, especially when you are trying to configure server extensions like mcrypt. However, it can be easily overridden using a few different methods.
Method 1: Using ‘!’ to Force Write
When you attempt to save a file with
:w command in Vim and encounter the E45 error, it means Vim has detected the file as read-only. You can override this by appending ‘!’ to the write command, like so:
This command forces Vim to write the changes to the file, overriding the read-only status.
Method 2: Using sudo to Edit the File
If you lack the necessary permissions to edit the file,
sudo can be used to temporarily gain root privileges. For instance:
sudo vi /etc/php5/mods-available/mcrypt.ini
This command opens the mcrypt configuration file with root access, allowing you to save changes without the read-only error.
Method 3: Checking and Changing File Permissions
Incorrect file permissions can also lead to the E45 error. You can check the permissions of the file using the
ls -l command:
ls -l /etc/php5/mods-available/mcrypt.ini
If you do not have write permissions for the file, you can change the permissions using the
sudo chmod command. For instance, to add write permissions for the owner, you can use:
sudo chmod u+w /etc/php5/mods-available/mcrypt.ini
Method 4: Using :w !sudo tee %
This command allows you to save changes to a file that requires root access. It combines the write command with the
sudo command and uses
tee to write the changes to the file. Here’s how you use it:
:w !sudo tee %
This command will save the changes to the current file.
While the “E45 readonly option” error can be a bit of a hurdle when configuring the mcrypt extension in Ubuntu server, it can be easily overridden using the methods described above. Always be cautious when using
sudo or modifying system files. Make sure you understand the changes you’re making and their potential impact on your system.
For more information on Vim and its commands, you can check the official Vim documentation. For more details on file permissions in Linux, you can visit this comprehensive guide on Linux file permissions.
The mcrypt extension is used for encryption and decryption functions in PHP. It provides a way to encrypt data using various algorithms and modes.
You can check if the mcrypt extension is installed by running the following command in your terminal:
php -m | grep mcrypt
If the extension is installed, you will see "mcrypt" in the output.
To install the mcrypt extension on Ubuntu server, you can use the following command:
sudo apt-get install php-mcrypt
This command will install the mcrypt extension for your PHP version.
If the mcrypt extension is not working after installation, you may need to enable it in your PHP configuration. You can do this by creating a symbolic link to the mcrypt configuration file in the
mods-available directory. Here’s an example command:
sudo ln -s /etc/php/7.4/mods-available/mcrypt.ini /etc/php/7.4/cli/conf.d/20-mcrypt.ini
Make sure to replace the PHP version in the command with your actual PHP version.
You can create a PHP file with the following code and access it in your web browser:
Search for "mcrypt" in the PHP info page that opens. If you see the mcrypt section, it means the extension is enabled and working.
Yes, the mcrypt extension has been deprecated since PHP 7.1. It is recommended to use OpenSSL or Sodium for encryption and decryption functions in PHP. These extensions provide more secure and up-to-date cryptographic algorithms.
Yes, the methods mentioned in this article can be used to override read-only file errors in Vim, not just for configuring the mcrypt extension.