I'm still really new to Git version control and Laravel. But I have gotten so far, and I'm not sure now where I am going wrong.
I set up VirtualBox and Vagrant on my local windows machine and installed homestead successfully. I have managed to get my Laravel website (it's only one page at the moment as I learn things) working correctly, it displays the header and the footer and the images load and everything. So that's all good.
So now, I have my Laravel website set up within my virtual vagrant server. On this server, the directory for my website is:
/home/vagrant/Code/sites/public_html
No when I cd to that directory, I ran the following:
git init
get remote add origin https://user#repo/user/publichtml.git
git add *
git commit -m "Initial Commit"
git push -u origin master
(I've substituted user#repo instead of the real URL)
All went through successfully. Great. So now on my live server I ran the following:
cd /home/sites/public_html
git init
git clone https://user#repo/user/publichtml.git
Which again, worked fine. It downloaded all the files into the public_html directory which is great. So then I go to visit the website and this is what I get:
The only explanation for this happening is maybe I need to install something on the server before I clone these files to it. I guess the files in the Laravel folder won't run by themselves? Do I need to install composer and laravel on the server or something? If so, how do I do that, and why don't they run on their own?
I cannot see a .htaccess or index.php in the root directory so I am not sure how it runs anyway.
You should install Laravel using composer instead.
composer create-project laravel/laravel mysite
You should also point the document root on your web server to laravels "/public" folder, making the framework code reside outside of the document root. That's good for security (no one can access any framework code, like your configs etc directly).
You will then find the .htaccess-file in the /public folder.
Please read the Laravel documentation about the different but recommended ways to install Laravel.
Btw, doesn't homestead use Nginx instead of Apache? In that case, .htaccess isn't even used. Please refer to the Laravel documentation again regarding homestead.
You need to redirect traffic to public/index.php instructions for this are webserver dependent.
Related
Has anyone here been able to install Snipe-IT (Open source asset management: https://snipe-it.readme.io/docs) on Azure Web Apps?
I know it is possible to install it on an Azure VM, since I've done that, but I would prefer it to be on a Web App so we keep everything simple and slightly more secure.
I have been able to download it from GitHub, and it then says that the document root is incorrect (It has to be \wwwroot\public instead of \wwwroot). So, I go ahead and change the document root to the public, but then the page returns a 500 error. I see that I need to install Composer, so I install the extension for that, but nothing changes. I know the document root works correctly because I am able to place a test file in the public directory and it works fine. It is just the actual Snipe-IT install that gets screwed up.
Here's how I did it:
Run the command composer install under \wwwroot folder to install dependencies.
Change the document root by setting the virtual application path for the web app.
Edit the Snipe-IT configuration file (.env file) to configure the database credentials, app key and so on.
Restart the app service.
Finally, It worked for me.
More and more projects are starting to pile up and I want some workflow and also version control over the different projects. I'm trying to set the "right" workflow with Xampp, Git, GitDesktop and PhpStorm on a Windows 2012r2 machine.
Xampp base: d:\xampp
http://localhost = d:\xampp\htdocs
Dev repositories: d:\xampp\htdocs\repositories\dev\GitDemo
Live repositories: d:\xampp\htdocs\repositories\live\GitDemo
Live folder: d:\xampp\htdocs\GitDemo
Live URL: http://servername/GitDemo (intranet use only)
Right now I have my repositories folder inside the htdocs folder, otherwise I would need another alias/copy action to be able to see what I'm developing. But at the same time the repositories folder is exposed. How to hide this? htaccess?
I've ran git init --bare inside the live folder for this project. With GitDesktop I've created the repository for GitDemo inside d:\xampp\htdocs\repositories\dev.
Using PhpStorm I've created a project based upon local files and pointed it towards d:\xampp\htdocs\repositories\dev\GitDemo. I'm able to see the changes made using git status, add them using git add . and commit them succesfully with git commit -m "my commit..".
I've created a remote server git remote add live master and created a post-receive to checkout the files inside d:\xampp\htdocs\repositories\live\GitDemo to d:\xampp\htdocs\GitDemo.
This all feels like a "ton" of work to set up initially and somewhat redundant (having the same files in 3 locations).
Is this the ideal way to set this up, or do you suggest an alternative approach? Thanks for sharing your thoughts!
I've been thinking about the most logical solution (to my opinion at this moment). Here's how I solved my unclear items as described:
I've optimized it by:
Bringing the repositories directory outside htdocs to d:\repositories\dev\ and d:\repositories\live.
I've set up a symlink to http://localhost/dev/GitDemo that links to
d:\repositories\dev\GitDemo. In this way I don't need to place the
repositories folder inside the htdocs folder and still benefit from
Apache being able to serve the content, which actually resides outside the htdocs folder.
The live version is now placed at http://localhost/GitDemo and with a post-receive hook it gets deployed from d:\repositories\live\GitDemo.git to d:\xampp\htdocs\GitDemo.
If you think I made a mistake or have mistaken something from the way it's supposed to be, please correct me as I'm still not sure this is the correct way but at least it seems like it to me.
what my aim here is to, upload my project that is basically a controller returning a twig template its as simple as that, i just cant figure out how to get it on the hosting.
I have been using symfony for a few months now, so still new to it all. and all the hosting/details stuff is new too me.
Whats throwing me off is my understanding of a hosting web/ folder
and how azures its wwwroot/
i used this website
http://symfony.com/doc/current/cookbook/deployment/azure-website.html
but i'm finding it rather difficult to follow it..
does anyone have any better sites with more clear steps on how to deploy? i've read a lot about a public_html folder but i've never heard/used it before
If someone could explain how the www.domain.com/web/app.php works that would help, i know that, that is the file that is called, but not too sure if i need to say call this file "app.php" or if its done kinda like the way a standard websites looks for 'index.php'
any kinda help or pointers would be much appreciated here as i'm kinda lost
Generally, we can build our project and test on local, then deploy on Azure Web Apps via Git or FTP tools.
Here is my test steps:
Build Symfony project on local, referring Using the Symfony full-stack framework
Login to Azure preview Portal, click NEW=> Web+Mobile=> Marketplace, in Web Apps section click Web app + MySQL, then click create.
When finishing creating Web app service, we can find MySQL connection string in Settings=>Application settings=>Connection strings click show connection string.
then click Set up continuous deployment in Deployment section. Select Local Git Repository for the source. Then in Essentials section, we can find there added a Git URL. Copy it.
In your local symfony project, make sure your Symfony repository has a .gitignore file at its root directory with at least the following contents:
/app/bootstrap.php.cache
/app/cache/*
/app/config/parameters.yml
/app/logs/*
!app/cache/.gitkeep
!app/logs/.gitkeep
/app/SymfonyRequirements.php
/build/
/vendor/
/bin/
/composer.phar
/web/app_dev.php
/web/bundles/
/web/config.php
run the following commands to init git repo and first-time push to Azure:
`
git init
git add .
git commit -m "initial commit"
git remote add azure [URL for remote repository]
git push azure master
Sign on Kudu console of your Azure web site, at https://<your-website-name>.scm.azurewebsites.net/DebugConsole, run following commands:
cd site\wwwroot
curl -sS https://getcomposer.org/installer | php
php composer.phar install
Now visit http://<your-website-name>.azurewebsites.net/web/app.php in browser, we should see the project.
Now we need to configure URL rewrite to remove /web/app.php pattern of the url. Add a file named web.config with the content shown in Deploying to Microsoft Azure Website Cloud in the root directory which is /site/wwwroot on Azure. Click restart on Azure portal, now we can visit the site at http://<your-website-name>.azurewebsites.net .
By the way, for deploying a PHP-MySQL application on Azure Web Apps, we can get more information at Create a PHP-MySQL web app in Azure App Service and deploy using Git. And specifically for Symfony project, the Symfony guide is still useful, and we can ignore section Enabling the PHP intl Extension .
If you can't change the name of the "wwwroot" directory to "web", you have to change the configuration of symfony to use "wwwroot" instead.
Have a look at this page!
I think the easiest solution is the one with the symlink:
Some shared hosts have a public_html web directory root. Renaming your web directory from web to public_html is one way to make your Symfony project work on your shared host. Another way is to deploy your application to a directory outside of your web root, delete your public_html directory, and then replace it with a symbolic link to the web in your project.
I want to upgrade my website without downtime. I made researches and didn't find a way to upgrade it without downtime (few seconds are fine). I was thinking a way as follows, but I am not sure whether any good professional way is there. Please help me out on how to improve this.
Add new tables/CFs to the database (database is Cassandra,
we are not supposed to do any changes in existing tables/CF)
Deploy the project in online server in different Directory, so that
users can still use the existing site.
Point the uploaded project in different port and check whether
everything is working properly.
If everything is working change the symlink to the uploaded directory
Please let me know any other good methodology if you have.
I am using SVN in my local server
UPDATING THE SERVER ALMOST INSTANTANEOUSLY
Ok for this one of the best and the easiest method is using Git. So, what you should do is host your code in Git and then whenever you want to update the site, just SSH into the server and do a Git Pull. It's instantaneous and it would update it. Also you can use Git Hooks to further solve your problem as well.
There are a few ways you can go about it, but one of the easier methods would be this.
Let me explain it in detail on how to do it:
The source for your web site should live in a Git repository on the local workstation. I shall describe how I set things up so that I can make changes live by running just "git push online".
The local repository
It doesn't really matter how the local repository is set up, but for the sake of argument, let's suppose you're starting one from scratch.
$ mkdir somesite && cd somesite
$ git init
Initialized empty Git repository in /home/sankalpsingha/somesite/.git/
$ echo 'Test!' > index.html
$ git add index.html
$ git commit -q -m "This is the first push."
The remote repository
I assume that the web site will live on a server to which you have ssh access, and that things are set up so that you can ssh to it without having to type a password (i.e., that your public key is in ~/.ssh/authorized_keys and you are running ssh-agent locally).
On the server, we create a new repository to mirror the local one.
$ mkdir coolsite.git && cd coolsite.git
$ git init --bare
Initialized empty Git repository in /home/sankalpsingha/coolsite.git/
Now lets make and define the hoolks as a post-receive hook that checks out the latest tree into the web server's DocumentRoot (this directory must exist; Git will not create it for you):
$ mkdir /var/www/www.somesite.org
$ cat > hooks/post-receive
#!/bin/sh
GIT_WORK_TREE=/var/www/www.somesite.org git checkout -f
$ chmod +x hooks/post-receive
Back on the workstation, we define a name for the remote mirror, and then mirror to it, creating a new "master" branch there.
$ git remote add online ssh://server.somesite.org/home/sankalpsingha/coolsite.git
$ git push online +master:refs/heads/master
On the server, /var/www/www.somesite.org should now contain a copy of your files, independent of any .git metadata.
The update process
Just run :
$ git push online
This will transfer any new commits to the remote repository, where the post-receive hook will immediately update the DocumentRoot for you.
(This is more convenient than defining your workstation as a remote on the server, and running "git pull" by hand or from a cron job, and it doesn't require your workstation to be accessible by ssh.)
You can use some CI or deployment tools. I'm doing this manually. Here is the way i'm doing it.
I have a workcopy directory from git, and git hook to sync it on push.
Then i sync worckopy directory with site using rsync.
All database changes done with migrations, so 1 command yiic migrate is enough to make new tables or alter existing.
With this methodology there is no actuall downtime, some pages can be unavailable for 5-10 sec max, but all system works on this time.
Point the uploaded project in different port and check whether
everything is working properly. If everything is working change the
symlink to the uploaded directory
It's bad way, for testing you need test server, or test it on local machine with same configs and params as on server. For example Vagrant can make any environment on your local machine for testing.
If you need to pass tests (e.g. unit tests or functional), then watch on CI tools.
While installing laravel through terminal command, my other projects in MAMP htdocs folder got affected and they are not working.
I followed this process for installing laravel
Those directions have you symlink the "htdocs" directory to your laravel install, effectively making your htdocs directly useful only for Laravel.
You should avoid this, perhaps by creating a symlink from your laravel build to a directory within htdocs. For example, linking to a directory in htdocs called "mylaravelapp": ln -s /path/to/laravel-master /path/to/htdocs/mylaravelapp.
Lastly, consider using Vagrant or another virtual machine provider instead of MAMP for a server. You'll have to get through a learning curve (potentially), but you'll end up better for it. This creates a virtual server for you, which won't interact with any other parts of your Mac (YOu can make a server per project!).
Here is a guide to get started with Laravel 4 and Vagrant.