Whenever I submit a git package to my packagist installation, I get the following error:
Uncaught Exception: [RuntimeException] The HOME or COMPOSER_HOME environment variable must be set for composer to run correctly
I've tried exporting the variable manually, but that doesn't seem to resolve the error.
The php user didn't have HOME or COMPOSER_HOME set, so I created a php.ini file in my web root with the following contents:
auto_prepend_file = /home/yourusername/directory/set_environment.php
I then created a set_environment.php file in the same directory, and set my COMPOSER_HOME directory.
<?php putenv("COMPOSER_HOME=/home/etc/webapps/novuspackagist/.composer"); ?>
Now, whenever the app is run, the COMPOSER_HOME environment variable will be set.
A much easier way is to add the environment variable into the apache configuration within the virtual host block, e.g.:
<VirtualHost *:80>
ServerName myhost.home
ServerAdmin webmaster#localhost
DocumentRoot /var/www/packagist/web
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/packagist/web>
AllowOverride All
SetEnv COMPOSER_HOME /home/<user>
</Directory>
</VirtualHost>
As you can see the SetEnv COMPOSER_HOME /home/<user> directive makes it possible.
This should solve that kind of problems.
Related
I was having problems with a blank page in my first Laravel project. I'm currently watching the Laravel Framework course on YouTube. This is Lesson 1 called "How to install the Laravel Framework". I checked it out laravel.com for the requirements section and made sure I have all of them. After that, I installed Composer 2.0.13. Using it, I installed Laravel Framework 5.7.29. I got reports that some packages are deprecated. They were about changing the color on the console.
The next step was to change "/etc/hosts". I added the line 127.0.0.1 poligon.local The next step was to change "/opt/lampp/etc/extra/httpd-vhosts.conf". I added the lines:
<VirtualHost *:80>
ServerAdmin admin#example.com
DocumentRoot "/home/stas/projects/poligon.local/public"
ServerName poligon.local
ServerAlias www.poligon.local
<Directory /home/stas/projects/poligon.local/public>
Options Indexes FollowSymLinks
AllowOverride All
Order Allow,Deny
Allow from all
Require all granted
</Directory>
ErrorLog "logs/poligon-error.log"
CustomLog "logs/poligon-access.log" common
</VirtualHost>
Then I wrote $ sudo /opt/lampp/lampp start to start the local XAMPP server. And I have a blank page on the "poligon.local/". When I started php artisan serve, I had access to "poligon.local:8000", and there is the Laravel home page. But the author of the video got access to the "poligon.local" without php artisan serve. What do you think is my mistake?
Update: If I create /public/index.html I will get this html page.
Update2: I was experimenting now with php artisan serve --host 127.0.0.1 --port 80 and found that with the XAMPP server enabled, this socket is already in use. But when the server is turned off, I manage to run artisan command with these connection settings. As I understand it, XAMPP occupies this socket, but for some reason can't handle it on its own.
Update3: I checked it out /public/index.php the whole file and found out that it is being executed. Up to the line $response = $kernel->handle( $request = Illuminate\Http\Request::capture() ); There is no continuation after it.
Define the site you added in hosts file in the Virtual Host route.
Change this
<VirtualHost *:80>
ServerAdmin admin#example.com
DocumentRoot "/home/stas/projects/poligon.local/public"
ServerName poligon.local
ServerAlias www.poligon.local
<Directory /home/stas/projects/poligon.local/public>
Options Indexes FollowSymLinks
AllowOverride All
Order Allow,Deny
Allow from all
Require all granted
</Directory>
ErrorLog "logs/poligon-error.log"
CustomLog "logs/poligon-access.log" common
</VirtualHost>
to this
<VirtualHost poligon.local:80>
ServerAdmin admin#example.com
DocumentRoot "/home/stas/projects/poligon.local/public"
ServerName poligon.local
ServerAlias www.poligon.local
<Directory /home/stas/projects/poligon.local/public>
Options Indexes FollowSymLinks
AllowOverride All
Order Allow,Deny
Allow from all
Require all granted
</Directory>
ErrorLog "logs/poligon-error.log"
CustomLog "logs/poligon-access.log" common
</VirtualHost>
Notice that i have defined the host URL you defined in the virtual host route
From <VirtualHost *:80> to the url you defined <VirtualHost poligon.local:80>
What this * does is it gets all the requests and direct it to XAMPP homepage which is default.
I was testing a clean Laravel 6 installation to migrate an old Laravel project in one Ubuntu 18.04 environment, no used with PHP projects before.
After install PHP, Apache, Mysql... I test one PHP page OK.
I set the permissioins to 777 in /var/www/html/ subdirectories.
I cloned my old Laravel App to migrate and did one clean Laravel 6 installation.
First, I loaded the default welcome page in Laravel 6. After, I put some routes and views from the old project and tried to load some of then, but I had errors of type:
page don't found
I checked the settings of Apache and if mod_rewrite was available... finally, I run the old project OK, but my Laravel 6 is dissapeared. I can see it in the disk, but if load the http://localhost/laravel/ directory I can't see it.
Edited
Content of /etc/apache2/sites-available/000-default.conf:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
What i can suggest you to try is to define one Virtual Host for each project in this way:
Put this (with proper information) inside /etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
DocumentRoot "/var/www/html/YOUR_LARAVEL_PROJECT_ROOT/public"
ServerName yourProjectDomain.dev
<Directory "/var/www/html/YOUR_LARAVEL_PROJECT_ROOT/public">
AllowOverride All
Options FollowSymLinks +Indexes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
And inside /etc/hosts put
127.0.0.1 yourProjectDomain.dev
Then check the permission on /var/www/html and each subdirectory (you can use cd /var/www/html && sudo chmod -R 777 * to set everything as readable, writable and executable).
Then clear the cache of the project (delete all the files inside the bootstrap/cache folder).
Then you should be able to access that project just using yourProjectDomain.dev on every browser inside your pc.
I installed backup of website from live server to localhost in xampp. But when I run the project I mean that when I type localhost/folder its shows php info file. I don't know why this happening. Can anyone guide me?
You'll have to configure virtual host on xampp in
C:\xampp\apache\conf\extra\httpd-vhosts.conf
<VirtualHost myproject.test:80>
DocumentRoot "C:\xampp\htdocs\myproject\public"
<Directory "C:\xampp\htdocs\myproject">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Also add this to hosts file in
C:\Windows\System32\drivers\etc
127.0.0.1 myproject.test
Change myproject with the name you want.
I have a question about a bad practice in Laravel.
I have only one server folder available for Laravel (in IIS).
There, I have the production site.
If I want to add a copy for development and testing against the test database, where must I place it?
Inside the production's version public folder? I donth think because it's unsafe. Sure will be an obvious best practice for that.
You can open a new port for it.
Example:
Config Virtual host with Production site:
Create a configuration file our laravel production project by typing the following commands
cd /etc/apache2/sites-available
sudo nano production.conf
In the production.conf file created paste the following content to the file and close it after saving.
Replace laravelproduction.com with the domain name of your website inside the file.
<VirtualHost *:80>
ServerName laravelproduction.com
DocumentRoot /var/www/html/production/public
<Directory /var/www/html/production>
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Enable the newly created .conf file and disable the default .conf which is pre-created by apache and enable mode rewrite for this to function appropriately. These are the comand to help you do that.
sudo a2dissite 000-default.conf (disable the default .conf file)
sudo a2ensite production.conf (enables the newly created .conf file)
sudo a2enmod rewrite (enables the rewrite)
Also, restart your apache server so that it can pick the changes that you have made by typing this command
sudo service apache2 restart
Config Virtual Host With Dev site
Create a configuration file our laravel dev project by typing the following commands
cd /etc/apache2/sites-available
sudo nano dev.conf
In the dev.conf file created paste the following content to the file and close it after saving.
Listen 8100
<VirtualHost *:8100>
ServerName laraveldev.com
DocumentRoot /var/www/html/dev/public
<Directory /var/www/html/dev>
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Enable the newly created .conf file and disable the default .conf which is pre-created by apache and enable mode rewrite for this to function appropriately. These are the comand to help you do that.
sudo a2ensite dev.conf
Finally restart your apache server so that it can pick the changes that you have made by typing this command
sudo service apache2 restart
This is how I usually use it. I hope to help you. ^_^
I have a website running fine which is located at:
/var/www/html/abcde
and phpmyadmin placed in:
/var/www/html/myadmin
And I have the following in my httpd.conf:
<VirtualHost *:80>
ServerName myadmin.mysite.com
DocumentRoot /var/www/html/myadmin
</VirtualHost>
I have added a DNS record, so that going to:
http://myadmin.mysite.com
does go to a link such as:
https://myadmin.mysite.com/?collation_connection=utf8_general_ci&token=d9383416a3547b7b0e569e048ca7caed&phpMyAdmin=899v1qg8t3s0o527qcgne0s5p2s2uijh
However, the page which shows up is the "Apache 2 Test Page". I earlier had this same folder located at: /var/www/html/abcde/myadmin and I simply moved it to its present location.
Check if you have the correct permissions on your folders
you can change the permission of your root folder
sudo chmod -r 0755 rootfolder
and here is how your httpd.conf should look like
<VirtualHost 127.0.0.1:8888>
ServerName myadmin.mysite.com
DocumentRoot "/var/www/html/abcde"
DirectoryIndex index.php
<Directory /var/www/html/abcde>
AllowOverride All
Allow from All
</Directory>
phpmyadmin itself was forcing a SSL connection
$cfg['ForceSSL'] = true;
I disabled that by setting it to false and everything worked.