I have two laravel apps that I wish to put on a live Apache server. The os is CentOs. I have followed this toturial to set up a virtual host: https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-centos-7
When I try to visit my links, http://lara.ci/public/ , all I get is 404 Not Found. Below is my sites-available file:
<VirtualHost *:80>
ServerName www.lara.ci
ServerAlias lara.ci
DocumentRoot /var/www/lara.ci/public_html/public
ErrorLog /var/www/lara.ci/error.log
CustomLog /var/www/lara.ci/requests.log combined
</VirtualHost>
Files for the app is in public_html folder. I even tried the approach below after searching all over but can't get it to work:
Set the following in httpd.conf
<Directory />
AllowOverride All
</Directory>
My .htaccess file in public seems to be working because when I try something like below, I get the redirection. Also mod_rewrite is enabled:
<IfModule mod_rewrite.c>
Redirect 301 / https://google.com
...
Appreciate assistance
是正确的,尽管您的document_root已经指向公共子文件夹,但您仍将转到http://lara.ci/public吗?
The problem is in the fact that you are pointing the document root to:
DocumentRoot /var/www/lara.ci/public_html/public
Its should be:
<VirtualHost *:80>
ServerName www.lara.ci
ServerAlias lara.ci
DocumentRoot /var/www/lara.ci/public_html
ErrorLog /var/www/lara.ci/error.log
CustomLog /var/www/lara.ci/requests.log combined
</VirtualHost>
After digging around, I realise that my hidden files didn't copy such as .env, .gitignore etc since I was using the cp
command to copy my files. To fix the problem, I ran the command like below (Source: https://superuser.com/questions/61611/how-to-copy-with-cp-to-include-hidden-files-and-hidden-directories-and-their-con ):
cp -r /var/www/html/lara/.[^.]* /var/www/lara.ci/public_html
which effectively copied all my hidden files and everything is working smoothly.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.