phpmyadmin not found in ubuntu 16.04

phpmyadmin not found in ubuntu 16.04

sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
sudo a2enconf phpmyadmin.conf
sudo systemctl restart apache2

How To Set Up Apache Virtual Hosts on Ubuntu 16.04

How To Set Up Apache Virtual Hosts on Ubuntu 16.04

Introduction

The Apache web server is the most popular way of serving web content on the internet. It accounts for more than half of all active websites on the internet and is extremely powerful and flexible.

Apache breaks its functionality and components into individual units that can be customized and configured independently. The basic unit that describes an individual site or domain is called a virtual host.

These designations allow the administrator to use one server to host multiple domains or sites off of a single interface or IP by using a matching mechanism. This is relevant to anyone looking to host more than one site off of a single VPS.

Each domain that is configured will direct the visitor to a specific directory holding that site’s information, never indicating that the same server is also responsible for other sites. This scheme is expandable without any software limit as long as your server can handle the load.

In this guide, we will walk you through how to set up Apache virtual hosts on an Ubuntu 16.04 VPS. During this process, you’ll learn how to serve different content to different visitors depending on which domains they are requesting.

Prerequisites

Before you begin this tutorial, you should create a non-root user as described in steps 1-4 here.

You will also need to have Apache installed in order to work through these steps. If you haven’t already done so, you can get Apache installed on your server through apt-get:

  • sudo apt-get update
  • sudo apt-get install apache2

After these steps are complete, we can get started.

For the purposes of this guide, our configuration will make a virtual host for example.com and another for test.com. These will be referenced throughout the guide, but you should substitute your own domains or values while following along.

To learn how to set up your domain names with DigitalOcean, follow this link. If you do not have domains available to play with, you can use dummy values.

We will show how to edit your local hosts file later on to test the configuration if you are using dummy values. This will allow you to test your configuration from your home computer, even though your content won’t be available through the domain name to other visitors.

Step One — Create the Directory Structure

The first step that we are going to take is to make a directory structure that will hold the site data that we will be serving to visitors.

Our document root (the top-level directory that Apache looks at to find content to serve) will be set to individual directories under the /var/www directory. We will create a directory here for both of the virtual hosts we plan on making.

Within each of these directories, we will create a public_html folder that will hold our actual files. This gives us some flexibility in our hosting.

For instance, for our sites, we’re going to make our directories like this:

  • sudo mkdir -p /var/www/example.com/public_html
  • sudo mkdir -p /var/www/test.com/public_html

The portions in red represent the domain names that we are wanting to serve from our VPS.

Step Two — Grant Permissions

Now we have the directory structure for our files, but they are owned by our root user. If we want our regular user to be able to modify files in our web directories, we can change the ownership by doing this:

  • sudo chown -R $USER:$USER /var/www/example.com/public_html
  • sudo chown -R $USER:$USER /var/www/test.com/public_html

The $USER variable will take the value of the user you are currently logged in as when you press Enter. By doing this, our regular user now owns the public_html subdirectories where we will be storing our content.

We should also modify our permissions a little bit to ensure that read access is permitted to the general web directory and all of the files and folders it contains so that pages can be served correctly:

  • sudo chmod -R 755 /var/www

Your web server should now have the permissions it needs to serve content, and your user should be able to create content within the necessary folders.

Step Three — Create Demo Pages for Each Virtual Host

We have our directory structure in place. Let’s create some content to serve.

We’re just going for a demonstration, so our pages will be very simple. We’re just going to make an index.html page for each site.

Let’s start with example.com. We can open up an index.html file in our editor by typing:

  • nano /var/www/example.com/public_html/index.html

In this file, create a simple HTML document that indicates the site it is connected to. My file looks like this:

/var/www/example.com/public_html/index.html

<html>
  <head>
    <title>Welcome to Example.com!</title>
  </head>
  <body>
    <h1>Success!  The example.com virtual host is working!</h1>
  </body>
</html>

Save and close the file when you are finished.

We can copy this file to use as the basis for our second site by typing:

  • cp /var/www/example.com/public_html/index.html /var/www/test.com/public_html/index.html

We can then open the file and modify the relevant pieces of information:

  • nano /var/www/test.com/public_html/index.html

/var/www/test.com/public_html/index.html

<html>
  <head>
    <title>Welcome to Test.com!</title>
  </head>
  <body> <h1>Success!  The test.com virtual host is working!</h1>
  </body>
</html>

Save and close this file as well. You now have the pages necessary to test the virtual host configuration.

Step Four — Create New Virtual Host Files

Virtual host files are the files that specify the actual configuration of our virtual hosts and dictate how the Apache web server will respond to various domain requests.

Apache comes with a default virtual host file called 000-default.conf that we can use as a jumping off point. We are going to copy it over to create a virtual host file for each of our domains.

