Useful Snippets

Welcome!


This blog is used to collect useful snippets related to Linux, PHP, MySQL and more. Feel free to post comments with improvements or questions!

Are your smart devices spying on you? Make better purchasing choices and find products that respect your privacy at Unwanted.cloud

RSS Latest posts from my personal blog


Subscribe to RSS feed


Best Apache VirtualHost configuration for PHP projects

Stanislav KhromovStanislav Khromov

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.

<VirtualHost *:80>
ServerName      example.com
ServerAlias     www.example.com

DocumentRoot    /var/www/html/example.com

php_admin_value open_basedir /var/www/html/example.com

CustomLog       /var/log/httpd/example.com-access.log common
ErrorLog        /var/log/httpd/example.com-error.log
</VirtualHost>

Note
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!

Full-stack impostor syndrome sufferer & Software Engineer at Schibsted Media Group

Comments 1