Friday, October 4, 2019

Install Apache2, MySQL, PHP, phpMyadmin, aktivasi page phpMyadmin On Ubuntu 19

1. Install Apache

First of all, update Ubuntu server using commands :
Login with root :
apt update
apt upgrade
Next, install Apache web server :
apt install apache2
Check if Apache web server is running or not :
systemctl status apache2
Sample output would be:
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled) Active: active (running) since Fri 2019-10-04 06:24:08 UTC; 11min ago Docs: https://httpd.apache.org/docs/2.4/ Process: 21511 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS) Main PID: 21531 (apache2) Tasks: 7 (limit: 4648) Memory: 20.9M CGroup: /system.slice/apache2.service ├─21531 /usr/sbin/apache2 -k start ├─21532 /usr/sbin/apache2 -k start ├─21533 /usr/sbin/apache2 -k start ├─21534 /usr/sbin/apache2 -k start ├─21535 /usr/sbin/apache2 -k start ├─21536 /usr/sbin/apache2 -k start └─21537 /usr/sbin/apache2 -k start Oct 04 06:24:08 xbox-01 systemd[1]: Starting The Apache HTTP Server... Oct 04 06:24:08 xbox-01 apachectl[21511]: AH00558: apache2: Could not reliably determine the server's fully quali Oct 04 06:24:08 xbox-01 systemd[1]: Started The Apache HTTP Server.
Now, open your web browser and access Apache test page by navigating to
http://localhost/ or http://IP.ADDRESS - http://192.168.94.99

2. Install MySQL

To install MySQL On Ubuntu, run :
apt install mysql-server
Verify if MySQL service is running or not using command :
systemctl status mysql
Sample output :

root@xbox-01:~# systemctl status mysql
● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2019-10-03 15:03:47 UTC; 15h ago
 Main PID: 4849 (mysqld)
    Tasks: 28 (limit: 4648)
   Memory: 176.6M
   CGroup: /system.slice/mysql.service
           └─4849 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid

Oct 03 15:03:46 xbox-01 systemd[1]: Starting MySQL Community Server...
Oct 03 15:03:47 xbox-01 systemd[1]: Started MySQL Community Server.
root@xbox-01:~#
Mysql is running!

2.1 SETUP DATABASE ADMINISTRATIVE USER (ROOT) PASSWORD

By default, MySQL root user password is blank. You need to secure your MySQL server by running the following script :
mysql_secure_installation
If your answer is Yes, you will be asked to choose the level of password validation.

The available password validations are lowmedium and strong. Just enter the appropriate number (0 for low, 1 for medium and 2 for strong password) and hit ENTER key.

Now, enter the password for MySQL root user. Please be mindful that you must use password for mysql root user depending upon the password policy you choose in the previous step. If you didn’t enable the plugin, just use any strong and unique password of your choice.
Please set the password for root here.

New password:

Re-enter new password:

Estimated strength of the password: 50 
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y

For the rest of questions, just type y and hit ENTER. This will remove anonymous user, disallow root user login remotely and remove test database.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.

Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...
Success.

- Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.

All done!

2.2 CHANGE AUTHENTICATION METHOD FOR MYSQL ROOT USER
mysql
Run the following command at the mysql prompt to find the current authentication method for all mysql user accounts :
SELECT user,authentication_string,plugin,host FROM mysql.user;
Change this authentication to mysql_native_password method.


ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'isipassword';
Update the changes using command :
FLUSH PRIVILEGES;
Now check again if the authentication method is changed or not using command :
SELECT user,authentication_string,plugin,host FROM mysql.user;

Good! Now the myql root user can authenticate using password to access mysql shell.
Exit from the mysql prompt :
exit

2. Install PHP

To install PHP, run :
apt install php libapache2-mod-php php-mysql
After installing PHP, create info.php in folder /var/www/html/ 
Let us create info.php file in the apache root folder:
nano /var/www/html/info.php
Add the following lines :
<?php
phpinfo();
?>
Press CRTL X Y to save and quit the file. Restart apache service to take effect the changes.
systemctl restart apache2

3.1 TEST PHP
Open up your web browser and navigate to http://IP-address/info.php

Usually, when a user requests a directory from the web server, Apache will first look for a file named index.html. If you want to change Apache to serve php files rather than others, move index.php to first position in the dir.conf file as shown below
nano /etc/apache2/mods-enabled/dir.conf
Here is the contents of the above file.
<IfModule mod_dir.c>
        DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
</IfModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Move the “index.php” file to first. Once you made the changes, your dir.conf file will look like below.
<IfModule mod_dir.c>
        DirectoryIndex index.php index.cgi index.pl index.html index.xhtml index.htm
</IfModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Press CRTL X Y to save and quit the file. Restart apache service to take effect the changes.
systemctl restart apache2

3.2 INSTALL PHP MODULES
To improve the functionality of PHP, you can install some additional PHP modules.
To list the available PHP modules, run :
apt-cache search php- | less
apt-cache show php-gd
To install a php module run :
apt install php-gd
To install all modules (not necessary though), run :
apt-get install php*
After Then
systemctl restart apache2