We will start with one domain, configure it, copy it for our second domain, and then make the few further adjustments needed. The default Ubuntu configuration requires that each virtual host file end in .conf.

Create the First Virtual Host File

Start by copying the file for the first domain:

  • sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example.com.conf

Open the new file in your editor with root privileges:

  • sudo nano /etc/apache2/sites-available/example.com.conf

The file will look something like this (I’ve removed the comments here to make the file more approachable):

/etc/apache2/sites-available/example.com.conf

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

As you can see, there’s not much here. We will customize the items here for our first domain and add some additional directives. This virtual host section matches any requests that are made on port 80, the default HTTP port.

First, we need to change the ServerAdmin directive to an email that the site administrator can receive emails through.

ServerAdmin admin@example.com

After this, we need to add two directives. The first, called ServerName, establishes the base domain that should match for this virtual host definition. This will most likely be your domain. The second, called ServerAlias, defines further names that should match as if they were the base name. This is useful for matching hosts you defined, like www:

ServerName example.com
ServerAlias www.example.com

The only other thing we need to change for a basic virtual host file is the location of the document root for this domain. We already created the directory we need, so we just need to alter the DocumentRootdirective to reflect the directory we created:

DocumentRoot /var/www/example.com/public_html

In total, our virtualhost file should look like this:

/etc/apache2/sites-available/example.com.conf

<VirtualHost *:80>
    ServerAdmin admin@example.com
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example.com/public_html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Save and close the file.

Copy First Virtual Host and Customize for Second Domain

Now that we have our first virtual host file established, we can create our second one by copying that file and adjusting it as needed.

Start by copying it:

  • sudo cp /etc/apache2/sites-available/example.com.conf /etc/apache2/sites-available/test.com.conf

Open the new file with root privileges in your editor:

  • sudo nano /etc/apache2/sites-available/test.com.conf

You now need to modify all of the pieces of information to reference your second domain. When you are finished, it may look something like this:

/etc/apache2/sites-available/test.com.conf

<VirtualHost *:80>
    ServerAdmin admin@test.com
    ServerName test.com
    ServerAlias www.test.com
    DocumentRoot /var/www/test.com/public_html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Save and close the file when you are finished.

Step Five — Enable the New Virtual Host Files

Now that we have created our virtual host files, we must enable them. Apache includes some tools that allow us to do this.

We can use the a2ensite tool to enable each of our sites like this:

  • sudo a2ensite example.com.conf
  • sudo a2ensite test.com.conf

Next, disable the default site defined in 000-default.conf:

  • sudo a2dissite 000-default.conf

When you are finished, you need to restart Apache to make these changes take effect:

  • sudo systemctl restart apache2

In other documentation, you may also see an example using the service command:

  • sudo service apache2 restart

This command will still work, but it may not give the output you’re used to seeing on other systems, since it’s now a wrapper around systemd’s systemctl.

Step Six — Set Up Local Hosts File (Optional)

If you haven’t been using actual domain names that you own to test this procedure and have been using some example domains instead, you can at least test the functionality of this process by temporarily modifying the hosts file on your local computer.

This will intercept any requests for the domains that you configured and point them to your VPS server, just as the DNS system would do if you were using registered domains. This will only work from your computer though, and is simply useful for testing purposes.

Make sure you are operating on your local computer for these steps and not your VPS server. You will need to know the computer’s administrative password or otherwise be a member of the administrative group.

If you are on a Mac or Linux computer, edit your local file with administrative privileges by typing:

  • sudo nano /etc/hosts

If you are on a Windows machine, you can find instructions on altering your hosts file here.

The details that you need to add are the public IP address of your VPS server followed by the domain you want to use to reach that VPS.

For the domains that I used in this guide, assuming that my VPS IP address is 111.111.111.111, I could add the following lines to the bottom of my hosts file:

/etc/hosts

127.0.0.1   localhost
127.0.1.1   guest-desktop
111.111.111.111 example.com
111.111.111.111 test.com

This will direct any requests for example.com and test.com on our computer and send them to our server at 111.111.111.111. This is what we want if we are not actually the owners of these domains in order to test our virtual hosts.

Save and close the file.

Step Seven — Test your Results

Now that you have your virtual hosts configured, you can test your setup easily by going to the domains that you configured in your web browser:

http://example.com

You should see a page that looks like this:

Apache virt host example

Likewise, if you can visit your second page:

http://test.com

You will see the file you created for your second site:

Apache virt host test

If both of these sites work well, you’ve successfully configured two virtual hosts on the same server.

If you adjusted your home computer’s hosts file, you may want to delete the lines you added now that you verified that your configuration works. This will prevent your hosts file from being filled with entries that are not actually necessary.

If you need to access this long term, consider purchasing a domain name for each site you need and setting it up to point to your VPS server.

Setup Apache2 Userdir Module On Ubuntu 16.04 LTS Servers

