Skip to content

Instantly share code, notes, and snippets.

@sibinx7
Last active June 15, 2018 05:13
Show Gist options
  • Save sibinx7/5a72bdf64ac67d392bfdfeb8992cda2e to your computer and use it in GitHub Desktop.
Save sibinx7/5a72bdf64ac67d392bfdfeb8992cda2e to your computer and use it in GitHub Desktop.
Development Setup

LAMP Setup

Install PHP, Apache, MySQL on Linux machine

Apache

sudo apt-get update
sudo apt-get install apache2

MySQL

sudo apt-get install mysql-server mysql-client

Install PHP

sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql
sudo apt-get install php-cli
sudo apt-get install phpmyadmin apache2-utils

TODO : How to create virtual server, install wordpress and other PHP, Laravel

php-common  libapache2-mod-php php-xmlrpc  libapache2-mod-fastcgi

build-essential php-dev libbz2-dev libmysqlclient-dev libxpm-dev libmcrypt-dev libcurl4-gnutls-dev libxml2-dev libjpeg-dev libpng12-dev

Setup Virtual Host

  • Create a folder in home or under var/www or whereever you want.
  • Goto /etc/apache2/sites-available/ folder. Copy 000-default.conf and rename it. For example, website.conf
  • Open and set website path
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot `/var/www/html`
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
  • Enable virtual host sudo a2ensite example.com.conf,
  • Disable virtual host sudo a2dissite example.com.conf(If you want).
  • Try this is moderewrite not working sudo a2enmod rewrite
  • Restart server sudo service apache2 restart

Tips: Enable mode rewrite

    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted

Edit host file

  • Edit sudo nano /etc/hosts
127.0.0.1   example.com

XAMP on Windows, Enable http

  • Goto php.ini file, then search php_openssl and uncomment it
  • Goto httpd.conf file and check LoadModule ssl_module modules/mod_ssl.so enabled or not
  • Then goto https-vhosts.conf
<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "<PATH>"
    # ServerName <SERVER_NAME>
    ErrorLog "logs/dummy-host2.example.com-error.log"
    CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>

<VirtualHost *:443>
    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "<PATH>"
    ServerName <SERVER_NAME>
    SSLEngine on
    SSLCertificateFile "conf/ssl.crt/server.crt"
    SSLCertificateKeyFile "conf/ssl.key/server.key"
    ErrorLog "logs/dummy-host2.example.com-error.log"
    CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>

Composer Installation

Get latest path https://getcomposer.org/download/

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

Change permission for www directory /var/www

sudo chgrp www-data /var/www/* -R 
sudo chmod 775 /var/www/* -R // 777 for all permission
sudo chmod g+s /var/www/* -R 
sudo chown -R <username>:<username> /var/www/* // optional 

Stop Port 80 usage by system

net stop http /y

Fix Git Problem in WWW

sudo adduser $USER www-data
sudo chown root:root /var/www
sudo chown -R $USER:www-data /var/www/*
sudo chmod -R 755 /var/www
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment