Archives For November 30, 1999

How to Disable Ping Response on Ubuntu Server

Last updated: April 21, 2024

This simple and brief tutorial is going to show you how to disable ping response on Ubuntu Server to make it more secure.

To get started, you need to first run command below to get the root privilege:

sudo su

Then, you can disable ping for IPv4 using the command below to set config file value to 1:

echo  1  > /proc/sys/net/ipv4/icmp_echo_ignore_all

For IPv6, you may use the command below instead:

echo 1 > /proc/sys/net/ipv6/icmp/echo_ignore_all

Or, you can use iptables command instead to do the same job. Though, you need to replace eth0 to yours network interface name (run ip -4 address to tell).

iptables  -I  INPUT  -i  eth0  -p   icmp  -s  0/0  -d  0/0   -j  DROP

To re-enable ping response, use commands:

echo  0  > /proc/sys/net/ipv4/icmp_echo_ignore_all
echo 1 > /proc/sys/net/ipv6/icmp/echo_ignore_all

or

iptables  -I  INPUT  -i  eth0  -p   icmp  -s  0/0  -d  0/0   -j  ACCEPT

To make it permanently, edit the “/etc/sysctl.conf” file and add the link below, so that the setting gets picked up at boot time.

net.ipv4.icmp_echo_ignore_all=1

Change Date and Time on Ubuntu 24.04 Server

Last updated: April 22, 2024

time

This simple tutorial is going to show Ubuntu beginners how to display and change date and time on Ubuntu Linux both Server and Desktop.

UPDATE: The commands in this tutorial are tested and also works in Ubuntu 24.04.

To display data and time, use date command:

date

Sample output:

Wed Jul 3 20:59:28 CST 2013

To display calendar, use cal command:

cal

If the command not found, run sudo apt install ncal to install it.

Sample output:

July 2013
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31

To change date and time, use command:

sudo date -s "4 June 2020 18:00:00"

NOTE: your Ubuntu server may enabled network time synchronization. The command above will NOT work until you disable it by using command:

sudo timedatectl set-ntp no

To re-enable network time synchronization, run command:

sudo timedatectl set-ntp yes

How to Install WordPress on Ubuntu Server

Last updated: April 22, 2024

Wordpress
Already installed LAMP or LEMP (Nginx with PHP, Mysql) on your Ubuntu Server? This time I’m going to show you how to install WordPress CMS.

WordPress is a popular blogging tool and a content management system (CMS) based on PHP and MySQL. It’s free and open-source.

To install WordPress, first login your Ubuntu Server as root, then follow the steps below:

1.) Create Mysql Database and User for WordPress.

    • First log into Mysql as root user:
      mysql -u root -p

Type in the root password to get past.

  • Create a database. Change database-name in code to whatever you want.
    CREATE DATABASE database-name;
  • Create an user. Change database-user in code to whatever you want.
    CREATE USER database-user@localhost;
  • Give a password to the user just created. Change password-here in code.
    SET PASSWORD FOR database-user@localhost= PASSWORD("password-here");
  • Grant all privileges to the new user.
    GRANT ALL PRIVILEGES ON database-name.* TO database-user@localhost IDENTIFIED BY 'password-here';
  • f.) Finally, refresh Mysql:
    FLUSH PRIVILEGES;
  • g.) Exit Mysql sell
    exit

2.) Download WordPress and setup the configuration.

  • Download the latest wordpress:
    wget http://wordpress.org/latest.tar.gz

    Then extract:

    tar -xzvf latest.tar.gz
  • Copy the sample configuration file to make a backup.
    cd wordpress && cp wp-config-sample.php wp-config.php
  • Edit the configuration file:
    vi wp-config.php

    Press I to start editing, Esc to stop editing. Press :, then type wq to save and exit, type q! to exit without save.

    Then change the section of database-name, database-user, password-here.

    // ** MySQL settings – You can get this info from your web host ** //
    /** The name of the database for WordPress */
    define(‘DB_NAME’, ‘database-name’);

    /** MySQL database username */
    define(‘DB_USER’, ‘database-user’);

    /** MySQL database password */
    define(‘DB_PASSWORD’, ‘password-here’);

3.) Setup the permissions.

    • Give ownership of the directory to the apache or nginx user by running following commands one by one:
sudo rsync -avP ~/wordpress/ /var/www/
cd /var/www/
sudo chown www-data:www-data * -R 
sudo usermod -a -G www-data username

4.) Finally in your browser go to IP or domain/wp-admin/install.php and start installing.

Enjoy!

Want to build a website? Then you need to setup a web server! Here I’ll show you how to install and setup LAMP pack on Ubuntu 12.04 LTS Server.

LAMP is a combination of Linux (OS), Apache HTTP Server, PHP (open-source scripting language), and MySQL (database software).

In this tutorial I use the hostname www.example.com with the IP address 192.168.0.100 as example.

1.) Login or Remote access your server as root, or run command to get root privileges.

sudo su

2.) Install Mysql:

apt-get install mysql-server mysql-client

You’ll be asked to set a password for root user of Mysql.

3.) Install Apache2:

apt-get install apache2

After installed, test if it works by going to http://192.168.0.100 in your web browser. Remember change the IP to yours.

apache-wellcome-page

The default default document root is /var/www/, and the configuration file is /etc/apache2/apache2.conf.

4.) Install PHP5:

apt-get install php libapache2-mod-php

Restart Apache2 service to get it works with PHP:

systemctl restart apache2

5.) To test if PHP works, create info.php in the root directory “/var/www/”:

nano /var/www/info.php

Then insert following lines:

<?php
phpinfo();
?>

Then press Ctrl+S to save file and Ctrl+X to exit. Then in browser go to http://192.168.0.100:info.php (replace ip to yours)

Phpinfo

6.) To get Mysql support in PHP, install following packages:

apt-get install php-mysql php-curl php-gd php-intl php-pear php-imagick php-imap php-memcache php-ps php-pspell php-snmp php-sqlite3 php-tidy php-xmlrpc php-xsl

Then restart Apache2 service:

systemctl restart apache2

Go to or reload http://192.168.0.100/info.php in your browser:

Mysql-support-in-php5

7.) (Optional) Install phpMyAdmin, a web interface to manage Mysql Databases:

apt-get install phpmyadmin

After installed, go to http://192.168.0.100/phpmyadmin/, login with root and password you set in step 2.