I want to install my vps to develop multiple websites at the same time.
My root directory structure:
/var/www/html/web1;
/var/www/html/web2;
/var/www/html/wordpress1;
/var/www/html/wordpress1;
/var/www/html/drupal1;
/var/www/html/drupal2;
I want to link to the website http://123.123.123.123/drupal1 and 123.123.123.123 is the IP of the VPS.
Now whenever I add a website I have to edit the config file. Is there a way to install it for every page?
Here is my nginx config:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html index.php;
server_name _;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location #sub_rewrite {
rewrite ^/drupal1/(.*)$ /drupal1/index.php?$1;
}
location /drupal1/ {
try_files $uri #sub_rewrite;
}
}
Thanks everyone!
Related
I have a react website which I am serving using NGINX. I wanted to create a blog for the same. So I tried to use wordpress in a sub-directory.
`
server {
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name domain.com;
location / {
try_files $uri $uri/ =404;
}
location ^~ /blog {
client_max_body_size 10m;
if (!-f $request_filename) {
rewrite [^/]$ $uri/ permanent;
}
try_files $uri $uri/ /index.php?$args;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^/wordpress(/.+\.php)(.*)$;
include fastcgi.conf;
fastcgi_index index.php;
fastcgi_pass unix:/run/php/php8.1-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
include fastcgi_params;
}
}
listen [::]:443 ssl ipv6only=on;
listen 443 ssl;
#ssl certificates here
}
`
After hours of reading docs, blogs and stack I got my homepage set up. However all my pages on the blog are returning 404. I am attaching my nginx config.
My directory structure is
/var/www/html/ : root folder for my react website
/var/www/html/blog : root folder for my wordpress ( no /wordpress subfolder present)
Add this lines
location /blog {
try_files $uri $uri/ /blog/index.php?$args;
}
location ~ \.php$ {
fastcgi_split_path_info ^(/blog
}
I'm getting a 404 error after install phpMyAdmin using Digital Ocean's guide. I have multiple domains setup on Ubuntu running nginx. There is a phpmyadmin directory within /var/www/. The only difference from the guide was the following command:
sudo ln -s /usr/share/phpmyadmin/ /var/www
Do I need to add server block possibly? Since I have multiple domains, each of them has a separate configuration file.
Sample config file:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/domain1.com/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name MY_IP_ADDRESS;
location / {
try_files $uri $uri/ =404;
}
location /phpmyadmin {
root /var/www/;
index index.php index.html;
}
location ~ \.php$ {
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
include fastcgi_params;
try_files $uri /index.php;
}
location ~ /\.ht {
deny all;
}
}
I'm not great at server administration. Any suggestions?
Define this server block it worked for me.
A basic configuration for phpmyadmin in you case.As you have created a symbolic link in /var/www.
sudo ln -s /usr/share/phpmyadmin/ /var/www
server {
listen 80;
server_name website.in www.website.in;
autoindex on;
location /phpmyadmin {
root /var/www/;
index index.php index.html;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
include fastcgi_params;
try_files $uri $uri/ /index.php;
}
}
location / {
root /var/www/your/path;
index index.php index.html;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
include fastcgi_params;
try_files $uri $uri/ /index.php;
}
}
}
I am creating server block in sites-available nginx. I have 2 server name it works fine if access to browser but in mobile it will show the i.p address and it will load the first app, I cannot load the my second app because If I dial in url mysecondsubdomain.mydomain.com it will redirect to i.p address and the first app will be serve.. I don't know why it behaves like this
updated : I noticed also in browser after few hours when I type mysecondsubdomain.mydomain.com i will be redirected to i.p adress and it will serve my first app
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/banking/public/;
index index.php index.html index.htm;
server_name banking.mydomain.com;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_pass unix:/var/run/php/php5.6-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
server {
listen 80;
listen [::]:80;
root /var/www/inventory/public/;
index index.php index.html index.htm;
server_name inventory.mydomain.com;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_pass unix:/var/run/php/php5.6-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
I am trying to add a subdomain along side my existing website setup.
I have added the following server block to my nginx configuration located at /etc/nginx/sites-available/default.
server {
listen 80;
server_name stats.website.org;
root /var/www/piwik;
index index.php index.html;
location / {
try_files $uri $uri/ =404;
}
}
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/html/existing_website/public;
index index.php index.html;
server_name website.org;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
I am getting a ERR_NAME_NOT_RESOLVED error when I try stats.website.org.
Can anyone advise where I am going wrong.
Thanks in advance.
I have a problem with my nginx configuration.
On most of pages and google search entries i found things like "nginx and symfony2" or "nginx and symfony2 in subdirectory".
But i not find some thing about this configuration:
Normal php file projects (path like localhost/project -> /srv/www/project/index.php / ruled per index)
Symfony2 projects (path like localhost/symfony2 -> /srv/www/symfony2/web/app.php (default) and manually app_dev.php / unknown!?)
Current configuration
server
{
listen 80;
listen [::]:80 default_server ipv6only=on;
root /srv/www;
index index.php index.html index.htm app.php app_dev.php;
try_files $uri $uri/ index.php #rewriteapp /index.php;
server_name localhost;
location ~ ^\/symfony2
{
#rewrite ^\/symfony2(.*)$ /symfony2/web$1 last;
#root /srv/www/symfony2/web;
alias /srv/www/symfony2/web;
}
location #rewriteapp
{
rewrite ^(.*)$ /app.php/$1 last;
}
location ~ \.php(/|$)
{
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
Thank's in advance for each tip!
This configuration should help.
server {
listen 80;
listen [::]:80 default_server ipv6only=on;
root /srv/www;
index index.php index.html index.htm app.php app_dev.php;
server_name localhost;
location / {
try_files $uri $uri/ /app.php /index.php;
location ~ .*\.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
location /symfony2 {
alias /srv/www/symfony2/web;
location ~ .*\.php(/|$) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ /symfony2(?<path>.*)$ {
root /srv/www/symfony2/web;
try_files $path $path/ /app.php$path;
}
}
}