#Introduction If you're a PHP developer on Ubuntu 13.10, there comes the time where you have to install/reinstall your system. I did it already a few times and i decided to write down the steps for a typical web developer stack with PHP. This is for a developer machine and not for a live environment!
I hope it helps you too!
#Installation stack
- LAMP Environment
- PHP QA Environment
- GitHub support
- General Environment
- Zend Framework
- IDE
#Installation LAMP Environment ##Apache2
sudo apt-get install apache2
sudo apt-get install libapache2-mod-php5
sudo a2enmod rewritesudo apt-get install php5-cli php5-common php5 php5-devsudo apt-get install mysql-server#Installation PHP QA Environment
#install newest version of phpunit
sudo pear channel-discover pear.phpunit.de
sudo pear update-channels
sudo pear upgrade-all
sudo pear config-set auto_discover 1
sudo pear install --alldeps pear.phpunit.de/PHPUnit
sudo pear install --force --alldeps pear.phpunit.de/PHPUnit#phpunit extensions
sudo pear install pear.phpunit.de/PHPUnit_SkeletonGenerator
sudo pear install pear.phpunit.de/DbUnit
sudo pear install --force phpunit/PHPUnit_MockObjectsudo apt-get install php5-xdebug*edit /etc/php5/mods-available/xdebug.ini
zend_extension=/usr/lib/php5/20121212/xdebug.so
xdebug.remote_enable=on
xdebug.remote_host=localhost
xdebug.remote_handler=dbgp
xdebug.remote_port=9000
xdebug.idekey="netbeans-xdebug"#Configuration
- Change this settings in /etc/php5/cli/php.ini for for all webservers
- Change this settings in /etc/php5/apache2/php.ini if you have installed apache2
memory_limit = 512m
display_errors = On
html_errors = On
post_max_size = 32m
upload_max_filesize = 32m
default_charset = utf8- Edit /etc/php5/cli/conf.d/xdebug.ini
xdebug.max_nesting_level = 1000#Debugging with XDebug on Browser
The example is made for NetBeans IDE with Apache2 WebServer. But other IDE's or webservers should work in a similar way. ##Configuration
#Edit /etc/php5/cli/conf.d/xdebug.ini
xdebug.remote_enable=On
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.profiler_append=Off
xdebug.profiler_enable=Off
xdebug.profiler_enable_trigger=Off
xdebug.profiler_output_dir="/tmp/kcachegrind"
sudo service apache2 restart
<a name="apache2-config-example"></a>
#Apache2 config example (with Zend Framework framework)
Assume you want to have your project in `/home/username/localhost`
```shell
# Change user/group of Apache2
# edit /etc/apache2/apache2.conf
User <username>
Group <usergroup>
#Add entry to /etc/hosts
127.0.0.1 www.my_webside.lo
#Create file
/etc/apache2/sites-available/www.my_webside.lo
#edit file (with example config)
#create symbolic link to enable a site
#restart apache
sudo /etc/init.d/apache2 restart
#Nginx config example (with Symfony2 framework)
Assume you want to have your project in /home/username/my_webside
# Change user of Nginx
# edit /etc/nginx/nginx.conf
User <username>
# Change user of php5-fpm
# edit /etc/php5/fpm/pool.d/www.conf
user = <username>
group = <group of user>
#Add entry to /etc/hosts
127.0.0.1 www.my_webside.lo
#Create file
/etc/nginx/sites-available/www.my_webside.lo
#edit file (with example config)
#www.my_webside.lo
server {
listen 80;
server_name www.my_webside.lo;
access_log /var/log/nginx/www.my_webside.lo.log;
location / {
root /home/username/my_webside/web;
index index.html index.htm index.php app_dev.php;
if ($request_filename !~ "\.(js|htc|ico|gif|jpg|png|css)$") {
rewrite ^(.*) /app.php$1 last;
}
}
location ~ \.php($|/) {
set $script $uri;
set $path_info "";
if ($uri ~ "^(.+\.php)(/.+)") {
set $script $1;
set $path_info $2;
}
fastcgi_pass 127.0.0.1:9009;
include fastcgi_params;
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
fastcgi_param SCRIPT_FILENAME /home/username/my_webside/web$script;
fastcgi_param PATH_INFO $path_info;
}
}
#create symbolic link to enable a site
sudo ln -s /etc/nginx/sites-available/www.my_webside.lo /etc/nginx/sites-enabled/www.my_webside.lo
#restart nginx
sudo /etc/init.d/nginx restart
sudo /etc/init.d/php5-fpm restart