Thursday, March 7, 2013

How to install laravel, apache, php and mysql on CentOS

While Laravel is pretty easy to install, I figure it couldn’t hurt to have a step-by-step guide that you could copy and paste into a new CentOS6 server.  (This should work on CentOS5+ and Red Hat as well)
This how-to is available as a Google Doc as well.

# Install epel and ius repositories 
rpm -ivh ius-release-1.0-10.ius.el6.noarch.rpm;
rpm -ivh epel-release-6-5.noarch.rpm;
yum clean all; yum update; yum upgrade;  

# Install apache, php, mysql, git and a few other goodies  
yum install -y httpd php54 php54-cli php54-common php54-gd php54-ldap php54-mbstring php54-mcrypt php54-mysql php54-odbc php54-pdo php54-pear php54-pecl-geoip php54-pecl-mongo php54-pecl-memcache php54-pgsql php54-soap php54-xml php54-xmlrpc mysql mysql-server screen git bind-utils;
service httpd restart; 

# Replace vi with vim (optional)  
mv /bin/vi /bin/vi.bak; 
ln -s /usr/bin/vim /bin/vi;
echo "export EDITOR=/usr/bin/vim" >> ~/.bashrc;
source ~/.bashrc; 

# Install Composer  
curl -k -sS | php;
sudo mv composer.phar /usr/local/bin/composer; 

# Grab Laravel and get it set up  
#unzip develop; 
#mv laravel-develop /var/www/; 
#rm -f develop;
git clone git:// -o laravel -b develop /var/www/
cd /var/www/;
composer install;
chmod -R 2777 /var/www/; 

# Set up virtual host in apache  
printf "<VirtualHost *:80>\n\tServerName\n\tServerAlias\n\tDocumentRoot /var/www/\n\tCustomLog /var/log/httpd/ combined\n\n\t<Directory \"/var/www/\">\n\t\tAllowOverride All\n\t</Directory>\n</VirtualHost>" >> /etc/httpd/conf.d/;
service httpd graceful;
That should about do it.  After you’ve set up your dns to point to your server’s ip address, simply visit your site in a browser and you should get the “Hello World!” Laravel start page. 


PHP Development Company said...

Thanks for guiding installation about php and mysql.

Varadharaj V said...

thanks for sharing your ideas with laravel installation. here is another way to install laravel on your machine.