Setup Apache2 Userdir Module On Ubuntu 16.04 LTS Servers

In most school environments is where you get to see Apache2 Userdir in action… each teacher is given his/her own website where he/she can publish materials for students to access… The URL to reach the teacher’s page is usually the domain name followed by /~teacher_name..

User Directory or Userdir for short is a module for Apache2 web server that allows user-specific directories to be accessed via Apache2. For example, when you enable this feature in Apache2, users with accounts on the system will be able to share content in their home directories with the world via Apache2..

This brief tutorial shows students and new users how to enable and configure it on Ubuntu 16.04 LTS Servers using Apache2…

To get started with enabling Userdir on Ubuntu 16.04 LTS, the steps below is a good place to start:

This tutorial assumes that you already have Apache2 web server installed. If you haven’t, you may want to do that before continuing below.

Step 1: Install Apache2 HTTP Server

First, run the commands below to install Apache2 HTTP Server on Ubuntu

sudo apt install apache2

Step 2: Enabling Userdir On Apache2

To enable Userdir module for Apache2 webservers, run the commands below

sudo a2enmod userdir

After running the commands above the feature will be enabled and ready to be used. The configuration file is at /etc/apache2/mods-enabled/userdir.conf. But you don’t have to do anything. It’s already configured with the best options.

To access the config file, run the commands below

sudo nano /etc/apache2/mods-available/userdir.conf

Then validate the settings below:

