Apache+PHP on Cubieboard with Lubuntu

Apache+PHP on Cubieboard with Lubuntu

I executed the following steps to install apache with PHP on my cubieboard2 with lubuntu.

Lets start with installation that will take about 25MB:

sudo apt-get install apache2
sudo apt-get install php5
sudo /etc/init.d/apache2 restart

Put your IP address to the browser (or localhost) and you see that Apache was installed correctly.

Your www content is stored in /var/www.

The whole www folder is owned by root. So for easier access I changed owner to my user named linaro

sudo chown -R linaro /var/www

To test PHP create a new php file in www directory:

 echo "<?php phpinfo(); ?>" > /var/www/info.php

And final test of php in apache from the browser.

We are done.

No you can continue with adding sata hdd drive or settip up media server (or both). You can try to attach some hobby devices via serial (UART) or I2C communication.

Hints

Security

Apache is running under root user that is not so secure. Read the hints how to secure you web server.

If I wanted also MySQL I would go for LAMP that you can install with sudo apt-get install lamp-server.

If you installed only apache+php then to install mySQL later (85MB):

sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql

Follow this ubuntu guide

Logrotate

To rotate log files follow the following sites:

I have changed apache log files to be stored in /tmp/ and I will keep only 1 day history. Mine logrotate config file looks like this:

cat /etc/logrotate.d/apache2
/tmp/*.log /var/log/apache2/*.log {
        daily
        missingok
        rotate 1
        compress
        delaycompress
        notifempty
        create 640 root adm
        sharedscripts
        postrotate
                if /etc/init.d/apache2 status > /dev/null ; then \
                    /etc/init.d/apache2 reload > /dev/null; \
                fi;
        endscript
        prerotate
                if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
                        run-parts /etc/logrotate.d/httpd-prerotate; \
                fi; \
        endscript
}

To check logrotate status: cat /var/lib/logrotate/status
To rum and check logrotate execution: logrotate -d -f /etc/logrotate.conf
-d = Turns on debug mode. In debug mode, no changes will be made to the logs or to the logrotate state file.