Setup Apache 2 & PHP 5.6 environment on Ubuntu 16.04

Install Apache

https://help.ubuntu.com/lts/serverguide/httpd.html

sudo apt install apache2

Check computer name

hostname

Returned ‘userver’. I’ll use it in apache configuration for setting sub-domains.

Setup enabled sites. I.e directories and its host names. I’ll setup localhost, local ip address and subdomain main.userver to point to same directory of my main project. I’ll keep the apache default page for reference on address apache.userver


cd /etc/apache2/sites-available/

apache.userver

sudo mv 000-default.conf 000-apache.userver.conf
sudo vim 000-apache.conf

Add ServerName apache.userver

	ServerName apache.userver
	ServerAdmin webmaster@localhost
	DocumentRoot /var/www/html
	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined

default

For any address like IP in LAN etc.

sudo vim 001-default.conf

        DocumentRoot /home/oleg/projects/webapp/public
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        
                Options Indexes FollowSymLinks
                AllowOverride All
                Require all granted
        

localhost

sudo vim 002-localhost.conf

enter:

        ServerName localhost
        DocumentRoot /home/oleg/projects/webapp/public
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        
                Options Indexes FollowSymLinks
                AllowOverride All
                Require all granted
        

main.userver

sudo vim 003-main.userver.conf

        ServerName main.userver
        DocumentRoot /home/oleg/projects/webapp/public
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        
                Options Indexes FollowSymLinks
                AllowOverride All
                Require all granted
        

Now, let’s disable the original apache and enable the new sites.

sudo a2dissite 000-default.conf
sudo a2ensite 000-apache.userver.conf
sudo a2ensite 001-default.conf
sudo a2ensite 002-localhost.conf
sudo a2ensite 003-main.userver.conf
sudo service apache2 restart

Add the sub-domains to hosts file.

sudo vim /etc/hosts

Add:

127.0.0.1 apache.userver
127.0.0.1 main.userver

Apache enable mod rewrite

sudo a2enmod rewrite
sudo service apache2 restart

Install PHP 5.6

Installing PHP 5.6 (http://askubuntu.com/questions/756181/installing-php-5-6-on-xenial-16-04)

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
apt search --names-only ^php5.6-
sudo apt-get install php5.6 php5.6-xml php5.6-mysql php5.6-curl php5.6-mbstring
sudo service apache2 restart

If www is inside your user directory, you will need to add apache’s www-data user to your group. This way apache will be able to write to log directories without setting it to 777 chmod. A restart may be needed. *I’m not sure that it works lately, but I’ll keep it and will check it later maybe…

sudo usermod -a -G oleg www-data

Check error log if you have errors:

tail -f /var/log/apache2/error.log

Install CURL

If not installed yet..

sudo apt install curl

Install wkhtmltopdf 0.12.2.1

Unfortunately the latest version doesn’t work in my project so I’m using 0.12.2.1

wget http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-trusty-amd64.deb
sudo dpkg -i wkhtmltox-0.12.2.1_linux-trusty-amd64.deb
sudo apt-get install -f

After installation it should be located at /usr/local/bin/wkhtmltopdf

Install PHPStorm

Download from https://www.jetbrains.com/phpstorm/download/#section=linux

mv PhpStorm-2017.2.tar.gz ~/Soft/

cd ~/Soft/

tar -xf PhpStorm-2017.2.tar.gz

cd PhpStorm-172.3317.83/bin/

./phpstorm.sh

Configure PhpStorm debugger

Install xdebug

sudo apt-get install php-xdebug

PhpStorm settings

https://confluence.jetbrains.com/display/PhpStorm/Zero-configuration+Web+Application+Debugging+with+Xdebug+and+PhpStorm

In /etc/php/5.6/apache2/php.ini set:

xdebug.remote_enable=1
xdebug.idekey=PHPSTORM

To start XDebug add XDEBUG_SESSION_START=PHPSTORM as GET parameter, by cookie or chrome extension https://xdebug.org/docs/remote

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s