Laravel 5 and Wordpress 4.1.1 in the same server

2019-08-01 06:46发布

this is the first time I try this and after a day of trying I am stuck. I do not have a lot of experience with Ubuntu so perhaps I missed something obvious.

I am trying to install WP (latest) and Laravel 5 on to an Ubuntu 14.04 installation in Virtual Box. I want both to work side by side since WP will take care of the web site side of things and the web app will be based on Laravel 5.

The result is Wordpress works OK but when I go to http://domain.com/app I get a blank page and the infamous 500 error:

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

What have I missed. Thanks!

The directory structure:

/etc/var/www/public_site - Public web site (WordPress is installed here)

/etc/var/www/ (Laravel 5 installed here)

/etc/var/www/public_site/wp-admin, 
                         wp-content, 
                         wp-includes  
                         app (as Laravel public folder)

After reading multiple forum posts, this is what I have done:

.htaccess in /public_site/ contains:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/app [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

.htaccess in /public_site/app contains:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /app/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>  

/etc/apache2/sites-enabled/000-default.conf (and same for sites-available)

<VirtualHost *:80>
        ServerName 10.0.0.204
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/public_site

        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

1条回答
贼婆χ
2楼-- · 2019-08-01 07:28

I think the best solution is to install them in a separate folder.

E.g.:

/etc/var/wordpress

and

/etc/var/laravel

Then, the main domain will point to /etc/var/wordpress and you can create a subdomain that will point to laravel, e.g.:

domain.com      --> /etc/var/wordpress
app.domain.com  --> /etc/var/laravel

I think you should not install them in the same folder, that will make the mainteinance a nightmare

查看更多
登录 后发表回答