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
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
Let’s get the prerequisites taken care of before installing Laravel
sudo apt-get install php5-curl
sudo apt-get install php5-mcrypt
# Enable extension
sudo php5enmod mcrypt
# Restart Apache
sudo service apache2 reload
# enable rewrite
sudo a2enmod rewrite
# restart apache
sudo service apache restart
Install Laravel via Composer
Install Composer First
curl -sS https://getcomposer.org/installer | sudo php
Installer Composer Globally
sudo mv composer.phar /usr/local/bin/composer
# your-project is your destination folder
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.
Options Indexes FollowSymLinks MultiViews
allow from all
# 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.
If you want to know what version of Apache you’re running, do this command:
If you have multiple domains installed in a virtual host configuration with one IP address in Apache, the IP address may not resolve to the domain you prefer. Let me explain.
For example, you have the following domains running on an Ubuntu Server with one IP address.
All the domains are resolving as expected on the browser.
However, if you type the IP address on the browser, it only defaults to the first domain found in the /etc/apache2/sites-available directory, which is most likely abc.com.
If you want the IP address to default to another domain, such as klm.com for example, you will need to edit the /etc/apache2/httpd.conf file and add the following entries.
Those are the only entries you’ll need. Typing the IP address on the browser will now default to the contents of klm.com. All the other domains are still accessible via domain names on the browser.
Simple Invoices is a free, open source, web based invoicing system that you can install on your server, desktop, or at a service provider. I installed Simple Invoices on a webhost company I rather not mention. The application was working fine, until they tweak their PHP settings several months back. As a result, the PDF export in Simple Invoices no longer worked. I was bummed. So, I was forced to run Simple Invoices from my home server, which was fun, but the issue was, I can’t access it outside of the house.
So, I decided to install Simple Invoices on my new account at Linode. Now, the funny thing was, the application won’t even come up. Not even a login page. So, I searched online for a possible solution to my dilemma. Some suggested to increase the php memory settings to 128M, but that didn’t work out for me. At one time, I thought I had a missing pdo_mysql module, but that wasn’t the case. Then, I stumbled into something that led me to the ultimate discovery.
Simple Invoices has this configuration file called config.ini located inside the config folder. One thing this application doesn’t like are extra characters inside the config file. I happen to like funky passwords with interesting characters like +-)!@#. My MySQL password happens to have a close parenthesis in it. Essentially, this extra character caused the entire application to not start. So, I change my password, and sure enough, the application worked.
So, if you ever get a 500 internal server error with the Simple Invoices application, make sure you don’t have any of those extra characters inside your config.ini file. I wasted two hours trying to fix this issue, only to be surprised by such an idiotic requirement. That means I can’t use difficult passwords for this application. I think this is either a design issue or a funny requirement of the Zend Framework, which by the way, Simple Invoices is written on. It was somewhat funny, but I wasn’t amused.
I was wondering about the best way to implement and give permissions to webroot, also known as the root directory of your web server. I’m familiar with Ubuntu’s structure, so I’ll use Ubuntu’s default webroot directory, which is /var/www.
Based on numerous documents and discussions I’ve read online, the proper way to give permissions to webroot is to (1 ) add a user to the www-data group, (2) change webroot’s ownership to www-data, (3) give all members of www-data group read and right access.
ulysses = user
webroot = /var/www
www-data = user and group for Apache
Here are the commands to run from the Terminal.
Add new user to the www-data group.
sudo adduser ulysses www-data
Add existing user to the www-data group.
sudo usermod -a -G www-data ulysses
Make www-data the group owner of /www/data
sudo chown -R ulysses:www-data /var/www
Give members of www-data permissions.
sudo chmod -R g+rw /var/www
That’s it. Pretty straightforward.
Are you looking for ways to increase the speed of your website? Apache has a new module called mod_spdy which is a new networking protocol spawned by Google. Howtoforge has the install tutorial. It requires that you have access to your own web server, like a VPS or a home server.
SPDY (pronounced “SPeeDY”) is a new networking protocol whose goal is to speed up the web. It is Google’s alternative to the HTTP protocol and a candidate for HTTP/2.0. SPDY augments HTTP with several speed-related features such as stream multiplexing and header compression.
To use SPDY, you need a web server and a browser (like Google Chrome and upcoming versions of Firefox) that both support SPDY. mod_spdy is an open-source Apache module that adds support for the SPDY protocol to the Apache HTTPD server. This tutorial explains how to use mod_spdy with Apache2 on Ubuntu 12.04.
The instructions looks fairly easy.
More proof? Here’s a video showcasing mod_spdy.
The mount command in Linux is used to attach a file system to a certain device. One of the least used features within mount is called bind. With bind, you can mount a certain directory to another directory within the file system. The result is, the files are accessible from both directories. This feature is particularly helpful when sharing files. I use it to map the home directory of a FTP user to the home directory of the web server. In this particular example, I’m using a FTP user called ‘ftpuser’ and mapping the drive to ‘/var/www,’ which is Apache’s home directory.
Mount Bind Command
mount --bind /var/www /home/ftpuser
Make It Permanent
To make this mount permanent, you need to add it to /etc/fstab.
/var/www /home/ftpuser bind defaults,bind 0 0
I recently installed Ubuntu and the Apache web server on another desktop computer. If you like to know how to install Apache, please read my previous post about installing LAMP. In this instance, installing Ubuntu and Apache was a success. There is one minor issue however. Every time I restart the Apache web server, I would get this annoying message: “Could not reliably determine the server’s fully qualified domain name.” The error is more of a warning. It does not really affect the way Apache display web pages. It’s more of annoyance more than anything.
So, how do you get rid of this minor Apache error?
First things first, one of the things I would like to do when I install a new instance of Ubuntu is to assign the desktop’s hostname to “localhost.” In this case, I don’t have to worry about the hostname resolving to itself, since localhost is already bound to 127.0.0.1. You can change your hostname to localhost by typing this command on the Terminal:
You don’t have to do this if you prefer another hostname.
Now, to fixing the minor nuisance.
Edit the Apache config: /etc/apache2/apache2.conf.
You will need to edit the Apache configuration and add your hostname as ServerName. You can edit the file via the Terminal and using either vi or Gedit. I prefer to work vi for minor changes. Gedit is probably easier for most.
sudo vi /etc/apache2/apache2.conf
sudo gedit /etc/apache2/apache2.conf
If you haven’t done anything previously to the Apache configuration, it will probably be an empty file. In my case, it was. Just add the following:
If you are going to use a different hostname, you will need to add the fully qualified domain name or FQDN in this format.
After saving your changes, you will need to restart Apache to see if that minor annoyance is gone.
To restart Apache, type:
sudo /etc/init.d/apache2 restart
There is no such thing as a perfect server, but this particular one is as close as you can get to being perfect. This tutorial will walk you through how to install the Ubuntu 10.04 LTS Server with all the services available typically that you get from ISPs and hosters.
It contains the installation of Apache web server (SSL-capable), Postfix mail server with SMTP-AUTH and TLS, BIND DNS server, Proftpd FTP server, MySQL server, Courier POP3/IMAP, Quota, Firewall, etc. It also installs the free web hosting control panel called ISPConfig2. Here’s the link to the tutorial.
You’ve installed CodeIgniter and you’ve written a couple of applications. Now, you want to run two of your applications under one install of CodeIgniter. The following article discusses how to run several applications within a single install of CodeIgniter. The approach is accomplished using Apache’s Virtual Host.
Install Apache Virtual Host
1. To add a virtual host, edit /etc/apache2/sites-available/default. We will use “vhostname” as the virtual hostname in this example. Edit the default file and add the following:
2. Run the a2ensite script which enables your virtualhost within the apache2 configuration. It creates symlinks within /etc/apache2/sites-enabled.
# sudo a2ensite vhostname
3. Restart Apache
# sudo /etc/init.d/apache2 restart
4. Check your virtualhost if it’s working by pointing your browser to http://vhostname.
One way of setting up CodeIgniter to support multiple applications, is to have separate folders for each application. You can set up your CodeIgniter directories like the following:
1. Under the “app1/config” directory, edit the config.php file. Point your application to be hosted at vhostname by changing the following line:
$config['base_url'] = "http://vhostname/";
2. Copy the “index.php” file under the main CodeIgniter directory to the http://vhostname web root directory.
3. The “.htaccess” file recommended by CodeIgniter also needs to placed to the web root of http://vhostname.
4. Open your browser and check if your application is working by placing http://vhostname in the address bar of the browser.
5. Repeat steps 1-4 to add additional virtual hosts. That’s it.
If you have questions or suggestions, please leave a comment.