<IfModule mod_userdir.c>
     UserDir public_html
     UserDir disabled root

        <Directory /home/*/public_html>
             AllowOverride FileInfo AuthConfig Limit Indexes
             Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
             Require method GET POST OPTIONS
        </Directory>
</IfModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Step 3: Creating User Directories

Now that the feature is enabled, all users have to do is run the commands below to create a folder in their home directories called public_html by running the commands below.

mkdir ~/public_html

In the ~/public_html folder, create html documents to be shared and accessed via the webserver.

Restart Apache2 webserver to load the settings.

sudo systemctl restart apache2.service

Now test it out by browsing to the server hostname or IP address followed by the username.

example: http://example.com/~richard

This is how Apache2 Userdir module is configured for users to allow users with accounts on the systems to share content from their home directories..

That’s it!

Enjoy!

Ubuntu 16.04 LTS – How To Install PHP, phpMyAdmin and MySQL

Ubuntu 16.04 LTS – How To Install PHP, phpMyAdmin and MySQL

Step 1 – Update repositories.

root@mail:/# apt-get update

root@mail:/# apt-get upgrade

Step 2 – Install mysql with the following command.

root@mail:/# apt-get install mysql-server mysql-client

Step 3 – You have to enter password for the root user.

Step 4 – You have to repeat password for the root user.

Step 5 – Install php7 for mysql with the following command.

root@mail:/# apt-get install php7-mysql

Step 6 – Install php7myadmin with the following command.

root@mail:/# apt-get install phpmyadmin

Step 7 – Choose web server who you want to use. i strongly recommended apache2

Step 8 – Configuring phpmyadmin – Configure database for phpmyadmin with dbconfig-common? write YES

Step 9 – Configuring phpmyadmin – Password of the database’s administrative user:

Step 10 – Configuring phpmyadmin – MySQL application password for phpmyadmin:

Step 11 – Configuring phpmyadmin – Password confirmation:

Step 12 – You have to write the ip address of your server “/” and phpmyadmin. You will phpMyAdmin.

Step 13 – You have to write password for the root user and login into phpmyadmin.

Step 14 – Restart apache service.

root@mail:/# service apache2 restart

curl_init not working ubuntu

curl_init not working ubuntu

sudo apt update
sudo apt install php7.0-curl   or sudo apt-get install php-curl
sudo phpenmod curl
sudo systemctl restart apache2.service

mail function not working in ec2 amazon aws php

mail function not working in ec2 amazon aws php

Just follow instructions below (Tested for ubuntu 10x EC2)

sudo apt-get install php-pear   // Install php-pear if not installed 

sudo pear install mail  

sudo pear install Net_SMTP

sudo pear install Auth_SASL

sudo pear install mail_mime

sudo apt-get install postfix

sudo service apache2 restart

hot to modify user group ubuntu

hot to modify user group ubuntu

To modify an existing user, like adding that user to a new group, use the usermod command.

Try this:

sudo usermod -a -G groupName userName

The user will need to log out and log back in to see their new group added.

  • The -a (append) switch is essential. Otherwise, the user will be removed from any groups, not in the list.
  • The -G switch takes a (comma-separated) list of additional groups to assign the user to.

How To Create a Sudo User on Ubuntu

How To Create a Sudo User on Ubuntu

The sudo command provides a mechanism for granting administrator privileges, ordinarily only available to the root user, to normal users. This guide will show you the easiest way to create a new user with sudo access on Ubuntu, without having to modify your server’s sudoers file. If you want to configure sudo for an existing user, simply skip to step 3.

Steps to Create a New Sudo User

  1. Log in to your server as the root user.
    • ssh root@server_ip_address
  2. Use the adduser command to add a new user to your system.Be sure to replace username with the user that you want to create.
    • adduser username
    • Set and confirm the new user’s password at the prompt. A strong password is highly recommended! Set password prompts: Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully
    • Follow the prompts to set the new user’s information. It is fine to accept the defaults to leave all of this information blank. User information prompts: Changing the user information for username Enter the new value, or press ENTER for the default Full Name []: Room Number []: Work Phone []: Home Phone []: Other []: Is the information correct? [Y/n]
  3. Use the usermod command to add the user to the sudo group.
    • usermod -aG sudo username
    By default, on Ubuntu, members of the sudo group have sudo privileges.
  4. Test sudo access on new user account
    • Use the su command to switch to the new user account.
      • su – username
    • As the new user, verify that you can use sudo by prepending “sudo” to the command that you want to run with superuser privileges.
      • sudo command_to_run
    • For example, you can list the contents of the /root directory, which is normally only accessible to the root user.
      • sudo ls -la /root
    • The first time you use sudo in a session, you will be prompted for the password of the user account. Enter the password to proceed. Output: [sudo] password for username: If your user is in the proper group and you entered the password correctly, the command that you issued with sudo should run with root privileges.

CentOS crontab – Automate System Tasks

CentOS crontab – Automate System Tasks

We’ll show you, how to use CentOS crontab. How to automate system tasks on CentOS 7, using Centos crontab. Crontab software utility, is a time-based job scheduler in Unix-like operating systems. Cron is driven by a crontab (cron table) file, a configuration file that specifies shell commands to run periodically on a given schedule. The crontab files are stored where the lists of jobs and other instructions to the cron daemon are kept. Users can have their own individual crontab files and often there is a system-wide crontab file (usually in /etc or a subdirectory of /etc) that only system administrators can edit.


1. Connect via SSH and update the system software

First of all, connect to your Linux VPS via SSH and update all your system software to the latest version available. You can use the following command to do that:

sudo yum update

2.  Verify if cronie package is installed

To automate the system tasks, or better known as jobs under Linux, you can use an utility called Cron. Using Cron you can run scripts automatically within a specified period of time, create backup of your databases or other important files, monitor the services running on your server and many other things. To use the Cron utility, you need to install the cronie package on your system. It should be already installed on your server. To confirm, issue the following command:

sudo rpm -q cronie

3. Install cronie package

If it is not installed, you can use yum to install it. Yum is a package manager which you can use to install and manage software on CentOS 7. Run the command below:

sudo yum install cronie

4. Check if  crond service is running

The cron jobs are picked by the crond service. To check whether the crond service is running on your CentOS VPS, you can use the following command:

sudo systemctl status crond.service

5. Configure cron jobs

To configure cron jobs you need to modify the /etc/crontab file. Please note that it can only be modified by the root user. To check the current configuration, you can use the following command:

sudo cat /etc/crontab

The output should be similar to the one below:

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root

# For details see man 4 crontabs

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name  command to be executed
37 * * * * root run-parts /etc/cron.hourly
23 5 * * * root run-parts /etc/cron.daily
19 3 * * 0 root run-parts /etc/cron.weekly
23 0 6 * * root run-parts /etc/cron.monthly

As you can see the crontab file already contain explanation about how to define your own jobs. The syntax is the following:

minute hour day month day_of_week username command

An asterisk (*) in the crontab can be used to specify all valid values, so if you like command to be executed every day at midnight, you can add the following cron job:

0 0 * * * root /sample_command >/dev/null 2>&1

Your cron job will be run at:

2016-06-10 00:00:00
2016-06-11 00:00:00
2016-06-12 00:00:00
2016-06-13 00:00:00
2016-06-14 00:00:00
...

Specific users can create cron jobs too. The cron jobs for specific users are located in /var/spool/cron/username. When you create cron jobs for specific users you do not need to specify the username in the cron job. Therefore the syntax will be like the one below:

minute hour day month day_of_week command

6.  Restart the crond service

After you make the changes restart the crond service using the command below:

sudo systemctl restart crond.service

For more information you can check the man pages:

man cron

and

man crontab

If it is difficult for you to set up correct cron jobs at the beginning, you can use some cron job calculator to generate the cron job expression. There are several good cron job calculators available on the Internet.

Read Also: Ubuntu crontab


Of course you don’t have to use CentOs crontab, if you use one of our CentOS VPS hosting services, in which case you can simply ask our expert Linux admins to help you with crontab on CentOS to Automate system tasks. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post, on how to use the CentOS crontab,  please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.