Yii2 advanced template config - php

Something wrong with my assets configuration, it looks to /usr/lib/cgi-bin/assets, which is wrong I guess. How to fix it?
Yii setup is initial.
Apache config:
Nginx config:

I recently also had similar problem with missing folder assets (I don't know how that happened since I have installed Yii2 multiple times and that occurred just once). The difference was only different path to it.
What solved my issue is creation of that folder in specified path (which is /usr/lib/cgi-bin in your case and it should be an empty folder, no need to write anything in it).
After that, Yii2 system should generate all widgets' JavaScript and CSS files automatically (assuming your server allows that). Try to access the website and if you still have the same issue (which shouldn't be the case anymore?), check if there are any files/folders in your newly created assets folder.

Related

NotFoundHttpException Only for the CSS and JS files

So for context, the application is a portal for my company that we have hosted on the main production server. Then we have the developer version on a different server. Same exact application but on a different VM and has a different url. That was all set up before I got put in charge of it. Now we want to make an alpha server as the dev server can affect the main database. So for the alpha we need to pretty much have it be exactly like dev, but once it's built, copy the database to a separate db and disconnect it from the main one.
But right now the issue is setting it up. I got Apache2 setup and the site all put together. Now the issue I'm running into is that it's showing the site but not running any of the CSS or JS. The laravel log shows this:
[2019-02-20 11:33:51] local.ERROR: User: test Route:
https://test/app/portal/final.css File:
/var/www/laravel/bootstrap/cache/compiled.php Line: 8335
Class:
Symfony\Component\HttpKernel\Exception\NotFoundHttpException
Exception: exception
'Symfony\Component\HttpKernel\Exception\NotFoundHttpException' in
/var/www/laravel/bootstrap/cache/compiled.php:8335
The same error comes up for the js file but I don't want to post that as it is the exact same error.
And the output of my site right now is just a bunch of links and text in a left tabbed column on the left.
I assume this is due to something not being installed or a config file not reading properly. The code for the site is all just git fetched so it's exactly the same as from the other two servers. The only difference is packages installed into the actual server. It seems that the css and js files aren't loading for some reason. I tried a bunch of other threads and fixes with no luck.
PHP Version is PHP 5.6.40-1+ubuntu18.04.1+deb.sury.org+1 (cli)
Apache2 for the server.
Composer version 1.5.6
Laravel 5
Thank you for any help.
Apache Config: https://drive.google.com/open?id=1im9voo0xqlyuf48gX-JJsRu00f0ym1UX
The CSS and JS files are in the public folder under css and js folders respectively.
Like I said, everything works just fine on the two servers already in place and the filesystem and code is the exact same at this point. The only thing that can be different is apache, laravel, and php.
Are you using Laravel mix with version ? If so, you need to import the css like :
<link rel="stylesheet" src="{{mix('final.css')}}">
or use the asset function just to be safe for any CSS/JS you need to import.
Three possibilities...
Apache root folder
First, the document root in your apache config (or site-enabled) needs to be the /public folder. In which case your request wouldn't hit the .htaccess and redirect to index.php and you'd get a bad route error. So this is a less likely option.
Compile Your .css and .js
You haven't compiled the .css and .js using Webpack (or gulp or whatever if you don't webpack) on the new server. In this case, the .htacess would send the request to index.php and Laravel would look for a route (which is what your error looks like) and then you'd get an error about an invalid route. Note the .css and .js should be in the .gitignore if you use git to clone the project, making this an easy thing to overlook and to have happen. Nice thing is that if node and npm are setup and you use webpack, it should just be a:
npm run development
The sad thing is getting node and npm and webpack all working isn't always as simple as it should because of versions and such.
Missing or not reading the .htaccess
Finally, your .htaccess isn't being read or didn't get copied over, which would mean that that / route would magically work, but any other routes wouldn't... Though, in that case your .css and .js should still work -- but not likely.

Internal pages not found (404) after moving to new host - CodeIgniter

I have recently moved one website to new server. I have transferred everything properly including mysql database. But now the internal pages are not opening (sending 404 error). Homepage looks fine.
One thing to consider here is that, the website was on shared cpanel with another domain and residing in a folder. Now after moving, it is placed directly in public_html. I hope, this doesn't create any issue.
The website is: http://nepaltrekking.co.kr/
regards,
When hosting changes, we need to take care of the following steps for codeigniter:
Check required php and apache modules are installed and enabled.
If installation is not in root directory, you must change htaccess.
If domain is changed, you need to edit config file for new base_url.
Clear application cache if enabled. Give required write permision in cache directory.
If nothing works, then see error log and correct error accordingly.
Actually I resolved it. The issue was with .htaccess. I changed the permission to 666 and it started working. I think there was problem writing in the .htaccess file.

Apache write permissions ( Drupal module unable to write/create css/js files)

