{"id":6389,"date":"2021-05-20T09:35:12","date_gmt":"2021-05-20T09:35:12","guid":{"rendered":"https:\/\/linuxways.net\/?p=6389"},"modified":"2021-05-20T09:35:12","modified_gmt":"2021-05-20T09:35:12","slug":"how-to-install-php-on-ubuntu-20-04","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/ubuntu\/how-to-install-php-on-ubuntu-20-04\/","title":{"rendered":"How to Install PHP on Ubuntu 20.04"},"content":{"rendered":"<p>PHP stands for Hypertext Preprocessor, free and open source, server-side scripting language that can also integrate into HTML. PHP language is suitable for dynamic and interactive web development. This is the most common and widely used web programming language in the world. PHP is an interpreted language so, you don\u2019t require a compiler to run the PHP program. PHP processing acts as a bridge between the PHP interpreter and the webserver.<\/p>\n<p>We will go through the PHP installation on Ubuntu 20.04 system in this article.<\/p>\n<h2><strong>Prerequisites<\/strong><\/h2>\n<p>You need sudo privileges to run the administrative commands.<\/p>\n<h2><strong>PHP installation steps on Ubuntu 20.04<\/strong><\/h2>\n<p>The installation of PHP completed into the following steps:<\/p>\n<h3><strong>Step 1: Install PHP modules<\/strong><\/h3>\n<p>Update the apt packages of your system and then type the following command on the terminal to install PHP components:<\/p>\n<pre>$ sudo apt install php libapache2-mod-php php-mysql<\/pre>\n<p>Enter the administrative password and in a while, a prompt interrupt the installation. Press \u2018y\u2019 and then hit the \u2018Enter\u2019 key to continue this process.<\/p>\n<p>After that, all PHP modules to be installed on your system. You can also install the required PHP extension depending on the project requirements.<\/p>\n<h3><strong>Step 2: Check installed PHP version<\/strong><\/h3>\n<p>Verify the installation of PHP by running the following command:<\/p>\n<pre>$ php --version<\/pre>\n<p>The installed PHP version should display on the terminal.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1079\" height=\"168\" class=\"wp-image-6390\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-84.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-84.png 1079w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-84-300x47.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-84-1024x159.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-84-768x120.png 768w\" sizes=\"auto, (max-width: 1079px) 100vw, 1079px\" \/><\/p>\n<h3><strong>Step 3: Install required PHP extensions<\/strong><\/h3>\n<p>To search for the relevant PHP extension type the following command on the terminal:<\/p>\n<pre>$ sudo apt-cache search php | grep php-<\/pre>\n<p>The all PHP extensions list displays on the terminal. You can find the relevant PHP extension and install it on your system by using the following syntax:<\/p>\n<pre>$ sudo apt install php-[extension-name]<\/pre>\n<h3><strong>Step 4: Configure PHP<\/strong><\/h3>\n<p>To configure the PHP for your web applications, you need to change certain values in the php.ini configuration file. Type the following command to open the \u2018php.ini\u2019 configuration file:<\/p>\n<pre>$ sudo nano \/etc\/php\/7.4\/apache2\/php.ini<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1067\" height=\"34\" class=\"wp-image-6391\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-85.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-85.png 1067w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-85-300x10.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-85-1024x33.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-85-768x24.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-85-1020x34.png 1020w\" sizes=\"auto, (max-width: 1067px) 100vw, 1067px\" \/><\/p>\n<p>Now, find and change the following values in the configuration file:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1082\" height=\"798\" class=\"wp-image-6392\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-86.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-86.png 1082w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-86-300x221.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-86-1024x755.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-86-768x566.png 768w\" sizes=\"auto, (max-width: 1082px) 100vw, 1082px\" \/><\/p>\n<pre># Upload max write = 32 M\r\n\r\n# After max size = 48 M\r\n\r\n# Speicher limit = 256 M\r\n\r\n# Max perform time = 600\r\n\r\n# Input vars = 3000\r\n\r\n# Input time max = 1000<\/pre>\n<p>Once you have changed the PHP configuration settings. Now, restart the service of the apache server by typing the following command:<\/p>\n<pre>$ sudo systemctl restart apache2<\/pre>\n<h3><strong>Step 5: Test the PHP installation<\/strong><\/h3>\n<p>Now, create a new PHP file in the web directory. Here, we have created a new file with the name \u2018info.php\u2019 by using the following command:<\/p>\n<pre>$ sudo nano \/var\/www\/html\/info.php<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1073\" height=\"33\" class=\"wp-image-6393\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-87.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-87.png 1073w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-87-300x9.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-87-1024x31.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-87-768x24.png 768w\" sizes=\"auto, (max-width: 1073px) 100vw, 1073px\" \/><\/p>\n<p>Paste the following PHP code in the above file:<\/p>\n<pre>&lt;? php\r\n\r\necho \u201cWelcome to PHP installation Tutorial!\u201d;\r\n\r\n?&gt;<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1092\" height=\"288\" class=\"wp-image-6394\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-88.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-88.png 1092w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-88-300x79.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-88-1024x270.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-88-768x203.png 768w\" sizes=\"auto, (max-width: 1092px) 100vw, 1092px\" \/><\/p>\n<p>Save this file and open the following URL in your browser:<\/p>\n<pre>http:\/\/server-ip\/info.php<\/pre>\n<p>For example, 127.0.0.1\/info.php<\/p>\n<p>The following output should display on the terminal after running the above code:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1090\" height=\"222\" class=\"wp-image-6395\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-89.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-89.png 1090w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-89-300x61.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-89-1024x209.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-89-768x156.png 768w\" sizes=\"auto, (max-width: 1090px) 100vw, 1090px\" \/><\/p>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>We have explained all details in this article that are necessary for the PHP installation on Ubuntu 20.04 system. By using the above installation steps, you can easily install the PHP components and extensions on your Ubuntu system.<\/p>\n<p>&nbsp;<\/p>","protected":false},"excerpt":{"rendered":"<p>PHP stands for Hypertext Preprocessor, free and open source, server-side scripting language that can also integrate into HTML. PHP language is suitable for dynamic and interactive web development.&hellip;<\/p>","protected":false},"author":1,"featured_media":6442,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[70,100],"class_list":["post-6389","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ubuntu","tag-php","tag-ubuntu-20-04"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/6389","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=6389"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/6389\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/6442"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=6389"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=6389"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=6389"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}