{"id":2556,"date":"2015-02-24T23:34:59","date_gmt":"2015-02-24T22:34:59","guid":{"rendered":"http:\/\/michlstechblog.info\/blog\/?p=2556"},"modified":"2016-06-07T15:26:09","modified_gmt":"2016-06-07T13:26:09","slug":"linux-install-lamp-stack-on-debian","status":"publish","type":"post","link":"https:\/\/michlstechblog.info\/blog\/linux-install-lamp-stack-on-debian\/","title":{"rendered":"Linux: Install LAMP stack on debian"},"content":{"rendered":"<div class=\"twoclick_social_bookmarks_post_2556 social_share_privacy clearfix 1.6.4 locale-en_US sprite-en_US\"><\/div><div class=\"twoclick-js\"><script type=\"text\/javascript\">\/* <![CDATA[ *\/\njQuery(document).ready(function($){if($('.twoclick_social_bookmarks_post_2556')){$('.twoclick_social_bookmarks_post_2556').socialSharePrivacy({\"services\":{\"flattr\":{\"uid\":\"Michl\",\"status\":\"on\",\"the_title\":\"Linux%3A%20Install%20LAMP%20stack%20on%20debian\",\"the_excerpt\":\"Hi%20%2C%0D%0A%0D%0Athis%20post%20describes%20the%20steps%20to%20install%20a%20lamp%20stack%20on%20debian%20linux.%20This%20is%20the%20base%20for%20many%20content%20management%20systems%20like%20Joomla%2C%20Wordpress%20or%20Drupal.%0D%0A%0D%0ALAMP%20means%20linux%20as%20operating%20system%2C%20apache%20as%20webserver%2C%C2%A0%20mysql%20as%20database%20and%20PHP%20as%20script%20language.%20To%20install%20all%20packages%20login%20as%20root.%0D%0A%20%28more%26hellip%3B%29\",\"txt_info\":\"2 clicks for more data protection:\\r\\n\\r\\nOnly when you click here, the button will be come active and you can send your recommendation to Flattr. When activating, data are transmitted to third parties. \",\"perma_option\":\"off\"}},\"txt_help\":\"When you activate these fields by clicking, information to Flattr may be transferred abroad, and probably may also stored there.\",\"settings_perma\":\"Enable permanently and accept data transmission. \",\"info_link\":\"http:\\\/\\\/www.heise.de\\\/ct\\\/artikel\\\/2-Klicks-fuer-mehr-Datenschutz-1333879.html\",\"uri\":\"https:\\\/\\\/michlstechblog.info\\\/blog\\\/linux-install-lamp-stack-on-debian\\\/\",\"post_id\":2556,\"post_title_referrer_track\":\"Linux%3A+Install+LAMP+stack+on+debian\",\"display_infobox\":\"on\"});}});\n\/* ]]> *\/<\/script><\/div><p>Hi ,<\/p>\n<p>this post describes the steps to install a lamp stack on debian linux. This is the base for many content management systems like Joomla, WordPress or Drupal.<\/p>\n<p>LAMP means linux as operating system, apache as webserver,\u00a0 mysql as database and PHP as script language. To install all packages login as root.<br \/>\n<!--more--><br \/>\nRefresh package list from repositories<br \/>\n<code><br \/>\nroot@debdevt:~# apt-get update<br \/>\n<\/code><br \/>\nInstall apache 2<br \/>\n<code><br \/>\nroot@debdevt:~# apt-get -y install apache2<br \/>\n<\/code><br \/>\nThe config of the default site (http) is defined in file<br \/>\n<code>\/etc\/apache2\/sites-available\/000-default.conf<\/code><br \/>\nAdd a<br \/>\n<code><br \/>\nHostnameLookups Off<br \/>\n<\/code><br \/>\ndirective to do not resolve IP Addresses to hostnames in logfile.<br \/>\nNote: If wordpress permalinks returns 404 file not found errorpages add a<br \/>\n<code><br \/>\n&lt;Directory \/var\/www\/html&gt;<br \/>\nAllowOverride All<br \/>\n&lt;\/Directory&gt;<br \/>\n<\/code><br \/>\ndirective into the virtualhost section of \/etc\/apache2\/sites-available\/000-default.conf. Also check that module mod_rewrite is enabled.<br \/>\n<code>root@debdevt:~# a2query -m rewrite<br \/>\n<\/code><br \/>\nif not enable it<br \/>\n<code>root@debdevt:~# a2enmod rewrite<\/code><br \/>\nand check if the .htaccess file in the root directory of your wordpress installation is writeable for the user www-data.<br \/>\n<code>root@debdevt:\/var\/www\/html\/blog# ls -la \/var\/www\/html\/blog\/.htaccess<br \/>\n-rw-rw---- 1 www-data root 246 Feb 24 22:32 \/var\/www\/html\/blog\/.htaccess<br \/>\n<\/code><\/p>\n<p>respectively for https<br \/>\n<code>\/etc\/apache2\/sites-available\/default-ssl.conf<\/code><br \/>\n<strong>Note<\/strong>: https is disabled by default due to missing certificates. <a title=\"OpenSSL: Command line examples\" href=\"http:\/\/michlstechblog.info\/blog\/openssl-command-line-examples\/\">Here<\/a> you can find an how to generate a selfsigned certificate for an apache webserver.<\/p>\n<p>Start apache. On Debian 7 Wheezy<br \/>\n<code>root@debdevt:~# service start apache2<\/code><br \/>\nOn Debian 8 Jessie type<br \/>\n<code>root@debdevt:~# systemctl start apache2<\/code><br \/>\nif the start on jessie fails check systemd log<br \/>\n<code>root@debdevt:~# journalctl -xn<\/code><\/p>\n<p>Install MySQL. During the installation you will be prompted for the mysql root password. Choose a secure password and notice it in a secure location.<br \/>\n<code><br \/>\nroot@debdevt:~# apt-get -y install mysql-server<br \/>\n<\/code><br \/>\nSecure your MySQL database installation<br \/>\n<code><br \/>\nroot@debdevt:~# mysql_secure_installation<br \/>\nRemove anonymous users? [Y\/n] y<br \/>\n... Success!<br \/>\nDisallow root login remotely? [Y\/n] y<br \/>\n... Success!<br \/>\nRemove test database and access to it? [Y\/n] y<br \/>\n- Dropping test database...<br \/>\nReload privilege tables now? [Y\/n] y<br \/>\n... Success!<\/code><\/p>\n<p>Open MySQL Console<br \/>\n<code><br \/>\nroot@debdevt:~# mysql -u root -p<br \/>\n<\/code><br \/>\nCreate a database named cms and a user with full permission on the datebase with Username cmsuser and password cmspassword<br \/>\n<code><br \/>\nmysql&gt; create database cms;<br \/>\nmysql&gt; CREATE USER 'cmsuser'@'localhost' identified by 'cmspassword';<br \/>\nmysql&gt; grant all on cms.* to 'cmsuser'@'localhost';<br \/>\n<\/code><br \/>\nInstall php<br \/>\n<code><br \/>\nroot@debdevt:~# apt-get -y install php5 libapache2-mod-php5 php5-mcrypt php5-mysql php-pear<br \/>\n<\/code><br \/>\nCheck PHP. Create a php file in your webserver root<\/p>\n<pre><code>\r\ncat &gt; \/var\/www\/html\/phpinfo.php &lt;&lt;EOF\r\n&lt;?php\r\nphpinfo();\r\n?&gt;\r\nEOF\r\n<\/code><\/pre>\n<p>Time to check the LAMP stack. Open a browser and navigate to<br \/>\n<code>http:\/\/IPorHostnameOfyourLAMP\/phpinfo.php<\/code><br \/>\nthis should show a php status site.<\/p>\n<figure id=\"attachment_2576\" aria-describedby=\"caption-attachment-2576\" style=\"width: 480px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2015\/02\/php-state.png\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-2576 \" title=\"PHP State\" alt=\"PHP State\" src=\"http:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2015\/02\/php-state.png\" width=\"480\" height=\"369\" srcset=\"https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2015\/02\/php-state.png 600w, https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2015\/02\/php-state-300x230.png 300w\" sizes=\"auto, (max-width: 480px) 100vw, 480px\" \/><\/a><figcaption id=\"caption-attachment-2576\" class=\"wp-caption-text\">PHP State<\/figcaption><\/figure>\n<p>If phpinfo site is shown correctly delete the file<br \/>\n<code>root@debdevt:~# rm \/var\/www\/html\/phpinfo.php<\/code><\/p>\n<p>Not necessary but useful: Enable apache PHP logging for apache.<br \/>\nCreate a directory for logs<br \/>\n<code><br \/>\nroot@debdevt:~# mkdir \/var\/log\/php<br \/>\nroot@debdevt:~# chown www-data \/var\/log\/php<\/code><br \/>\nEdit <strong>\/etc\/php5\/apache2\/php.ini<\/strong> and set<\/p>\n<pre><code>error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR\r\ndisplay_errors = Off \r\nlog_errors = On \r\nerror_log = \/var\/log\/php\/error.log  <\/code><\/pre>\n<p>To import a database exported by myPhpAdmin for example. Open the sql file and alter the database name at the top of the file<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\nCREATE DATABASE IF NOT EXISTS `DATABASE_AT_WEBHOSTER` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;\r\nUSE `DATABASE_AT_WEBHOSTER`;\r\n<\/pre>\n<p>to<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\nCREATE DATABASE IF NOT EXISTS `cms` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;\r\nUSE `cms`;\r\n<\/pre>\n<p>and import the database<br \/>\n<code><br \/>\nroot@debdevt:~# mysql -u cmsuser -p &lt; exported_database.sql<br \/>\n<\/code><\/p>\n<p>That&#8217;s it.<\/p>\n<p>Michael<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi , this post describes the steps to install a lamp stack on debian linux. This is the base for many content management systems like Joomla, WordPress or Drupal. LAMP means linux as operating system, apache as webserver,\u00a0 mysql as database and PHP as script language. To install all packages login as root.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[39,3],"tags":[625,859,623,119,622,619,224,620,624,621,862],"class_list":["post-2556","post","type-post","status-publish","format-standard","hentry","category-apache","category-linux","tag-625","tag-apache","tag-cms","tag-install","tag-joomla","tag-lamp","tag-linux-2","tag-mysql-2","tag-permalinks","tag-php","tag-wordpress"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/2556","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/comments?post=2556"}],"version-history":[{"count":32,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/2556\/revisions"}],"predecessor-version":[{"id":3749,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/2556\/revisions\/3749"}],"wp:attachment":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/media?parent=2556"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/categories?post=2556"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/tags?post=2556"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}