Skip to content

Instantly share code, notes, and snippets.

@yashhere
Last active January 12, 2018 12:12
Show Gist options
  • Save yashhere/35229aadee946ee66faa76d96cc2f858 to your computer and use it in GitHub Desktop.
Save yashhere/35229aadee946ee66faa76d96cc2f858 to your computer and use it in GitHub Desktop.
## Installing LAMP Stack
```
sudo apt update
sudo apt install apache2 mysql-server php libapache2-mod-php php-mcrypt php-mysql phpmyadmin php-mbstring php-gettext
sudo a2enmod rewrite
sudo systemctl restart apache2
```
Now you can access apache server at http://localhost.
```
mysql_secure_installation
```
will setup secure mysql configuration. Use your common sense/Internet to identify which settings suits you configuration.
## To make /var/www folder writable by your user
```
sudo usermod -a -G www-data ${USER}
sudo chown -R www-data:www-data /var/www
sudo chmod -R g+rwx /var/www
newgrp www-data
```
Now you have permissions to edit content inside the /var/www folder with root access.
To test php, create a new file in the /var/www/html folder. Name it info.php
Open the file, add the following content and save it.
```
<?php
phpinfo();
?>
```
Now go to http://localhost/info.php, and see if you get a blue colored page. If yes, then php is working fine.
Now download the database that I sent to Faris. Go to http://localhost/phpmyadmin and enter your credentials. Remember you added your credentials when installing mysql and phpmyadmin.
Now make a new database. Name it "fossmeet". In the "create table" page, click on import tab, and import your database. You don't have to extract your database, just import the gz archive.
Now we need to setup some tools for proper setup of the website. The tools are composer, bower, npm
## Install NPM
```
sudo apt-get install build-essential libssl-dev
curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
sudo apt-get install -y nodejs
#check the version of npm
node -v
npm -v
It should show the version that you installed.
Pro Tip: You should not install global npm packages as root. So we will change that behaviour.
```
# to get the location where packages are currently installed, usually /usr/local
npm config get prefix
mkdir ~/.npm-packages
npm config set prefix ~/.npm-packages
echo "# npm installation without sudo" >> ~/.bashrc
echo 'NPM_PACKAGES="${HOME}/.npm-packages"' >> ~/.bashrc
source ~/.bashrc
echo 'PATH="$NPM_PACKAGES/bin:$PATH"' >> ~/.bashrc
## Installing Composer
```
sudo apt-get install curl php-cli php-mbstring git unzip
cd /tmp
curl -sS https://getcomposer.org/installer -o composer-setup.php
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
cd
sudo chown -R ${USER}:${USER} ~/.composer
```
## Installing Ruby
```
sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
cd /tmp
curl -sSL https://get.rvm.io -o rvm.sh
cat /tmp/rvm.sh | bash -s stable --rails
source ~/.rvm/scripts/rvm
rvm install ruby --default
ruby -v
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*' >> ~/.bashrc
echo '# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.' >> ~/.bashrc
echo 'export PATH="$PATH:$HOME/.rvm/bin"' >> ~/.bashrc
gem install sass
which sass # it should be something like /home/yash/.rvm/gems/ruby-2.4.1/bin/sass
```
Now clone the two repository. I have given you the access to those repositories to five(may be four) persons. Others might not be able to clone it withour permissions.
```
sudo apt install git git-core
git config --global user.name "your name"
git config --global user.email "your email id" # please give your gitlab email id
cd /var/www/html
git clone https://gitlab.com/fosscell/2018
git clone https://gitlab.com/fosscell/2018-BE
# this step should not be necessary to perform
sudo chown -R www-data:www-data 2018-BE
cd 2018-BE/
npm install
npm install -g gulp grunt bower
cd public/
bower install
cd ..
composer update -vvv
composer install -vvv
cp .env.example .env
php artisan key:generate
```
## Now open .env file and edit the parameters there. Change DB_USERNAME and DB_PASSWORD and DB_NAME to your mysql username and password.
```
php artisan migrate:rollback
php artisan migrate
```
Now open .env file and edit the parameters there. Change DB_USERNAME and DB_PASSWORD to your mysql username and password.
Now from the root of the folder, run
```
grunt server
```
Now open a new terminal window.
You need to create a apache virtual host configuration file also for the site to work.
```
echo "127.0.0.1 fossmeet.com" >> /etc/hosts
sudo touch /etc/apache2/sites-available/fossmeet.conf
sudo gedit /etc/apache2/sites-available/fossmeet.conf
```
Now paste the following code (Without backticks)
```
<VirtualHost *:80>
ServerAdmin root@localhost
ServerName fossmeet.com
DocumentRoot /var/www/html/2017-BE/public
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory "/var/www/html/2017-BE/public/">
DirectoryIndex index.php
Options Indexes FollowSymLinks Includes ExecCGI
AcceptPathInfo on
AllowOverride All
#Options None
Require all granted
</Directory>
</VirtualHost>
```
After that, run
```
sudo a2ensite fossmeet.conf
sudo systemctl restart apache2
```
and go to http://localhost/2018-BE to access the site.
There are certain issues which I am not able to solve till now. But that should not affect your work. I'll post the remaining part later.
https://gist.github.com/yashhere/19f66f65482168be2be7e4f94c264628
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment