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 https://getcomposer.org/installer | php;
sudo mv composer.phar /usr/local/bin/composer; 

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

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


2 comments:

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.

http://kvcodes.com/2014/04/install-laravel-using-laravel-phar-file/