I have a Laravel project in my local machine that is currently in development, due to reasons, the application is showcase to people using an Nginx server, the problem is this, in the local machine I host the project in a root directory (localhost:8000/), but in the Nginx I host it in a folder (e.g. 10.x.x.x/webapp/), this breaks a lot of stuff and I need to constantly change back and fort the reference to the assets and scripts I have, example:
Font awesome fail to load because is looking for the js & css directories and not the webapp/js & webapp/css directories
In a vue component holding a picture the picture won't load because is looking for /img/picture.jpg instead of /webapp/img/picture.jpg
The only way I manage to solve this is, in the case of Font awesome, is to add the mix.setResourceRoot('/webapp') parameter on the webpack.mix.js file, and in the case of the assets to add /webapp at the beggining, but doing that breaks everything on localhost, since now everything is pointing to a folder that doesn't exist in my machine.
What is a possible solution to have both running without constant reference changes? And what other possible problems could emerge?
Related
In AWS Elastic Beanstalk, there is a wizard flow for deploying node.js apps. When I get to the step for "upload your own" application source, it describes in generic terms their 3 requirements: zip file, less that 500MG, no parent folder.
But they stop there. No specifics.
I dropped out to bash and ran...
ng build --prod
...and now have a dist folder. So... what do I include in my zip file and at what folder level? I have tried just /dist, and also /myapp/dist which included all the other loose files in /myapp but no other sub folders such as /src. I have looked all over the web, but don't see what should be a fairly simple tutorial on zipping up an Application Source Bundle for AWS EC2.
What should be included in the zip file for upload?
The cardinal sin in my question above was attempting to run my Angular 5 app in AWS by using their choice for node.js as my server platform. Here is what I learned (with some help from folks like Albert Haff: Angular 5 uses Node (ng serve) to simulate a webserver while you code. However, even though there is a supported flag for --prod, it's not to be used in production! It's really easy (and tempting) to select node.js as the environment when deploying your Angular 5 app via Beanstalk -- but don't do it!
from within your Angular 5 project folder, run ng build --prod ( and consider adding --aot)
if you can, from within the new /dist folder that the build just created (or updated), optionally run compression like for i in dist/*; do brotli $i; done
from within the /dist folder, zip up ALL the contents including subfolders.
go to beanstalk, and as you create a webserver environment, select Tomcat (or any other plain old webserver, but DON'T pick node.js even though it's on the list!).
on Application Code, select to Upload Your Own, and browse to the .zip file you created in step 3 above.
click Create Environment and in a few minutes your Angular 5 app will be serving up on the internet.
Now, from here you will likely need to connect up your domain name. Use Route 53 for that.
I have an app (built with laravel) which i deployed it and working very well, but i have a question, when i deploy it the server i made these process :
1- minify css and js files and comine them in a single file
2- changing some configuration (database,hostname,mail sever ,etc ...)
3- Finally i upload my files to the server.
how can i return back to my local config and unminify my js and css files without doing it manually ?
is there a better way to make it automated ? i know that the first step can be done by gulp or any javascript task runner by a single command and the second one is not a big deal ,but i just want to know if there an automated way?
Why don't you just have a .env config file out of you version control and compress your CSS/JS using Laravel Mix as a part of your deploy process?
To make it clear:
Keep your .env file in .gitignore. Thus you have to setup your environment settings only once (database, hostname, etc).
Use npm run prod to minify your CSS/JS: https://laravel.com/docs/5.4/mix
I generated the default RoR application with the rails new <project_name> command, and everything seemed to go fine. Later I decided I wanted to relocate my rails projects in a different directory (something other than my home directory), so I moved the RoR project to /opt/rails/<project_name> and I created a symlink in my web root pointing to /opt/rails/<project_name>/public, and the page loads fine, but some of the assets aren't loading on the Welcome aboard page, i.e. the rails.png And when I go to click on the About your application's environment link I get a 404 error. If I had to take a guess as to why I'm getting these errors it would have to be that I moved the rails app simple_cms from /home/user/www/rails/simple_cms to /opt/rails/simple_cms Is there a command I need to issue in the project root of simple_cms to get things fully working?
Update
I'm using Apache 2 as the web server on a CentOS 5.9 box.
If you are using rails s to launch your app, then there is no need to create symlinks. The web server (could be WEBrick, or Thin) will serve the application from the app root.
If you are using Apache or Nginx, again there is no need to create symlinks, but you need to let Apache/Nginx know the new location. For example, in a Nginx+Passenger setup, you would need to set passenger_app_root to the new location.
Provide more details in your question, or consult the documentation for your setup.
I’ve got two applications running in my CI deployment. I’m using a separate folder to hold shared resources between the two apps.
Then in autoload.php i have:
$autoload['packages'] = array(SHARED_RESOURCES_PATH);
I’m finding models and helpers load fine from the shared directory, however i’ve added a config folder with database.php and this doesn’t get loaded.
Anyone know why this would be?
Most likely the new config directory you created does not have the same permissions or ownership as your other shared directories; compare permissions/ownership & insure config matches the others (this is usually the culprit when all else is functioning properly).
I'm thinking to something really similar on what you can do with mod_php: drop an application in some way inside Apache and making it run with Passenger, without adding anything inside httpd.conf (no vhost, nothing except the basic Passenger configuration).
It's something very similar to Wordpress or many other frameworks: just unzip/svn checkout it inside a folder and run it.
I know that it's possible with CGI and FCGI, but I'm wondering if it's also possible to tap in the speed of Passenger.
I've tried fiddling with the Rack instructions on the official website trying to find a specific .htaccess and config.ru configuration, but nothing so far.
I know it's not common, but... is it even possible?
It's not possible without configuring a virtual host.
Rails applications are not like PHP files; files on the filesystem do not correspond with URLs. PHP files are placed within the DocumentRoot, whereas Rails/Rack apps live outside the DocumentRoot.
It is therefore not possible for Passenger to detect your application's location. You either need to tell it where it is located in the first place, or you need to point your virtual host's DocumentRoot to your application's /public directory. In that case Passenger will detect that it is a Rails/Rack app and you don't need additional Passenger configuration, but you do need a virtual host for each application.
Update: The Passenger docs mention that RailsBaseURI is allowed within a .htaccess file. Adding this in your document root and creating a symlink from a subdirectory (e.g. /docroot/yourapp) to the /public dir of your application might then be just what you need.
It all depends on what is already in your httpd.conf
You can't even run a PHP app without modifying your apache config files on many default apache installs.
Maybe dropping config.ru to some directory would do it?
It is almost possible. If the configuration is done right and apache+mod_rails knows where your application ist you need to change the last modified date of the /path/to/your/app/tmp/restart.txt. With ssh access you can do this like this
touch /path/to/your/app/tmp/restart.txt
more information can be found here: http://www.modrails.com/documentation/Users%20guide.html#_redeploying_restarting_the_ruby_on_rails_application
Update:
Or you can create the /path/to/your/app/tmp/always_restart.txt
more information about this can be found here:
http://www.modrails.com/documentation/Users%20guide.html#_making_the_application_restart_after_each_request