Cara menggunakan what company use php
An earlier version of this tutorial was written by Brennan Bearnes. Show IntroductionWhile many users need the functionality of a database management system like MySQL, they may not feel comfortable interacting with the system solely from the MySQL prompt. phpMyAdmin was created so that users can interact with MySQL through a web interface. In this guide, we’ll discuss how to install and secure phpMyAdmin so that you can safely use it to manage your databases on an Ubuntu 20.04 system. PrerequisitesIn order to complete this guide, you will need:
Additionally, there are important security considerations when using software like phpMyAdmin, since it:
For these reasons, and because it is a widely-deployed PHP application which is frequently targeted for attack, you should never run phpMyAdmin on remote systems over a plain HTTP connection. If you do not have an existing domain configured with an SSL/TLS certificate, you can follow this guide on securing Apache with Let’s Encrypt on Ubuntu 20.04. This will require you to register a domain name, create DNS records for your server, and set up an Apache Virtual Host. Step 1 — Installing phpMyAdminYou can use APT to install phpMyAdmin from the default Ubuntu repositories. As your non-root sudo user, update your server’s package index:
Following that you can install the If you followed the prerequisite
LAMP stack tutorial, several of these modules will have been installed along with the
Be aware that if you’re using a version of PHP other than the default one installed in the prerequisite
LAMP stack tutorial, you will need to install the appropriate versions of these module packages. For instance, if you’re using PHP version 8.0, you will need to install the Run the following command to install these packages onto your system. Please note, though, that the installation process requires you to make some choices to configure phpMyAdmin correctly. We’ll walk through these options shortly:
Here are the options you should choose when prompted in order to configure your installation correctly:
Warning: When the prompt appears, “apache2” is highlighted, but not selected. If you do not hit
Note: Assuming you installed MySQL by following Step 2 of the prerequisite LAMP stack tutorial, you may have decided to enable the Validate Password plugin. As of this writing, enabling this component will trigger an error when you attempt to set a password for the phpmyadmin user: To resolve this, select the abort option to stop the installation process. Then, open up your MySQL prompt:
Or, if you enabled password authentication for the root MySQL user, run this command and then enter your password when prompted:
From the prompt, run the following command to disable the Validate Password component. Note that this won’t actually uninstall it, but just stop the component from being loaded on your MySQL server:
Following that, you can close the MySQL client:
Then try installing the
Once phpMyAdmin is installed, you can open the MySQL prompt once again with
The
installation process adds the phpMyAdmin Apache configuration file into the
Afterwards, restart Apache for your changes to be recognized:
phpMyAdmin is now installed and configured to work with Apache. However, before you can log in and begin interacting with your MySQL databases, you will need to ensure that your MySQL users have the privileges required for interacting with the program. Step 2 — Adjusting User Authentication and PrivilegesWhen you installed phpMyAdmin onto your server, it automatically created a database user called phpmyadmin which performs certain underlying processes for the program. Rather than logging in as this user with the administrative password you set during installation, it’s recommended that you log in as either your root MySQL user or as a user dedicated to managing databases through the phpMyAdmin interface. Configuring Password Access for the MySQL Root AccountIn Ubuntu systems running MySQL 5.7 (and later versions), the root MySQL user is set to authenticate using the
In order to log in to phpMyAdmin as your root MySQL user, you will need to switch its authentication method from
Next, check which authentication method each of your MySQL user accounts use with the following command:
In this example, you can see that the root user does in fact authenticate using the
Note:
The previous However, some versions of PHP don’t work reliably with
Then, check the authentication methods employed by each of your users again to confirm that root no longer authenticates using the
You can see from this output that the root user will authenticate using a password. You can now log in to the phpMyAdmin interface as your root user with the password you’ve set for it here. Configuring Password Access for a Dedicated MySQL UserAlternatively, some may find that it better suits their workflow to connect to phpMyAdmin with a dedicated user. To do this, open up the MySQL shell once again:
If you have password authentication enabled for your root user, as described in the previous section, you will need to run the following command and enter your password when prompted in order to connect:
From there, create a new user and give it a strong password:
Note: Again, depending on what version of PHP you have installed, you may want to set your new user to authenticate
with
Then, grant your new user appropriate privileges. For example, you could grant the user privileges to all tables within the database, as well as the power to add, change, and remove user privileges, with this command:
Following that, exit the MySQL shell:
You can now access the web interface by visiting your server’s domain name or public IP address followed by
Log in to the interface, either as root or with the new username and password you just configured. When you log in, you’ll see the user interface, which will look something like this: Now that you’re able to connect and interact with phpMyAdmin, all that’s left to do is harden your system’s security to protect it from attackers. Step 3 — Securing Your phpMyAdmin InstanceBecause of its ubiquity, phpMyAdmin is a popular target for attackers, and you should take extra care to prevent unauthorized access. One way of doing this is to place a gateway in front of the entire application by using Apache’s built-in To do this, you must first enable the use of Use your preferred text editor to edit the
Add an /etc/apache2/conf-available/phpmyadmin.conf
When you have added
this line, save and close the file. If you used To implement the changes you made, restart Apache:
Now that you have enabled the use of In order for this to be successful, the file must be created within the application directory. You can create the necessary file and open it in your text editor with root privileges by typing:
Within this file, enter the following information: /usr/share/phpmyadmin/.htaccess
Here is what each of these lines mean:
When you are finished, save and close the file. The location that you
selected for your password file was
You will be prompted to select and confirm a password for the user you are creating. Afterwards, the file is created with the hashed password that you entered. If you want to enter an additional user, you need to do so without the
Then restart Apache to put
Now, when you access your phpMyAdmin subdirectory, you will be prompted for the additional account name and password that you just configured:
After entering the Apache authentication, you’ll be taken to the regular phpMyAdmin authentication page to enter your MySQL credentials. By adding an extra set of non-MySQL credentials, you’re providing your database with an additional layer of security. This is desirable, since phpMyAdmin has been vulnerable to security threats in the past. ConclusionYou should now have phpMyAdmin configured and ready to use on your Ubuntu 20.04 server. Using this interface, you can create databases, users, and tables, as well as perform the usual operations like deleting and modifying structures and data. |