Skip to content

Instantly share code, notes, and snippets.

@kevyworks
Last active August 8, 2016 22:55
Show Gist options
  • Save kevyworks/b60c581a5a70e10474d9f7ba77b5e7de to your computer and use it in GitHub Desktop.
Save kevyworks/b60c581a5a70e10474d9f7ba77b5e7de to your computer and use it in GitHub Desktop.

Guide installing LAMP & php7.0 (BashOnWindows)

I will assume that you have already installed BashOnWindows. Note: Some AntiVirus prohibits successfull installation, like Avast. Uninstall Avast.

Installing LAMP-SERVER

  • Run bash.exe in Administrator Mode
  • # apt-get install lamp-server^

If you have an error like APR_TCP_DEFER_ACCEP. add this AcceptFilter http none end of /etc/apache2/apache2.conf

REF: https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-14-04 REF: http://stackoverflow.com/questions/36469527/installing-apache-on-windows-subsystem-for-linux

Setup MySQL

First, we need to tell MySQL to create its database directory structure where it will store its information. You can do this by typing:

  • # mysql_install_db

Secure? (optional; we're at development right?)

  • # mysql_secure_installation

Test if "It Work's"

  • nano /var/www/html/info.php and type in <?php phpinfo(); and save it.

Open your browser and visit http://localhost/info.php

Upgrading to Php7

  • # apt-get install python-software-properties
  • # add-apt-repository ppa:ondrej/php
  • # apt-get update
  • # apt-get install -y php7.0

to find available php 7 modules apt-cache search php7-* for this guide, I will install these modules:

# apt-get install libapache2-mod-php7.0 php7.0-mysql php7.0-curl php7.0-json php7.0-mcrypt php7.0-gd php7.0-mbstring php7.0-zip php7.0-common php7.0-xml

Switch to PHP7

  • # a2dismod php5
  • # a2enmod php7.0
  • # service apache2 restart

About apr_sockaddr_info_get() failed

  • # hostname <type-your-computer-name>
  • # nano /etc/apache2/apache2.conf and add ServerName <type-your-computer-name>

About Cant resolve <Hostname>

  • # nano /etc/hosts add 127.0.0.1 <Hostname>

About /com/ubuntu/upstart fix (Copy-Paste)

Note: Check before continuing.

cat > /usr/sbin/policy-rc.d <<EOF
#!/bin/sh
exit 101
EOF
chmod +x /usr/sbin/policy-rc.d
dpkg-divert --local --rename --add /sbin/initctl
ln -s /bin/true /sbin/initctl

The userdir

  • # a2enmod userdir
  • # mkdir ~/public_html

Note: Do first at PowerShell/Command lxrun /setdefaultuser <username> Visit: http://localhost/~<username>

Enable PHP in userdir by checking out # /etc/apache2/mods-available/php7.0.conf

You can now use this for virtual hosts like ~/public_html/mysite.local

Install NodeJS

  • Install nodejs # apt-get install nodejs npm OR
  • PPA: # curl -sL https://deb.nodesource.com/setup_6.x | bash - this includes npm already. for LTS use setup_4.x
  • # apt-get install nodejs

REF: https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-an-ubuntu-14-04-server

Install Composer

  • # curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

REF: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-composer-on-ubuntu-14-04

Install Git

  • # apt-get install git

Install defaultuser (Ref above)

  • PS C:\> LxRun /setdefaultuser <desired-username>

Virtual Hosts & for WINDOWS

  • just add the server name of the virtual host you created at Bash Environment to C:\Windows\System32\drivers\etc\hosts file. 127.0.0.1 <server name>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment