{"id":5,"date":"2019-04-19T05:20:53","date_gmt":"2019-04-19T05:20:53","guid":{"rendered":"https:\/\/scythk.com\/?p=5"},"modified":"2019-04-19T15:14:07","modified_gmt":"2019-04-19T20:14:07","slug":"lamp-installation","status":"publish","type":"post","link":"https:\/\/scythk.com\/index.php\/2019\/04\/19\/lamp-installation\/","title":{"rendered":"LAMP Installation on Ubuntu 16.04"},"content":{"rendered":"<p>After a whole day working on my site, I finally got it runs.<\/p>\n<p>Here&#8217;s some instructions on how you install LAMP and Wordpress on your VPS and enabling SSL for your site. And, of course, many problems I&#8217;ve faced and the solutions.<\/p>\n<p>I&#8217;m using Digital Ocean ubuntu-s-1vcpu-1gb host, and the path and configuration may vary. I would suggest using root user since many of the following commands require sudo permission.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Install_LAMP\"><\/span>Install LAMP<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Update apt and then install Apache.<\/p>\n<pre><code class=\"language-bash\">apt-get update\napt-get install apache2\n<\/code><\/pre>\n<p>The Apache configuration file is located at \/etc\/apache2. And now we can modify the configuration of our site.<\/p>\n<pre><code class=\"language-bash\">nano \/etc\/apache2\/sites-available\/000-default.conf\n<\/code><\/pre>\n<ul>\n<li>Set ServerName to your hostname or ip address.<\/li>\n<li>Set ServerAdmin to your email address.<\/li>\n<\/ul>\n<pre><code class=\"language-apache\">&lt;VirtualHost *:80&gt;\n    ServerName yourhostname\n    ServerAdmin youremailaddress\n    DocumentRoot \/var\/www\/html\n    &lt;Directory \/var\/www\/html\/&gt;\n        AllowOverride All\n    &lt;\/Directory&gt;\n<\/code><\/pre>\n<p>Before restart apache you may check the syntax of your configuration file.<\/p>\n<pre><code class=\"language-bash\">apache2ctl configtest\n<\/code><\/pre>\n<p>If nothing wrong you should see\n<code>Syntax OK<\/code>.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Trouble_shooting\"><\/span>Trouble shooting<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<details>\nYou might see the following message.\n\n<pre><code class=\"language-console\">AH00558: apache2: Could not reliably determine the server&#039;s fully qualified domain name, using 127.0.1.1. Set the &#039;ServerName&#039; directive globally to suppress this message\nSyntax OK\n<\/code><\/pre>\n\nIt&#8217;s OK if you just ignore this but in case you&#8217;re an OCD like me, you can run the following command.\n\n<pre><code class=\"language-bash\">echo &quot;ServerName localhost&quot; | sudo tee \/etc\/apache2\/conf-available\/fqdn.conf\nsudo a2enconf fqdn\n<\/code><\/pre>\n\nHere DON&#8217;T replace ServerName with your server name.\n<\/details>\n<p>Start rewrite and proxy_fcgi module and restart apache.<\/p>\n<pre><code class=\"language-bash\">a2enmod rewrite proxy_fcgi\nservice apache2 restart\n<\/code><\/pre>\n<p>Add access permission to www-data user.<\/p>\n<pre><code class=\"language-bash\">chown -R www-data \/var\/www\/html\n<\/code><\/pre>\n<p><strong>\/var\/www\/html<\/strong> is where you gonna put you website files in.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Install_MySQL\"><\/span>Install MySQL<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>We use mariadb, an open-source fork of MySQL.<\/p>\n<pre><code class=\"language-bash\">apt-get install mariadb-server\n<\/code><\/pre>\n<p>Log in with MySQL root user.<\/p>\n<pre><code class=\"language-bash\">sudo mysql -u root -p\n<\/code><\/pre>\n<p>By default, there&#8217;s no password for MySQL root user and you definitely wanna change it.<\/p>\n<pre><code class=\"language-sql\">ALTER USER &#039;root&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;yourpasswd&#039;;\n<\/code><\/pre>\n<p>Don&#8217;t forget the &#8220;;&#8221; at the end of every SQL command.<\/p>\n<p>Exit MySQl.<\/p>\n<pre><code class=\"language-sql\">EXIT;\n<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Install_PHP\"><\/span>Install PHP<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Install php and needed packages.<\/p>\n<pre><code class=\"language-bash\">apt install php-fpm php-mysql php-gd php-curl php-mbstring php-xml php-xmlrpc php-zip\n<\/code><\/pre>\n<p>Editing the dir.conf.<\/p>\n<pre><code class=\"language-bash\">nano \/etc\/apache2\/mods-enabled\/dir.conf\n<\/code><\/pre>\n<p>Move &#8220;index.php&#8221; to the front so Apache will search for index.php first instead of inex.html.<\/p>\n<pre><code class=\"language-php\">&lt;IfModule mod_dir.c&gt;\n    DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm\n&lt;\/IfModule&gt;\n<\/code><\/pre>\n<p>Now we can restart Apache.<\/p>\n<pre><code class=\"language-bash\">service apache2 restart\n<\/code><\/pre>\n<p>The next post is about <a href=\"https:\/\/scythk.com\/index.php\/2019\/04\/19\/install-wordpress-on-lamp\/\">WordPress installation<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>After a whole day working on my site, I finally got it runs. Here&#8217;s some instructions on how you install LAMP and Wordpress on your VPS and enabling SSL for your site. And, of course, many problems I&#8217;ve faced and the solutions. I&#8217;m using Digital Ocean ubuntu-s-1vcpu-1gb host, and the path and configuration may vary. [&hellip;]<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[5],"tags":[11,9,7,10,12,8],"class_list":["post-5","post","type-post","status-publish","format-standard","hentry","category-linux","tag-apache","tag-lamp","tag-linux","tag-mysql","tag-php","tag-ubuntu"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/paTSGz-5","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/scythk.com\/index.php\/wp-json\/wp\/v2\/posts\/5","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/scythk.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/scythk.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/scythk.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/scythk.com\/index.php\/wp-json\/wp\/v2\/comments?post=5"}],"version-history":[{"count":15,"href":"https:\/\/scythk.com\/index.php\/wp-json\/wp\/v2\/posts\/5\/revisions"}],"predecessor-version":[{"id":30,"href":"https:\/\/scythk.com\/index.php\/wp-json\/wp\/v2\/posts\/5\/revisions\/30"}],"wp:attachment":[{"href":"https:\/\/scythk.com\/index.php\/wp-json\/wp\/v2\/media?parent=5"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/scythk.com\/index.php\/wp-json\/wp\/v2\/categories?post=5"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/scythk.com\/index.php\/wp-json\/wp\/v2\/tags?post=5"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}