Setting a LAMP environment on Linux
Yet another tutorial about installing a LAMP on Linux (I'm using Ubuntu). I've found all info I needed online but for it wasn't so easy. All informations are different, for different tools and purposes and you can't find them in single tutorial. Here I'm listing all commands we need to set up a good PHP development enviroment more quickly.
Apache
sudo apt-get install apache2
Just open a browser and type http://localhost. If you will see a web page, all is ok. Now you will need these command to interact with the server Restart the server: sudo /etc/init.d/apache2 restart Start the server: sudo /etc/init.d/apache2 start Stop the server: sudo /etc/init.d/apache2 stop You can add apache utils: sudo apt-get install apache2-utils
Enable mod rewrite
sudo a2enmod rewrite and restart apache with sudo /etc/init.d/apache2 restart or sudo service apache2 restart Now edit the default VirtualHost with
sudo nano /etc/apache2/sites-available/000-default.conf
Search for “DocumentRoot /var/www/html” and add the following lines directly below:
<Directory "/var/www/html"> AllowOverride All</Directory>
Save and exit the nano editor via CTRL-X, “y” and ENTER. Restart the server again: sudo /etc/init.d/apache2 restart
PHP
Install last PHP version:
sudo apt-get install php5 libapache2-mod-php5
Just type php -v and see if all is ok. if you want to edit the php.ini file:
sudo gedit /etc/php5/apache2/php.ini
Probably you will need to enable the CURL extension:
sudo apt-get install php5-curlsudo /etc/init.d/apache2 restart
Composer
Download the phar file and move it to /usr/local/bin to install it globally:
sudo mv composer.phar /usr/local/bin/composer
Type composer to check the installation and remember to use sudo for the update:
sudo composer self-update
PHPUnit
I've downloaded the phar file on and moved it on /usr/local/bin/:
wget https://phar.phpunit.de/phpunit.pharchmod +x phpunit.pharsudo mv phpunit.phar /usr/local/bin/phpunitphpunit --version
Here you can start using PHPUnit very easily. I'm using PHPStorm and if you want the IDE to see PHPUnit for showing autocomplete instructions you must let the IDE see the phar file elsewhere. So download the phar file again and move it in a directory of your choice. Update the PHPStorm settings and add the directory on PHP. File -> Settings -> PHP and add the directory on include path. On PHPUnit tab, let the IDE see the phar file.
MySQL
sudo apt-get install mysql-server
Follow the install procedure.
sudo /etc/init.d/mysql startsudo /etc/init.d/mysql stopsudo /etc/init.d/mysql restart
Client softwares
- MySQL workbench
- Dbeaver, actually I get a JVM error after the installation :(
- Razor SQL
- PhpMyAdmin
- HeidiSQL is excellent. It runs on Windows but it's freeware and portable. You can use Wine to run it on your computer.
IDE
GIT
Git is simply essential. Install it with:
sudo apt-get install git
NodeJS
NodeJS is not a pure PHP tool but today you may need to install it:
sudo apt-get updatesudo apt-get install nodejs
Install npm:
sudo apt-get install npm