I'm using a Drupal module called 'Code Per Node'. It allows basically what the name describes: custom code in the form of JS or CSS on a per node basis. Upon publishing the node, the module writes the css and js to a file specified in the module's configuration settings.
In development, I have the directory set to /cpn, I've temporarily made the permissions for that folder 0777 just to cover all angles.
The problem is, I've moved the site to a staging server and something about the environment is restricting the module from writing the CSS and JS files. it returns a 'The file could not be created' error upon publishing.
I've tried: Setting open permissions and moving directory inside of /sites/default, no dice.
Is there anything else I should look at that would prevent this module from writing these files? Perhaps an Apache config setting?
As a side note, I would much prefer the custom code be generated inline on the page, so if anyone knows any actively supported modules that accomplish this, that would also be much appreciated.
Thanks
Problem was that the tmp directory for Drupal was still set to a local path.

Netbeans and codeigniter

For some reason when I create a project in netbeans and go to run the project it also loads the xxamp index file and not the project index file that is apart of the codeigniter installation.
http://screencast.com/t/qOSH80wPgvf
Edit:
Here is my file tree I have right now set up for my project. Why Netbeans creates an important files folder I have no idea for my CI project. I have edited the index file to have the application and system variable to both have the ../system or applicaton as its value. I have changed the Web Root inside the project properties to have a value of public_html and I have also changed the value of the Index File field to say index.php.
After doing this and running the project I would expect to get the default Welcome to Codeigniter page and I don't. I am receiving a message that shows the following. Any ideas on why this is?
Object not found!
The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
If you think this is a server error, please contact the webmaster.
Error 404
localhost
Apache/2.4.4 (Win32) OpenSSL/0.9.8y PHP/5.4.16
Projects
- MyFirstProject
- Source Files
- application
- public_html
- assets
index.php
- system
- Test Files
- Important Files
- Include Path
I've tried doing some additional research on the topic and have yet to come up with a solution.
Edit 2:
Any ideas from anyone?
Your problem is likely related to your choice of folder layout. Which I assume you do, for "security reasons". That said, NetBeans isn't a server. Its an IDE, so you can't manipulate it the same way you would the server.
Most servers by default define your "root" folder as "public_html" or "www" as far as where it looks by default to serve files for public consumption. Through the use of PHP you can tell the index.php that comes with CodeIgniter to look up one directory outside of the defined root and have it read the file(s) accordingly.
However, to setup a project in netbeans and have all files and folder accounted for accordingly you need to tell it that all your files start in whatever folder they reside. So it can load all the files and read from them respectively. This in essence and in respect to server logic is telling it that the folder that houses
application
public_html
system
is the define root path. So inadvertantly by breaking out of the design of codeigniter and placing the core files outside of what would be your defined root on the server is breaking your project. There is not an index.php depicted in your listing above at the same level that those folders are in. If there is, its the index.php for xxamp that keeps loading for you by default.
What you need to do is stop trying to implement your "security measures" and put them in the right order. Or.. not include that folder in your project telling it the one with assets and index.php is the root path. If netbeans is smart enough it will find the files and folders outside like the server will.
Right click on your project and go to properties. Make sure that in the run configuration the URL is correct and the index file is properly set up and matches your directory in xxamp.
after downloading codeigniter open index.php file and there set your path correctly to your
application folder because i think you putted your index.php inside public_html folder so
the path which is set by default in index.php is not working and can not find application folder, try to fix it and it will work fine your problem is not with netbeans.

Symfony 1.4 installation and security issues

I have a shared hosting account in which I want to install my symfony 1.4 and deploy and application. I bumped into some issues because of the inability to change the apache config on the production server.
the structure of my web server is:
hosting_account_name
html <--- public folder
I then moved all files in symfony local app folder to my hosting_account_name and put the web folder content in html
So i got the following structure:
hosting_account_name
apps
cache
config
data
html
css
js
index.php
.htaccess
frontend_dev.php
lib
log
plugins
test
and i added the line bellow to config/ProjectConfiguration.class.php
$this->setWebDir($this->getRootDir().'/www');
I have a couple of issues though:
1. when i access the frontend_dev.php no images are due to the fact that symfony expects some files to be under a sf/ folder. Should I move the files there?
2. Index.php gives an error. Even with display errors set to yes and 500 internal server error is presented.
Also i had to set my permissions to 777 on cache and log. Their are under the folder html so that's ok for security right?
First, you said that the "public" folder is html, but you used $this->setWebDir($this->getRootDir().'/www');. Is it html or www? (Just to make sure)
Then: setting the sf_web_dir should work like you expected, so that shouldn't throw any errors.
To link the /sf Symfony folder, you will need to add something to your apache configuration. As described on the first page of the Jobeet tutorial, you will need to add an Alias to the /lib/vendor/symfony/data/web/sf.
If you don't have access to the httpd.conf, you could also add this to your .htaccess.
777 for log and cache is ok. It's what the default project:permissions task does as well.

Categories