Ulyssesonline

the tech surfer

  • Home
  • About
  • Archives
You are here: Home / 2014 / Archives for July 2014

Archives for July 2014

July 24, 2014

Be careful when using Usermod

When adding an existing user to a group, be careful of using ‘usermod.’ If done incorrectly, you can remove a user from its existing groups. In my case, I used ‘usermod’ to add myself to the www-data group. Since I did it wrong, I lost ‘sudo’ access on the next reboot. I ended up booting up from a rescue CD and restoring /etc/groups. Thankfully, Ubuntu keeps a backup copy called /etc/groups-.

Wrong way:

sudo usermod -G www-data username

sudo usermod -G www-data username

Correct way:

sudo usermod -a -G www-data username

sudo usermod -a -G www-data username

Filed Under: Linux Tagged With: sudo, usermod, www-data

July 24, 2014

Install Laravel 4.2 on Ubuntu Server 14.04 LTS

I was having a little trouble getting Laravel installed on a newly installed Ubuntu 14.04 LTS server. I’ve decided to document the whole process in hopes that I’ll use the documentation to good use once again sometime in the future. Who knows, someone will benefit from reading this. I’m not the only one that will be doing a Laravel installation on Ubuntu.

If you need to install Ubuntu from scratch, I recommend that use install LAMP and SSH because you’ll need those services to support Laravel. PHP, MySQL, Apache and SSH would be installed for you right out of the gate. In addition, I recommend that you install PHPMyAdmin for database administration.

# Install Tasksel
sudo apt-get -y install tasksel
# Install LAMP
sudo tasksel install lamp-server
# Install PHPMyAdmin
sudo apt-get install phpmyadmin

# Install Tasksel sudo apt-get -y install tasksel # Install LAMP sudo tasksel install lamp-server # Install PHPMyAdmin sudo apt-get install phpmyadmin

In Ubuntu, the default document root is /var/www/. Before starting, let’s make sure we got the correct permissions for Apache, and for the user (you). This is to prevent so you don’t run into issues with write permissions on the document root.

Permissions for /var/www/

# Set group to www-data
sudo chgrp www-data /var/www
# Make it writable for the group
sudo chmod 775 /var/www
# Set GID to www-data for all sub-folders
sudo chmod g+s /var/www
# Add your username to www-data group
sudo usermod -a -G www-data username
# Finally change ownership to username
sudo chown username /var/www/
# Your account shouldn't have any more permission issues

# Set group to www-data sudo chgrp www-data /var/www # Make it writable for the group sudo chmod 775 /var/www # Set GID to www-data for all sub-folders sudo chmod g+s /var/www # Add your username to www-data group sudo usermod -a -G www-data username # Finally change ownership to username sudo chown username /var/www/ # Your account shouldn't have any more permission issues

Let’s get the prerequisites taken care of before installing Laravel

Install Curl

sudo apt-get install php5-curl

sudo apt-get install php5-curl

Install Mycrypt

sudo apt-get install php5-mcrypt

sudo apt-get install php5-mcrypt

Activate Mcrypt

# Enable extension
sudo php5enmod mcrypt
# Restart Apache
sudo service apache2 reload

# Enable extension sudo php5enmod mcrypt # Restart Apache sudo service apache2 reload

Enable Mod-Rewrite

# enable rewrite
sudo a2enmod rewrite
# restart apache
sudo service apache restart

# enable rewrite sudo a2enmod rewrite # restart apache sudo service apache restart

Install Laravel via Composer

Install Composer First

cd ~
curl -sS https://getcomposer.org/installer | sudo php

cd ~ curl -sS https://getcomposer.org/installer | sudo php

Installer Composer Globally

sudo mv composer.phar /usr/local/bin/composer

sudo mv composer.phar /usr/local/bin/composer

Install Laravel

# your-project is your destination folder
cd /var/www/
composer create-project laravel/laravel your-project --prefer-dist

# your-project is your destination folder cd /var/www/ composer create-project laravel/laravel your-project --prefer-dist

Set up your Apache virtual host

# Copy default Apache conf
sudo cp /etc/apache2/sites-available/000-default /etc/apache2/sites-available/laravel.conf
# Edit laravel.conf and change DocumentRoot to /var/www/laravel/public
sudo nano /etc/apache2/sites-available/laravel.conf
# Edit laravel.conf add the following and save.
DocumentRoot /var/www/laravel/public
<Directory /var/www/laravel/public>
 Options Indexes FollowSymLinks MultiViews
 AllowOverride All
 Order allow,deny
 allow from all
</Directory>
# Reload Apache
sudo service apache2 reload
# Disable default Apache conf
sudo a2dissite 000-default.conf
# Enable laravel.conf
sudo a2ensite laravel.conf
# Reload Apache
sudo service apache reload

# Copy default Apache conf sudo cp /etc/apache2/sites-available/000-default /etc/apache2/sites-available/laravel.conf # Edit laravel.conf and change DocumentRoot to /var/www/laravel/public sudo nano /etc/apache2/sites-available/laravel.conf # Edit laravel.conf add the following and save. DocumentRoot /var/www/laravel/public <Directory /var/www/laravel/public> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> # Reload Apache sudo service apache2 reload # Disable default Apache conf sudo a2dissite 000-default.conf # Enable laravel.conf sudo a2ensite laravel.conf # Reload Apache sudo service apache reload

The cool thing about this example is, by setting up your /var/www permissions, you don’t need to change permissions to “app/storage” since you already have the correct permission to /var/www.

Finally, access Laravel from the IP address of your Ubuntu Server. The IP address of your Ubuntu server should be a static IP address. You can set this in the network config file called /etc/networking/interfaces.

Have fun!

Filed Under: Linux Tagged With: apache, curl, laravel, mcrypt, ubuntu

July 24, 2014

No longer part of sudoers group

So the only user I have in Ubuntu is no longer part of the sudoers group. How that happen? I have no access to root, and I don’t have admin access. Great. Very weird indeed. A bug?

Filed Under: Linux Tagged With: sudo

  • 1
  • 2
  • 3
  • 4
  • Next Page »

Copyright © 2003 - 2018