How to install Apache, PHP 7.2, and MySQL on Ubuntu 18.04 (LTS)
Original
- Troy
- 2020-12-01 21:23:05
- 20243
ZenTao: 15 years of dedication to building open source project management software
Download Now
How to install Apache, PHP 7.2, and MySQL on Ubuntu 18.04 (LTS)
I'm running all the steps in this tutorial with root privileges, so logged in as root:
sudo -s
1. Installing MySQL or MariaDB Database ( The following example will be an installation of MariaDB 10 )
1.1 Install MariaDB 10
Run the following command to install MariaDB-server and client:apt-get -y install mariadb-server mariadb-clientNow we set a root password for MariaDB.
mysql_secure_installationYou will be asked these questions:
Enter current password for root (enter for none): <-- press enter Set root password? [Y/n] <-- y New password: <-- Enter the new MariaDB root password here Re-enter new password: <-- Repeat the password Remove anonymous users? [Y/n] <-- y Disallow root login remotely? [Y/n] <-- y Reload privilege tables now? [Y/n] <-- y1.2 Test the MySQL/MariaDB root login
Test the login to MariaDB with the "mysql command"
mysql -u root -pand enter the MariaDB root password that you've set above. The result should be similar to the screenshot below:
To leave the MySQL/MariaDB shell, enter the command "quit" and press enter.
2. Install Apache Web Server
Apache 2 is available as an Ubuntu package, therefore we can install it like this:apt-get -y install apache2Now direct your browser to http://192.168.1.100, and you should see the Apache2 default page (It works!):
The document root of the apache default vhost is /var/www/html on Ubuntu and the main configuration file is /etc/apache2/apache2.conf. The configuration system is fully documented in /usr/share/doc/apache2/README.Debian.gz.
3. Install PHP 7.2
We can install PHP 7.2 and the Apache PHP module as follows:apt-get -y install php7.2 libapache2-mod-php7.2Then restart Apache:
systemctl restart apache2
4. Test PHP and get details about your PHP installation
The document root of the default web site is /var/www/html. We will now create a small PHP file (info.php) in that directory and call it in a browser. The file will display lots of useful details about our PHP installation, such as the installed PHP version.Advertisement
nano /var/www/html/info.php
<?php phpinfo();Then change the owner of the info.php file to the www-data user and group.
chown www-data:www-data /var/www/html/info.phpNow we call that file in a browser (e.g. http://192.168.1.100/info.php):
As you see, PHP 7.2 is working, and it's working through the Apache 2.0 Handler, as shown in the Server API line. If you scroll further down, you will see all modules that are already enabled in PHP. MySQL is not listed there which means we don't have MySQL / MariaDB support in PHP yet.
5. Get MySQL / MariaDB support in PHP
To get MySQL support in PHP, we can install the php7.2-mysql package. It's a good idea to install some other PHP modules as well as you might need them for your applications. You can search for available PHP modules like this:
apt-cache search php7.2and
apt-cache search php-as not all PHP packages have the version number 7.2 in their name.
Pick the ones you need and install them like this:
apt-get -y install php7.2-mysql php7.2-curl php7.2-gd php7.2-intl php-pear php-imagick php7.2-imap php-memcache php7.2-pspell php7.2-recode php7.2-sqlite3 php7.2-tidy php7.2-xmlrpc php7.2-xsl php7.2-mbstring php-gettextNow restart Apache2:
systemctl restart apache2
PHP 7.2 has now MySQL / MariaDB support as shown in phpinfo() above.
What's more?
Once Apache, PHP and MySQL have been provisioned in Ubuntu 18.0.4, you could just go to download source code of ZenTao and unzip it to your webroot
sudo wget https://blog.easycorp.cn/dl/zentao/biz4.1/ZenTaoPMS.biz4.1.php7.2.zipSince the apache default vhost is /var/www/html on Ubuntu 18.04, so just unzip it there
sudo unzip ZenTaoPMS.biz4.1.php7.2.zip -d /var/www/htmlAnd now just direct your browser to http://192.168.1.100
For latest Enterprise version of ZenTao, https://www.zentao.pm/dynamics/scrum-tool-for-enterprises-zte4.1-798.html
Referrence
https://www.howtoforge.com/tutorial/install-apache-with-php-and-mysql-on-ubuntu-18-04-lamp/
Write a Comment
Support
- Book a Demo
- Tech Forum
- GitHub
- SourceForge
About Us
- Company
- Privacy Policy
- Term of Use
- Blogs
- Partners
Contact Us
- Leave a Message
- Email Us: [email protected]