By rubioli
I have a droplet which I have Ubuntu 20.04 (LTS) x64, Nginx, and passenger. Currently, I’m running a Rails app in it. I was wondering how and if I’m able to run Rails alongside PHP script on the same server.
What I’m looking for is to have Rails app in domain.com and the PHP as domain.com/php-here
Thanks in advance
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi @rubioli,
You’ll need to configure this in your domain’s Nginx configuration file. You can add something like the following to make your configuration work:
location /php-folder {
try_files $uri $uri/ /index.php;
# process PHP here
location ~* ^/(.*\.php)$ {
# directives to process PHP
}
}
If you just want to proccess .php files in your main folder, you can just add the following
# process PHP here
location ~* ^/(.*\.php)$ {
# directives to process PHP
}
In your main location block.
Regards, KFSys
Thanks a lot @KFSys do I need to add this is the same ngnix config file I have for my rails? and what do I need to add in the directives to process PHP?
Thanks in advance!
With my user I did sudo vim /etc/nginx/sites-enabled/domainname
and I have:
server {
listen 80;
listen [::]:80;
server_name domain.com;
root /home/deploy/domain/current/public;
passenger_enabled on;
passenger_app_env production;
location /cable {
passenger_app_group_name lustsnaps_websocket;
passenger_force_max_concurrent_requests_per_process 0;
}
# Allow uploads up to 100MB in size
client_max_body_size 200m;
location ~ ^/(assets|packs) {
expires max;
gzip_static on;
}
# process PHP here
location /php {
try_files $uri $uri/ /index.php;
# process PHP here
location ~* ^/(.*\.php)$ {
# directives to process PHP
}
}
}
Is this what you mean?
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.