Symfony 5.2 and Apache 2.4 Sat, Jan 2. 2021
Certainly the most convenient way to develop a Symfony 5.x app is to use the symfony server. Eventually however, you may have to deploy the application. For a while use of nginx with php-fpm was the flavor of the month, but there are now simple ways of still using php-fpm with apache and achieving comparable performance to nginx.
For example a vhost setting like this one is possible:
<VirtualHost *:80>
SetEnv ENVIRONMENT "dev"
<FilesMatch \.php$>
SetHandler proxy:fcgi://php:9000
# for Unix sockets, Apache 2.4.10 or higher
</FilesMatch>
# Proxy .php requests to port 9000 of the php-fpm container
DocumentRoot /usr/local/apache2/cms/public
ServerName cms.mydev.local
ServerAdmin admin@mydev.local
<Directory /usr/local/apache2/cms/public>
DirectoryIndex index.php index.html
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
# Send apache logs to stdout and stderr
CustomLog /proc/self/fd/1 common
ErrorLog /proc/self/fd/2
</VirtualHost>
For example a vhost setting like this one is possible:
<VirtualHost *:80>
SetEnv ENVIRONMENT "dev"
<FilesMatch \.php$>
SetHandler proxy:fcgi://php:9000
# for Unix sockets, Apache 2.4.10 or higher
</FilesMatch>
# Proxy .php requests to port 9000 of the php-fpm container
DocumentRoot /usr/local/apache2/cms/public
ServerName cms.mydev.local
ServerAdmin admin@mydev.local
<Directory /usr/local/apache2/cms/public>
DirectoryIndex index.php index.html
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
# Send apache logs to stdout and stderr
CustomLog /proc/self/fd/1 common
ErrorLog /proc/self/fd/2
</VirtualHost>
Composer install of Private Bitbucket VCS "aka" 'Invalid OAuth consumer provided' Thu, Apr 5. 2018
So you have a private Bitbucket Repo and you want to utilize it in your project composer.json. You may find that when you run the composer install you get an error pulling your private Bitbucket repo with messages about Oauth failure that may include "Invalid OAuth consumer provided"
Continue reading "Composer install of Private Bitbucket VCS "aka" 'Invalid OAuth consumer provided'" »
Howto serve a markdown document Wed, Aug 2. 2017
Allmark is a simple self contained Markdown html renderer and server from developer Andreas Koch, that is written in Go.
You could certainly install Allmark locally, but there are numerous editors or standalone operating system specific markdown parsers you could use.
But what if you have some markdown documentation on a server, and need a quick and easy way to access that documentation? You can always just look at the raw markdown using vim, but what fun is that?
Allmark is a full markdown server, but installing a server just to read a couple of markdown documents is something very few people would want to do. If however, your server has docker installed, you can be reading your documentation in all its rendered glory in a matter of a few seconds. Here is how:
You could certainly install Allmark locally, but there are numerous editors or standalone operating system specific markdown parsers you could use.
But what if you have some markdown documentation on a server, and need a quick and easy way to access that documentation? You can always just look at the raw markdown using vim, but what fun is that?
Allmark is a full markdown server, but installing a server just to read a couple of markdown documents is something very few people would want to do. If however, your server has docker installed, you can be reading your documentation in all its rendered glory in a matter of a few seconds. Here is how:
Vagrant Share and Ngrok Mon, Jul 17. 2017
As more and more people utilize virtualization for development the need to easily and securely share your work in progress with team members or clients can be a great boost to productivity. Such a tool is also not bad when your kid wants to let his friend access that local minecraft server you are running on your workstation for him, not that I would know anything about that. There are several utilities that are available, and now a plug and play option that is available if you use vagrant.
In recent versions of Vagrant, Hashcorp has added a plugin called Vagrant-share. You can see if its installed by running
And you should see something like this:
In recent versions of Vagrant, Hashcorp has added a plugin called Vagrant-share. You can see if its installed by running
CODE:
vagrant plugin list
And you should see something like this:
CODE:
vagrant-share (1.1.9, system)
Putting Apache on a diet - how to get a lean configuration, Part 1 Sun, Jul 16. 2017
In this article I'm going to go over some of the details of how Apache works, and uses memory. As you will see, the apache processes that serve requests will grow to include the amount of memory they need for a particular request, and they will still be using that memory, even when they are serving something simple like a .css file or an image.
For this reason, the first limitation you are likely to encounter running Apache is a limitation on memory. I will explore this topic and show you how you can do the same.
The first thing need to determine about Apache is what mode it is running in. If your plan is to use Apache with php via mod_apache, then the prevailing wisdom for many years has been that there may be library extensions in PHP that are not thread safe. For this reason, people have tended to avoid running Apache as a threaded server, for fear that scripts may randomly die producing the dreaded 500 Internal server error pages we all know and love.
This fear may be overstated depending on the nature of your php code, but the defaults for apache packages I've seen, seem almost always to be using the prefork worker.
Prefork vs Worker?
So the first question you might be asking yourself is, which mode is my current apache server running in? There is a simple safe way to determine this -- run the httpd(apache) program with a specific command line switch. There are programs like which and whereis that might help you locate it, if you don't know where it is.
whereis httpd
So let's run the /usr/sbin/httpd with the -h for help and see what happens:
For this reason, the first limitation you are likely to encounter running Apache is a limitation on memory. I will explore this topic and show you how you can do the same.
The first thing need to determine about Apache is what mode it is running in. If your plan is to use Apache with php via mod_apache, then the prevailing wisdom for many years has been that there may be library extensions in PHP that are not thread safe. For this reason, people have tended to avoid running Apache as a threaded server, for fear that scripts may randomly die producing the dreaded 500 Internal server error pages we all know and love.
This fear may be overstated depending on the nature of your php code, but the defaults for apache packages I've seen, seem almost always to be using the prefork worker.
Prefork vs Worker?
So the first question you might be asking yourself is, which mode is my current apache server running in? There is a simple safe way to determine this -- run the httpd(apache) program with a specific command line switch. There are programs like which and whereis that might help you locate it, if you don't know where it is.
whereis httpd
CODE:
httpd: /usr/sbin/httpd.worker /usr/sbin/httpd /usr/sbin/httpd.event /etc/httpd /usr/share/man/man8/httpd.8.gz
So let's run the /usr/sbin/httpd with the -h for help and see what happens:
Continue reading "Putting Apache on a diet - how to get a lean configuration, Part 1" »
PHP Mysql support: mysql or mysqlnd? Sat, Jul 1. 2017
So you are installing a modern version of php using one of the alternative repositories, and suddenly you are confronted with a confusing choice. You want support for mysql (mysqli or PDO-mysql) in your php program. But which one to choose?
First off, you should probably be using PDO. It's just a cleaner database interface when compared to mysqli, and also tends to be the supported option if you're using an ORM like Doctrine2.
But you probably have found that installing the PDO package doesn't get you support for MySQL.
So what are these 2 packages? Well let's see what yum under Centos shows us, once we've setup webtatic as a repo:
* webtatic: us-east.repo.webtatic.com
==============================================
php56w-mysql.x86_64 : A module for PHP applications that use MySQL databases
php56w-mysqlnd.x86_64 : A module for PHP applications that use MySQL databases
In short, the mysql extension aka the mysql library is to quote Oracle/mysql
This was the original php approach to supporting mysql. MySQL provided a client api library, and using that c library, a php extension was created that depends upon libmysql implementing the famous mysql_ functions that allowed php to talk to mysql.
The mysqlnd package (where nd stands for "native driver") is the fruit of a project to make mysql work optimally in the php language. Again to quote the mysql site:
On top of these benefits are a number of interesting enhancements and support for plugins that might be of specific interest to you as a developer or sysadmin.
In general nothing should break in your code as the api should work the same under mysqlnd as it did with the old mysql library.
Conclusion
First off, you should probably be using PDO. It's just a cleaner database interface when compared to mysqli, and also tends to be the supported option if you're using an ORM like Doctrine2.
But you probably have found that installing the PDO package doesn't get you support for MySQL.
So what are these 2 packages? Well let's see what yum under Centos shows us, once we've setup webtatic as a repo:
* webtatic: us-east.repo.webtatic.com
==============================================
php56w-mysql.x86_64 : A module for PHP applications that use MySQL databases
php56w-mysqlnd.x86_64 : A module for PHP applications that use MySQL databases
In short, the mysql extension aka the mysql library is to quote Oracle/mysql
... a general-purpose client librarynamed libmysql.
This was the original php approach to supporting mysql. MySQL provided a client api library, and using that c library, a php extension was created that depends upon libmysql implementing the famous mysql_ functions that allowed php to talk to mysql.
The mysqlnd package (where nd stands for "native driver") is the fruit of a project to make mysql work optimally in the php language. Again to quote the mysql site:
The mysqlnd library is highly optimized for and tightly integrated into PHP. The MySQL Client Library cannot offer the same optimizations because it is a general-purpose client library.
The mysqlnd library is using PHP internal C infrastructure for seamless integration into PHP. In addition, it is using PHP memory management, PHP Streams (I/O abstraction) and PHP string handling routines. The use of PHP memory management by mysqlnd allows, for example, memory savings by using read-only variables (copy on write) and makes mysqlnd apply to PHP memory limits.
On top of these benefits are a number of interesting enhancements and support for plugins that might be of specific interest to you as a developer or sysadmin.
In general nothing should break in your code as the api should work the same under mysqlnd as it did with the old mysql library.
Conclusion
In summary, you want to use mysqlnd now and in the future.
« previous page
(Page 1 of 7, totaling 40 entries)
next page »