{"id":130,"date":"2013-07-02T03:11:06","date_gmt":"2013-07-02T03:11:06","guid":{"rendered":"http:\/\/ubuntuhandbook.org\/?p=130"},"modified":"2024-04-22T15:19:50","modified_gmt":"2024-04-22T15:19:50","slug":"setup-lamp-ubuntu-server","status":"publish","type":"post","link":"https:\/\/ubuntuhandbook.org\/index.php\/2013\/07\/setup-lamp-ubuntu-server\/","title":{"rendered":"Install and Setup Apache2, Php, Mysql on Ubuntu Server (LAMP)"},"content":{"rendered":"<p>Want to build a website? Then you need to setup a web server! Here I&#8217;ll show you how to install and setup LAMP pack on Ubuntu 12.04 LTS Server.<\/p>\n<p>LAMP is a combination of Linux (OS), Apache HTTP Server, PHP (open-source scripting language), and MySQL (database software).<\/p>\n<p>In this tutorial I use the hostname <i>www.example.com<\/i> with the IP address <i>192.168.0.100<\/i> as example.<\/p>\n<p>1.) Login or Remote access your server as root, or run command to get root privileges.<\/p>\n<pre>sudo su<\/pre>\n<p>2.) Install Mysql:<\/p>\n<pre>apt-get install mysql-server mysql-client<\/pre>\n<p>You&#8217;ll be asked to set a password for root user of Mysql.<\/p>\n<p>3.) Install Apache2:<\/p>\n<pre>apt-get install apache2<\/pre>\n<p>After installed, test if it works by going to <i>http:\/\/192.168.0.100<\/i> in your web browser. Remember change the IP to yours.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2013\/07\/apache-wellcome-page.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-132\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2013\/07\/apache-wellcome-page-300x217.png\" alt=\"apache-wellcome-page\" width=\"300\" height=\"217\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2013\/07\/apache-wellcome-page-300x217.png 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2013\/07\/apache-wellcome-page.png 800w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>The default default document root is <i>\/var\/www\/<\/i>, and the configuration file is <i>\/etc\/apache2\/apache2.conf<\/i>.<\/p>\n<p>4.) Install PHP5:<\/p>\n<pre>apt-get install php libapache2-mod-php<\/pre>\n<p>Restart Apache2 service to get it works with PHP:<\/p>\n<pre>systemctl restart apache2<\/pre>\n<p>5.) To test if PHP works, create <i>info.php<\/i> in the root directory &#8220;\/var\/www\/&#8221;:<\/p>\n<pre>nano \/var\/www\/info.php<\/pre>\n<p>Then insert following lines:<\/p>\n<pre>&lt;?php\r\nphpinfo();\r\n?&gt;<\/pre>\n<p>Then press Ctrl+S to save file and Ctrl+X to exit. Then in browser go to <i>http:\/\/192.168.0.100:info.php (replace ip to yours)<\/i><\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2013\/07\/Phpinfo.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-142\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2013\/07\/Phpinfo-300x217.png\" alt=\"Phpinfo\" width=\"300\" height=\"217\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2013\/07\/Phpinfo-300x217.png 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2013\/07\/Phpinfo.png 800w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>6.) To get Mysql support in PHP, install following packages:<\/p>\n<pre>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<\/pre>\n<p>Then restart Apache2 service:<\/p>\n<pre>systemctl restart apache2<\/pre>\n<p>Go to or reload <i>http:\/\/192.168.0.100\/info.php<\/i> in your browser:<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2013\/07\/Mysql-support-in-php5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-145\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2013\/07\/Mysql-support-in-php5-300x217.png\" alt=\"Mysql-support-in-php5\" width=\"300\" height=\"217\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2013\/07\/Mysql-support-in-php5-300x217.png 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2013\/07\/Mysql-support-in-php5.png 800w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>7.) (Optional) Install phpMyAdmin, a web interface to manage Mysql Databases:<\/p>\n<pre>apt-get install phpmyadmin<\/pre>\n<p>After installed, go to <i>http:\/\/192.168.0.100\/phpmyadmin\/<\/i>, login with <i>root<\/i> and password you set in step 2.<\/p>","protected":false},"excerpt":{"rendered":"<p>Want to build a website? Then you need to setup a web server! Here I&#8217;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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[175,159,26,153,25],"class_list":["post-130","post","type-post","status-publish","format-standard","hentry","category-ubuntu-server-2","tag-13-10","tag-install","tag-setup-lamp","tag-ubuntu","tag-ubuntu-server"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/130","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/comments?post=130"}],"version-history":[{"count":0,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/130\/revisions"}],"wp:attachment":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media?parent=130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/categories?post=130"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/tags?post=130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}