2. Install phpMyAdmin

Once you’ve setup LAMP stack, enable ‘universe’ repository, which is disabled by default on Ubuntu 19.  To do so, run :
add-apt-repository universe
Now is the time to install phpMyAdmin.
To install phpMyAdmin on Ubuntu 19, run :
apt update
apt install phpmyadmin php-mbstring php-gettext
Hit the TAB key to choose OK and again hit ENTER key to continue.


Hit ENTER to continue.

Choose Yes to configure database for phpmyadmin :

Provide mysql application password phpmyadmin. using the first password you set before.

Enter password :
Re-enter password :

Once phpmyadmin is installed, enable mbstring php extension and restart Apache service update the changes as shown below.
phpenmod mbstring
systemctl restart apache2
You can now verify if mbstring extension is enabled or not by loading into info.php file from the web browser. http://ip.address/info.php

To do so, login to mysql shell using command:
mysql -u root -p
Enter your mysql root password. You will now be in mysql shell.
Enter the following command to create a new dedicated user for phpmyadmin :
CREATE USER 'phpmyadminuser'@'localhost' IDENTIFIED BY 'isipassword';
Here, phpmyadmin is the new user for accessing phpmyadmin dashboard. The password for phpmyadminuser is isipassword. Replace these values with your own.
Next give the appropriate privileges to the ‘phpmyadminuser’ using command :
GRANT ALL PRIVILEGES ON *.* TO 'phpmyadminuser'@'localhost' WITH GRANT OPTION;
Finally exit from mysql shell :
exit

Before access phpMyAdmin dashboard http://IP.ADREESS/phpMyAdmin

Edit apache2.conf

nano /etc/apache2/apache2.conf

Then add the following line to the end of file : 

Include /etc/phpmyadmin/apache.conf

Then Restart apache2

systemctl restart apache2

Access phpMyAdmin dashboard

Open your web browser and navigate to :

http://IP.ADREESS/phpMyAdmin

Then Log in using root password.

SEMOGA BERMANFAAT!


Tuesday, January 15, 2019

Tips Menggunakan Perintah History di Linux



Perintah GNU history mencatat semua perintah yang dijalankan dari sebuah sesi terminal dan memungkinkan kita untuk menggunakan ulang perintah-perintah tersebut tanpa menuliskannya lagi. Untuk melihat bagaimana history bekerja, buka sebuah jendela terminal lalu tuliskan:

$ history
Dari perintah di atas penulis mendapatkan hasil:

1  sudo apt update
2  sudo apt install git python3-pip
3  curl https://cli-assets.heroku.com/install-ubuntu.sh | sh
4  reboot
5  history
Hasil di atas pasti akan berbeda-beda setiap orang karena kita mungkin akan menggunakan perintah-perintah yang berbeda pula.

Di sebelah kiri, kita bisa melihat nomor perintah yang menunjukkan urutan keberapa perintah tersebut di eksekusi. Apabila kamu ingin manjalankan ulang perintah tertentu cukup tuliskan tanda seru ! diikuti nomornya:

$ !4
Perintah di atas akan memanggil perintah nomor 4 yaitu reboot yang mengakibatkan komputer melakukan restart.

Kita juga bisa mencari perintah terakhir yang strukturnya paling cocok dengan yang kita tuliskan:

$ !sudo apt
Perintah di atas akan mengeksekusi baris kedua karena menjadi baris paling akhir dengan struktur pola penulisan kode yang paling mendekati.

Kita bisa juga menggunakan perintah berikut untuk mengulang perintah paling akhir.

$ !!
Perintah di atas akan mengulang perintah yang terakhir kali di eksekusi.

Pencarian
Kita bisa melakukan pencarian pada hasil yang ditampilkan oleh perintah history menggunakan grep atau tail.

$ history | grep apt
sudo apt update -y
history | grep apt
history | tail -n 3
history
history | grep apt
history | tail -n 3

Pada perintah di atas grep akan memfilter hasil yang mengandung teks apt saja dan tail -n 3 akan menampilkan tiga perintah yang terakhir dimasukkan (ubah angka 3 untuk mendapatkan hasil yang berbeda).

Cara lain untuk melakukan pencarian ialah dengan menekan tombol CTRL + R yang akan menampilkan recursive search. Masukan input satu persatu, maka ia akan recursive search akan menampilkan hasil yang cocok untuk dieksekusi.

$ (reverse-i-search)`su`: sudo apt install git
Menghapus history
Ada saatnya kita ingin menghapus beberapa atau semua perintah yang dicatat oleh history. Jika ingin menghapus baris history tertentu gunakan perintah history -d <nomor>. Untuk menghapus seluruh catatan file history, jalankan history -c.

File yang mencatat history bisa kita modifikasi juga. Pengguna shell Bash bisa menemukan file ini sebagai .bash_history di direktori home.

Penutup
History masih memiliki banyak fitur-fitur lain yang bisa disesuaikan dengan kebutuhan. Kunjungi GNU Bash Manual untuk daftar semua fitur yang bisa dijalankan.

Sumber : opensource.com



 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Macys Printable Coupons