In the first part of this series, we consider how to create and manage development environments in a certain way that is simple, repetitive, and even efficient. This is a matter of self-confidence from time running to time. This solution is a relatively new tool called PuPHPet.
In the first part of this series, we consider how to create and manage development environments in a certain way that is simple, repetitive, and even efficient. This is a matter of self-confidence from time running to time. This solution is a relatively new tool called PuPHPet.
If you miss the first part, PuPHPet creates an unemployed traveler + puppet configuration based on five key fields:
- Deployment Target (memory, IP address, port forwarding)
- Basic Server knowledge
- PHP (module, library, configuration settings)
- Database (from PostgreSQL to MySQL)
- Web server (Apache 2, Nginx)
We focus on how to configure most of the options and how to use the generated configuration. there are some basic unemployed travel commands. However, we just went there.
Therefore, we will go further in the second part of this series. Specifically, we will look for two core files: common. yaml and Vagrantfile. We will make some changes to them, and then set the virtual machine to reflect the configuration changes.
This series won't let you, whether it's a master puppet or let waves, but it's over, you will have enough knowledge to make changes to the configurations generated by PuPHPet, so you can adjust your virtual machine, based on the demand changes.
Note: some important changes have occurred to the puppet and tramp, thus affecting PuPHPet. Please pay special attention to the two notifications at the top of the PuPHPet website-especially if you have encountered any difficulties in the first part of this series below. If no notification is available, the problem is, too.
Configuration changes
What are the one-click commands that you need to know and what are the rules for today. Reference this manual:
This command is a great way to quickly test any provisioners and is especially useful for shell scripts, chef recipes, or incremental development of puppet modules. You only need to modify the configuration script on your machine, run an unemployed traveler, and provide the expected results for you. Rinse and repeat.
We will use it to launch our environment changes.
Modify shared folder configuration
Yes, you may want to adjust the configuration of the shared folder first. Assume that from the first part of the series the original configuration, here is the relevant part of Vagrantfile.
config.vm.synced_folder "/Users/matthewsetter/Documents/workspace/my-great-app", "/var/www/my-great-app", id: "vagrant-root", :nfs => false
You see, I have set a shared folder named/var/www/virtual machine under my workspace directory. Recently, I have created a new project for a stray virtual machine as a customer. I found that my Zend Framework 2 application cannot be written to the cache directory. Looking at the directory structure of the project, all the directories in the virtual machine are owned by the user tramp, but the web server users (and groups) are WWW data. Therefore, it cannot be read. I see two options:
- Change permission to 777
- Change owner and group
For me, the second is a more wise choice. But how to do this? Facts prove that this is very simple. At the end of the above configuration, we need to specify the owner and group as www-data. I have done this in the following updated configuration.
config.vm.synced_folder "/Users/matthewsetter/Documents/workspace/my-great-app", "/var/www/my-great-app", id: "vagrant-root", :nfs => false, owner: "www-data", group: "www-data"
Update the Vagrantfile file in your stray configuration, save the file, and then execute the following command in the command line: vagrant provision. If everything goes well, you will see a similar output called vagrant up for the first time, but it is much shorter, because only some changes are being made-not the whole virtual machine is configured. After it is complete, SSH to the virtual machine and vagrant ssh, and then look at the permissions in the project directory. They should be like the following output:
$ ls -lahrt /var/www/my-great-app/ total 3.1M drwxrwxrwx 1 www-data www-data 102 Oct 15 05:00 data/ -rw-rw-rw- 1 www-data www-data 856K Oct 15 05:00 composer.phar -rw-rw-rw- 1 www-data www-data 607 Oct 15 05:00 README.md -rw-rw-rw- 1 www-data www-data 259 Oct 15 05:00 .gitmodules -rw-rw-rw- 1 www-data www-data 338 Oct 15 05:00 .gitignore -rw-rw-rw- 1 www-data www-data 1.8K Oct 15 05:00 init_autoloader.php drwxrwxrwx 1 www-data www-data 340 Oct 15 05:00 db/ -rw-rw-rw- 1 www-data www-data 2.2M Oct 15 05:00 zftool.phar
Change PHP configuration
So far, everything is fine. Let's take a look at the PHP configuration and make some modifications. The following is the original configuration generated by PuPHPet in the first part. You will find it in vagrant/puppet/hieradata/common. yaml. It displays the PHP version 5.5, the Enable of the composer, the PHP module, the ini settings, and the default time zone.
php: version: '55' composer: '1' modules: php: - cli - intl - cgi - curl - mcrypt - memcache - memcached - pspell - tidy - sqlite pear: { } pecl: - pecl_http ini: display_errors: On error_reporting: 'E_ALL & ~E_STRICT' apc.enabled: '1' timezone: Europe/Berlin
Let's make some changes. Let's change:
- The time zone is "Europe/London"
- Session save_path
- Other runtime options:
Specifically, update ini as follows:
ini: display_errors: On error_reporting: 'E_ALL & ~E_STRICT' apc.enabled: '1' session.save_path: /tmp allow_url_fopen: '1' allow_url_include: '1' error_log: syslog file_uploads: '1' timezone: Europe/London
You are likely to acknowledge the instruction from this ini php manual, so I won't repeat them here. But you can see that they are so easy to configure here, because they are in the php ini file. In fact, let us go out and have a decent change.
After doing so, the new PHP settings here:
- Session. save_path = "/tmp directory =>/tmp Directory
- Allow_url_fopen option => open => Open
- Allow_url_include => open => Open
- Record file_uploads => open => Open
- Error_log => System Log
- Default time zone => Europe/London
- Date. timezone => Europe/London
Note: If you want to select a different time zone, the list here is supported by PHP.
Now, I am sure you will agree that you can change a PHP configuration by modifying a text file, which is powerful and powerful. Imagine that you have already achieved this goal in the past.
Changed the XDebug configuration.
If you have been using PHP for any time, you may have used Derek Rethan's XDebug package. In the first part, we take the basic settings provided in PuPHPet. Let's make some minor changes and reconfigure the virtual machines to enable them. The following is the original configuration in common. yaml.
xdebug: install: '1' settings: xdebug.default_enable: '1' xdebug.remote_autostart: '0' xdebug.remote_connect_back: '1' xdebug.remote_enable: '1' xdebug.remote_handler: dbgp xdebug.remote_port: '9000'
Add the following options. remember to respect indentation. Otherwise, you will have problems.
xdebug.auto_trace = 1 xdebug.idekey = "SITEPOINTPHP" xdebug.max_nesting_level xdebug.profiler_enable = 1 xdebug.profiler_output_dir = "/tmp/xdebug.profiler"
There is no specific reason for any other configuration options. They have been randomly selecting and playing just with XDebug. So feel free if you want to select other options.
As before, it is called vagrant provision and will be completed later. Then we can check the success of the process and view the PHP configuration again:
php -i | grep -i xdebug
- Xdebug. auto_trace => open => Open
- Xdebug. idekey => SITEPOINTPHP
- Xdebug. max_nesting_level => 100 => 100
- Xdebug. profiler_enable => open => Open
- Xdebug. profiler_output_dir =>/tmp directory/xdebug. profiler =>/tmp directory/xdebug. profiler
Modify MySQL configurations
Okay, the last one. Let's change MySQL, and have a little fun. We will change the account name and password, install and enable phpmyadmin. We will strictly implement the user's permission bit. No bad list of tasks. No?
. Think about how long it will take. if you do it all by hand, you will not take it. to be honest, maybe you already have the script, maybe you do it all by hand, however, either method requires time.
Note: I will tell the truth, I am not a MySQL administrator, so I do not know if I have tools. If yes, please make some comments.
As before, the following is the initial configuration, so you know what it looks like.
mysql: root_password: password phpmyadmin: 0 databases: njmOqAFAsG3i: grant: - ALL name: testdb host: localhost user: testdb_couser password: testdb_password sql_file: ''
The following is the updated version, showing its appearance and the changes I mentioned above. The user name and password you see have been changed. I have set phpMyAdmin next to 1 to enable and install.
mysql: root_password: password phpmyadmin: 1 databases: njmOqAFAsG3i: grant: - INSERT - SELECT - 'SHOW DATABASES' - UPDATE - USAGE - INDEX - DELETE - CREATE - ALTER name: testdb host: localhost user: testdb_username password: testdb_P@$sw0rd sql_file: ''
Let's provide the virtual machine again to see what changes have taken place. After running vagrant provision, I can log on to use the new user name and password. phpMyAdmin is available at http: // 192.168.56.101/phpmyadmin /.
Conclusion
So what do you think? Do not use PuPHPet, wandering, and puppets to manage a development environment. Is it really easy? It may have been manually completed or written with bash scripts. Therefore, many things do not take any longer.
As you followed, didn't you set up and run as smoothly as I did? Have you ever encountered any problem that you need to use one hand? If yes, please send me an email at any time.
Otherwise, I hope you will keep biting the bug of unemployed people, puppets and PuPHPet. I also hope that you have seen how easy it is to adjust the environment to fly to adapt to the changing needs by using text files and some commands controlled by version 2.
Please share your comments in the comments.