I have an apache server and my projects are inside /var/www/html/
Inside there I created a new project using composer like composer create-project symfony/website-skeleton myproject.
Then inside my project I ran the command composer require symfony/apache-pack which added an .htaccess file inside public folder containing the default .htaccess of symfony.
When I accessed my server like http://192.168.0.2/myproject I got the folder list that apache serves if it doesn't find an index.php file because it accessed the default symfony folder in /var/www/html/myproject and not the public folder.
So inside the folder /var/www/html/myproject which is a symfony project I added the following .htaccess file.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /myproject/
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</IfModule>
No I when I visit http://192.168.0.2/myproject I get an error that No route found for "GET /myproject/" which means that symfony now considers /myproject as part of a route.
Is there a solution for this. I suggested solution that I got from symfony slack would be to have the project inside another folder and symlink only the public folder.
Something like:
lrwxrwxrwx 1 root root 59 gmponos 9 19:26 myproject -> /home/gmponos/Projects/myproject/public/
This is a solution but I really need to have the whole project under /var/www/html/ and not symlink the public folder.
Also another solution according to the official documentation is editing the apache config and change the document root from /var/www/html/myproject to /var/www/html/myproject/public but I need the configuration to stay inside the project and not change the apache config.
Is there any solution?
Is there any solution?
No Solution for what you are requesting :
You must have the rights to configure Apache to adjust the document root to either :
/var/www/html/myproject,
or /var/www/html/myproject/public
and set according access permissions in apache config file
Putting whole code in code in /var/www/html directory, and give free remote access through Web (Apache) is very risky, for production environments.
I have PHP with Apache2 and I want to run Laravel Framework without Artisan but I can't! Does anyone know how to run Laravel without Artisan?
I've solved the problem. The problem was in my htaccess and in mod_rewrite (Apache2). Now I can connect to my application only by typing localhost/public..
If anyone wants to make the application public, the more easy and fastest way is:
Rename the "server.php" file in root directory, in "index.php"
Move your .htaccess from public folder to root directory
Make your directory accessible to Apache2 (set correct file/folder permissions).
Thanks to all users for help! :)
Important Edit
Consider using Apache Virtual Hosts (pointing the virtual host to the /public Laravel folder) instead of renaming server.php to index.php because by doing this you will need to prefix "public/" when you use the Laravel's asset() function in your views.
When working with other devs, who are using a different configuration, this might be a big problem because they will be able to see the assets while you will not (or viceversa).
I am using xampp in mac
inside htdocs / run following command:
$ laravel new myblog
After successfully creation run following and do following:
sudo chmod -R o+w storage/
Change server.php to index.php (# root directory)
copy .htaccess from public to root directory
(optional) in resources / app.blade.php → Change to
<link href="{{ asset('public/css/app.css') }}" rel="stylesheet">
run following
http://localhost/myblog/
Easy solution without any code alterations
Point your domain to public/ folder of laravel project.
Enjoy!
~OR~
Create .htaccess in project folder and add below code. This code will rewrite domain to public/ folder of your laravel project
RewriteEngine on
RewriteRule ^(.*)?$ ./public/$1
Hope this is helpful.
Laravel framework is such a pain in the ass for startup PHP guys who are not much oriented about what the hell composer is, and where .phar files are coming from and what are they, and why "Artisan" is trying to ruin your PHP life.
Most people are looking for a PHP framework where all you have to do is download, extract and code.
Nevertheless to make things work, you just need to install Laravel through Composer:
composer global require "laravel/installer=~1.1"
Anyway, you can download Composer from http://getcomposer.org/
After you install Laravel through Composer, navigate to your local server's directory. You might want to use "CD" (Change directory) to do this. (I'm speaking of CLI, whether you're in BASH(Linux) or CMD(Windows))
Then create your very first Laravel project by typing this in command line:
laravel new mywebsite1
Replace "mywebsite1" with your first project name.
And there you go, you're ready to hit the Laravel road.
In my case, I'm still using Windows XP in such development and shifts back to Ubuntu Trusty whenever I feel like I want to smell Linux scent.
So Composer installs "Laravel installer" in:
%userprofile%\Application Data\Composer\vendor\bin
So I make a backup copy of this directory so the next time I use Laravel on other unit with no internet connection, I just have to extract it, and run:
laravel new [myprojectname]
within the same directory and copies the resulting folder to my XAMPP's htdocs or WAMP's www folder.
Anyway I'm just sharing my approach for those with no 24/7 internet connection at home :p
After all it's still best for everyone to read the documentation on how to properly install Laravel: http://laravel.com/docs/5.0/installation
For Windows Users Its very easy to change and run laravel projects on your normal project urls :
1. "server.php" to "index.php" .
2. copy ".htaccess" from public to root directory.
there you go with your normal URL .
localhost/project_name
Artisan is simply a command line interface. It is made to do things like create and run migrations and automate building certain objects within your Application, etc. Essentially, it's only made to help facilitate creating and working on your Application, not run it.
If you are having issues actually getting the Application to run, it is likely a problem with either your PHP or Apache, not Artisan.
Just Follow 3 Step ;
Change File Name : change serve.php to index.php inside your Project name folder.
Move .htaccess file Bring ".htaccess" file to main root [inside your Project name folder ].
Restart your local server. Your are just 1 click away . Restart all services of xampp or wamp
Enjoy
For an aternative maybe you can run it under a virtual host. All you need is just create a new virtual host with your project/public directory as a DocumentRoot.
In my case, I am using XAMPP under Mac OS. These are the steps on how to achieve that:
Enable virtual host config
Ensure virtual host config was enabled, else you can enable it through this file: /Applications/XAMPP/xamppfiles/etc/httpd.conf
$ sudo nano /Applications/XAMPP/xamppfiles/etc/httpd.conf
Remove the hash "#" of this following line
# Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf
Add a new virtual host
$ sudo nano /Applications/XAMPP/xamppfiles/etc/extra/httpd-vhosts.conf
The add a new virtual host (e.g: newproject.dev)
# Virtual host of newproject.dev
<VirtualHost *:80>
ServerName newproject.dev
DocumentRoot "/Users/your-username/newproject/public"
<Directory "/Users/your-username/newproject/public">
Options Indexes FollowSymLinks Includes execCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Note: /Users/your-username/newproject/public is the location of your project.
Update your hosts
$ sudo nano /etc/hosts
Add this following setting:
# Host of newproject.dev
127.0.0.1 newproject.dev
Restart your Apache, go to your browser and your project should be available on http://newproject.dev
I got mine to work by adding the following block to my apache vhost conf file
<VirtualHost *:8003>
ServerName myproject
DocumentRoot "/path/to/myproject/public"
</VirtualHost>
and running sudo chown -R daemon storage from my project root
Well , the easy way is
1) create a new folder"Project" and copy all files except public folder content to project folder
2) copy all files of public folder to root
and you can run laravel without artisan.If you rename server.php and copy .htaccess , it may make trigger some error when you try to run auth artisan command.I experienced problem with auth command.
Laravel with Vue.JS
If you are using vue.js with Laravel and your app is not working without php artisan serve, you need to create a virtual host. This is a simple two-step process for windows.
Step 1: Update you hosts file at C:\Windows\System32\drivers\etc with,
127.0.0.1 dev.example #You can rename according to your app
Step 2: Update you vhosts file with,
I am using Apache which is installed in D:\ so my path for vhosts file is at
D:\xampp\apache\conf\extra
<VirtualHost *>
DocumentRoot "D:\xampp\htdocs\example\public" ##Your path
ServerName dev.example ##Your URL according to what you set in hosts file in step 1
<Directory "D:\xampp\htdocs\example\public"> ##Your path
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
That's it, now you can just visit your app at http://dev.example/
Install and setup Laravel on your local (meaning your local machine).
Once done, copy all files to your hosting.
Create a .htaccess file on your Laravel's root directory. This is to access it without the "public" on the URL.
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
Hi all I'm using PHP for my website and ubuntu linux on my system. I got the above error in error.log file of apache, even after configurating everything properly. I did a lot of research on this but couldn't be able to resolve the issue. Can anyone please help me in this reagard? Following is my .htaccess file in abc directory. Can anyone please help me in this regard?
# -FrontPage-
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName abc.org
AuthUserFile /home/abc/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/abc/public_html/_vti_pvt/service.grp
Options -Indexes
RewriteEngine On
RewriteRule ^alumni$ alumni.php
RewriteRule ^student$ student.php
RewriteRule ^view_alumni_article/view/([0-9]+)$ view_alumni_article.php?op=view&article_id=$1
Make sure that the htaccess file is readable by apache:
chmod 644 /var/www/abc/.htaccess
And make sure the directory it's in is readable and executable:
chmod 755 /var/www/abc/
I had the same issue when I changed the home directory of one use. In my case it was because of selinux. I used the below to fix the issue:
selinuxenabled 0
setenforce 0
If it gets into the selinux arena you've got a much more complicated issue. It's not a good idea to remove the selinux protection but to embrace it and use the tools that were designed to manage it.
If you are serving content out of /var/www/abc, you can verify the selinux permissions with a Z appended to the normal ls -l command. i.e. ls -laZ will give the selinux context.
To add a directory to be served by selinux you can use the semanage command like this. This will change the label on /var/www/abc to httpd_sys_content_t
semanage fcontext -a -t httpd_sys_content_t /var/www/abc
this will update the label for /var/www/abc
restorecon /var/www/abc
This answer was taken from unixmen and modified to fit this question. I had been searching for this answer for a while and finally found it so felt like I needed to share somewhere. Hope it helps someone.
I have also got stuck into this and believe me disabling SELinux is not a good idea.
Please just use below and you are good,
sudo restorecon -R /var/www/mysite
Enjoy..
I have setup apache according to this article
https://help.ubuntu.com/community/ApacheMySQLPHP
and I have created a new site config in /etc/apache2/sites-available/mysite
and changed the document root and directory to :
DocumentRoot /home/gapton/public_html
<Dictory />
..
..
</Directory>
<Directory /home/gapton/public_html/>
...
...
...
...
</Directory>
and I sudo a2dissite default && sudo a2ensite mysite to disable and enable them, restarted apache2 and things are working.
I then setup vsftpd and config the vsftpd.conf file to :
local_enable=YES
write_enable=YES
connect via Notepad++ with the user 'gapton' and I created a file called test.php under home/gapton/public_html. It would not be readable by Apache it seems. I did sudo chmod -R 755 ~/public_html and it would load alright.
However any subsequent files created via vsftpd will not be readable.
Since I have logged in to the only account gapton when connecting via FTP, then any newly created file should be owned by gapton right? What happens when apache tries to access a file/folder location, what credentials does it access it by?
How do I config it so that all files created by gapton can be read by apache? (Also, is it at all advisable?)
Thanks.
I found the problem.
In older version of vsftpd, the umask they apply when writing file was by default 022.
In the current version, such default value has been changed to 077. This mask read 4 write 2 and execute 1 for everyone except the owner.
Changing the umask value in the vsftpd.conf file back to 022 has solved my problem. Hope this help future users of vsftpd facing the same issue.
I'm new to .php and servers and all this craziness (and StackOverflow) but I've downloaded Apache and I'm trying to symlink a PHP code folder to the Apache root directory. My Apache root was var/www/html and my PHP code folder is Documents/PHPStuff. I renamed var/www/html to var/www/html2 and I made a symlink in var/www/ called 'html' which links to Documents/PHPStuff, thinking if I renamed the symlink to the name Apache is looking for then it would work.
It doesn't.
When I try to access my test file in Documents/PHPStuff called 'helloworld2.php' in my browser with 'localhost/helloworld2.php' I get a 403 Forbidden Error.
I've been messing with permissions on the symlink and in the PHPStuff directory, changing them to 777 and stuff but it hasn't worked. I also changed my httpd.conf file by changing FollowSymlinks None to FollowSymlinks All. Nothing has worked yet so this was my last resort.
Try to don't touch your http.conf. Instead, edit files from conf.d path.
To grant access to your home paths, edit your /etc/http/conf.d/userdir.conf to activate user dir option, like:
<IfModule mod_userdir.c>
#UserDir disabled
UserDir public_html
</IfModule>
<Directory "/home/*/public_html">
AllowOverride All
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
Require method GET POST OPTIONS
</Directory>
then, restart your apache.
Now, you have to create a directory /home/$USER/public_html and create into it the symlink to your ~/PHPStuff, like
ln -s ~/PHPStuff ~/public_html/PHPStuff
You can move PHPStuff to ~/public_html/ instead create the symlink.
Ensure that your homedir have 711 permissions, public_html have 755 and the dirs and files inside PHPStuff are readable by everyone.
Finally, type into your web browser
http://localhost/~user ('user' is your system username)
and you will see your PHPStuff listed. You can type
http://localhost/~user/PHPStuff
to view the PHPStuff content directly.
Good luck!
You shouldn't need to do all of that.
This is how I set up my symlinks.
When I install apache, it's web directory is located at /var/www/html which doesn't really need to be changed.
Then, I create a folder called public_html, you can call it PHPStuff, doesn't matter. What matters is that the folder is inside your home directory, so /home/your_username/PHPStuff
Then link that directory to /var/www/html
sudo ln -s ~/PHPStuff /var/www/html/$USER
You can then access ~/PHPStuff by going to your browser, and typing:
http://localhost/your_username
Which will give you access to ~/PHPStuff
After you do that, set proper permissions:
sudo chmod -R 777 ~
Then make sure apache allows symlinks by going to /etc/httpd/conf/httpd.conf and editing this portion Directory "/var/www/html"
And make sure you have these:
Options Indexes FollowSymLinks
AllowOverride All
Restart apache and everything will work.
You need to make sure apache has access to the folder that the symlink is pointing to, try running:
chmod a+x /home/your-username /home/your-username/Documents/PHPStuff