Say that you have multiple log files for Nginx, Apache or any other software that you would like to tail. You can do this easily with
tail like so:
tail -f /var/log/nginx/*.log
tail -f /var/log/apache2/*.log
You need to have a fairly recent version of
tail to use this. It works on Ubuntu 16.04 with
tail version 8.25.
Here is an example of an Apache VirtualHost config that provides your site with security through open_basedir and writes both a regular access log, as well as a PHP error log.
php_admin_value open_basedir /var/www/html/example.com
CustomLog /var/log/httpd/example.com-access.log common
In order for open_basedir to work with file uploads, you need to add the following to your php.ini configuration file:
upload_tmp_dir = /tmp
I’m always looking to improve this configuration – send me a comment if you have a better version!
Start out with the basics – Apache, MySQL and PHP + extensions
apt-get install mysql-server mysql-client apache2 php5 php5-cli libapache2-mod-php5 php5-mysql php5-curl php5-gd php-pear php5-imagick php5-mcrypt php5-memcache php5-mhash php5-sqlite php5-xmlrpc php5-xsl php5-json php5-dev libpcre3-dev
I recommend using this on Debian Jessie. That way you get a bleeding edge version of PHP (5.5.8 as of right now)
OpCode cache and APCu (Optional)
pecl install ZendOpcache-beta
pecl install apcu-beta
Add the following to /etc/php5/apache2/php.ini
Configure Opcache by adding this to /etc/php5/apache2/php.ini
Restart apache. The extensions should be available and configured. (You can verify this via phpinfo(); )
Useful tools (Optional)
apt-get install htop vim
Here is a quick VirtualHost generator I made! It should provide you with a good VirtualHost + PHP setup, which includes:
- open_basedir folder restriction
- Separated access and error logs
- www and non-www aliases for domains
It is possible to separate paths with a colon when setting open_basedir folders.
This is useful to give access to the /tmp folder, which many CMS and frameworks use per default to store temporary files such as uploads.
php_admin_value open_basedir /var/www/html/example.com/:/tmp/
cat access.log | grep "my_file.php" | wc -l
This command is fairly generic and will return the amount of rows in a file after applying the grep search string.
And grep does regular expressions too!
Restarts Apache without breaking open connections.
apachectl -k graceful
Note: Some configuration changes require a full restart, rather than a graceful one.
httpd -V | grep "Server MPM:"
Ubuntu / Debian
apache2 -V | grep "Server MPM:"
Server MPM: Prefork
This is useful for knowing whether to tweak prefork or worker MPM in the apache config.
Ubuntu / Debian
Compiled in modules: