1 – Install Apache
# sudo apt-get update
$ sudo apt-get install apache2
You will see a web page
The configuration system is fully documented in /usr/share/doc/apache2/README.Debian.gz
The configuration layout for an Apache2 web server installation on Ubuntu systems is as follows:
/etc/apache2/ |-- apache2.conf | `-- ports.conf |-- mods-enabled | |-- *.load | `-- *.conf |-- conf-enabled | `-- *.conf |-- sites-enabled | `-- *.conf
Apache commands, status, stop, start, restart
$ sudo service apache2 status
$ sudo service apache2 stop
$ sudo service apache2 start
$ sudo service apache2 restart
Warning:
If you see this message:
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
For local static ip machines follow these instructions to solve the above issue:
1- Add ServerName localhost at the end of the file and save it
$ sudo vi /etc/apache2/apache2.conf
ServerName localhost
2 – Then create a file with your real server name i.e. online2
$ sudo vi /etc/apache2/conf-available/online2.conf
add ServerName localhost to the line and save it
3- Create a soft link under /etc/apache2/conf-enabled
$ sudo ln -s /etc/apache2/conf-available/online2.conf .
4- Restart your apache
$ sudo service apache2 restart
2- Install MySQL
# sudo apt-get install mysql-server php5-mysql
MySQL “root” user password:$ sudo mysql_install_db
$ sudo mysql_secure_installation
MySQL command:
Access MySQL
# sudo mysql -u root -p
Available Databases
mysql> SHOW DATABASES;
+——————–+
| Database |
+——————–+
| information_schema |
| mysql |
| performance_schema |
| test |
+——————–+
4 rows in set (0.01 sec)
let’s create events database and do some tests
mysql> CREATE DATABASE events;
mysql> USE events;
mysql> CREATE TABLE potluck (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(20),
food VARCHAR(30),
confirmed CHAR(1),
signup_date DATE);
mysql> SHOW TABLES;
+——————+
| Tables_in_events |
+——————+
| potluck |
+——————+
DESCRIBE potluck;
mysql>DESCRIBE potluck;
+————-+————-+——+—–+———+—————-+
| Field | Type | Null | Key | Default | Extra |
+————-+————-+——+—–+———+—————-+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(20) | YES | | NULL | |
| food | varchar(30) | YES | | NULL | |
| confirmed | char(1) | YES | | NULL | |
| signup_date | date | YES | | NULL | |
+————-+————-+——+—–+———+—————-+
5 rows in set (0.01 sec)
let’s add a record
mysql> INSERT INTO `potluck` (`id`,`name`,`food`,`confirmed`,`signup_date`) VALUES (NULL, “John”, “Casserole”,”Y”, ‘2012-04-11’);
Query OK, 1 row affected (0.00 sec)
Let’s add more people records to the
mysql> INSERT INTO `potluck` (`id`,`name`,`food`,`confirmed`,`signup_date`) VALUES (NULL, “Sandy”, “Key Lime Tarts”,”N”, ‘2012-04-14’);
mysql> INSERT INTO `potluck` (`id`,`name`,`food`,`confirmed`,`signup_date`) VALUES (NULL, “Tom”, “BBQ”,”Y”, ‘2012-04-18’);
mysql> INSERT INTO `potluck` (`id`,`name`,`food`,`confirmed`,`signup_date`) VALUES (NULL, “Tina”, “Salad”,”Y”, ‘2012-04-10’);
mysql> SELECT * FROM potluck;
+—-+——-+—————-+———–+————-+
| id | name | food | confirmed | signup_date |
+—-+——-+—————-+———–+————-+
| 1 | John | Casserole | Y | 2012-04-11 |
| 2 | Sandy | Key Lime Tarts | N | 2012-04-14 |
| 3 | Tom | BBQ | Y | 2012-04-18 |
| 4 | Tina | Salad | Y | 2012-04-10 |
+—-+——-+—————-+———–+————-+
4 rows in set (0.00 sec)
mysql>exit;
Also don’t forget to install mysql-client
$ sudo apt-get install mysql-client
to enable remote connection to mysql
$ sudo vi /etc/mysql/my.cnf
disable the line by commenting out
# bind-address 127.0.0.1
Restart mysql
$ sudo service mysql restart
Let’s give rights to the remote server
https://rtcamp.com/tutorials/mysql/remote-access/
give grants to your server
$ sudo mysql -u root -p
mysql> GRANT ALL PRIVILEGES ON *.* TO ‘root’@’1.1.1.57’ IDENTIFIED BY ‘YourPassword’ WITH GRANT OPTION;
let’s lookup all outcome
mysql> SELECT * from information_schema.user_privileges where grantee like “’root’%”;
Finally, you may also need to run:
mysql> FLUSH PRIVILEGES;
Test Remote Connection
From terminal/command-line via another server (ubuntu virtual server) to production ubuntu server:
$ sudo mysql -u root -p -h 1.1.1.57 -P 3306
mysql> show databases;
3- Install PHP
$ sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt
to make apache look first index.php, move “index.php” in dir.conf to the begining
$ sudo nano /etc/apache2/mods-enabled/dir.conf
restart apache server for the changes to be get recognized
$ sudo service apache2 restart
4- Install PHP Modules
To see the available options for PHP modules and libraries
$ apt-cache search php5-
For more information about a php package
i.e
$ apt-cache show php5-mysql
To install more than one module (no need if already there)
$ sudo apt-get install php5-cli php5-mysql …
Make sure you have the latest version of VIM (You can also use Nano)
$ sudo apt-get install vim
Let’s see if all required additional libraries are installed.
(We already installed most of them earlier on php-apache-mysql)
$ sudo apt-get install graphviz aspell php5-pspell php5-curl php5-gd php5-intl php5-mysql php5-xmlrpc php5-ldap clamav
Restart Apache so that the modules are loaded correctly
$ sudo service apache2 restart
5- Install and Secure phpMyAdmin
$ sudo apt-get install phpmyadmin apache2-utils
Select Apache2 for the server Choose YES when asked about whether to Configure the database for phpmyadmin with dbconfig-common Enter your MySQL password when prompted Enter the password that you want to use to log into phpmyadmin
Enter apache2.conf file to point phpmyadmin
$ sudo nano /etc/apache2/apache2.conf
Add the phpmyadmin config to the file
Include /etc/phpmyadmin/apache.conf
Restart apache
$ sudo service apache2 restart
One thought on “INSTALL LAMP ON UBUNTU 14.04”