I have the problem that when I want to run the PHP script it does not run  File Structure  /home/myapp/landing * contact.php * index.html   NGINX Conf  location / {     alias /home/myapp/main; }  location /landing-page {      alias /home/myapp/landing/;       location ~ \.php$ {           try_files $uri =404;           fastcgi_split_path_info ^(.+\.php)(/.+)$;           fastcgi_pass unix:/path/to/php.sock;           fastcgi_index index.php;           fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;           #also tried this           #fastcgi_param SCRIPT_FILENAME /home/myapp/landing$fastcgi_script_name;           include fastcgi_params;      } }
122449
I have an app behind nginx. But i need a specific path in this app redirect to a Wordpress Blog  Example :  example.com/       -------> Redirect to my app  example.com/whatever/  -------> Redirect to my app too  example.com/blog/  ------->Redirect to my Wordpress Blog  So, I add a location matching this sub-path  server {         listen 80 default_server;          index index.php;          server_name _;          location ^~ /blog {                 root /path/to/my/blog;                 index index.php index.html;                  location ^~ /blog/(.*\.php)$ {                    fastcgi_pass   127.0.0.1:9000;                    fastcgi_index index.php;                    fastcgi_param  SCRIPT_FILENAME  /path/to/my/blog/$fastcgi_script_name;                    include fastcgi_params;                 }         }          location ~* /(.*) {                 #here the conf for the rest of the website         } }   And when i try to get the page, i have a 404 with this eror in the logs :   2016/05/22 15:27:24 [error] 21759#0: *1 open() "/path/to/my/blog/blog/index.php" failed (2: No such file or directory), client: XX.XX.XX.XX, server: _, request: "GET /blog/index.php HTTP/1.1", host: "example.com"   With /blog is duplicate.  How i can fix this ?  EDIT :   Now i have this (Thanks to Richard Smith) :   location ^~ /blog {                 root /path/to/my/;                 index index.php;                 try_files $uri $uri/ /blog/index.php;                  location ~ \.php$ {                         try_files $uri =404;                         include fastcgi_params;                         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;                         fastcgi_pass   127.0.0.1:9000;                 }         }   But now, i got index.php event if i try to ge another file (toto.html for example)  If i replace              try_files $uri $uri/ /blog/index.php;   with              try_files $uri $uri/;   I got a 404 with  2016/05/22 20:57:21 [error] 22621#0: *1 "/path/to/my/blog/toto.html/index.php" is not found (20: Not a directory), client: 84.98.248.33, server: _, request: "GET /blog/toto.html/ HTTP/1.1", host: "example.com"   in the logs  EDIT 2  :   The file exist and currently, and i give it 777 rights (i will remove them later before go to production):   drwxrwxrwx  2 user group 4096 May 22 20:36 . drwxr-xr-x 11 user group   4096 May 23 06:20 .. -rwxrwxrwx  1 user group  126 May 22 13:30 index.php -rwxrwxrwx  1 user group  102 May 22 10:25 old.index.html -rwxrwxrwx  1 user group   12 May 22 12:24 toto.html   Thank you fo your patience !
10696
I've tried it a 100 times I'm really new to Ubuntu and ended with a bunch of error that I don't even understand can any one please help me??  Here is what I did:   I installed PHP  I installed libcurl then php5-dev I tried installing PECL extension and it says PHPIZE not found.
39114
I can't notice any difference if in my config file I set   fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;   Or:   fastcgi_param  SCRIPT_FILENAME    $request_filename;   What do they do respectively? Is one of the two better than the other?  Thanks in advance.
78999
I have a brand new VM with CenotOS 7 Minimal Installation.  What I want to happen is to configure Nginx to serve static files from a directory on localhost:80.  My directory is /home/kenny/projects/kcrypt/dist/.  Here are the contents of my /etc/nginx/nginx.conf:  # this is set to root in order to rule out # any permission related issues. user root;      worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid;  include /usr/share/nginx/modules/*.conf;  events {     worker_connections 1024; }  http {     log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '                       '$status $body_bytes_sent "$http_referer" '                       '"$http_user_agent" "$http_x_forwarded_for"';      access_log  /var/log/nginx/access.log  main;      sendfile            on;     tcp_nopush          on;     tcp_nodelay         on;     keepalive_timeout   65;     types_hash_max_size 2048;      include             /etc/nginx/mime.types;     default_type        application/octet-stream;      server {         listen       80 default_server;         listen       [::]:80 default_server;         root         /home/kenny/projects/kcrypt/dist/;         index index.html;          location / {         }     } }   when I run curl http://localhost I get this response:  &lt;html&gt; &lt;head&gt;&lt;title&gt;403 Forbidden&lt;/title&gt;&lt;/head&gt; &lt;body bgcolor="white"&gt; &lt;center&gt;&lt;h1&gt;403 Forbidden&lt;/h1&gt;&lt;/center&gt; &lt;hr&gt;&lt;center&gt;nginx/1.12.2&lt;/center&gt; &lt;/body&gt; &lt;/html&gt;   I have tried giving all kinds of permissions to any directories that I can think of.   In the end I configured Nginx to run as root.   I have reinstalled the OS multiple times already and can't get it to work.   P.S.   This is what I found in /var/log/nginx/error.log  2018/02/27 21:33:19 [error] 15689#0: *1 open() "/home/kenny/projects/kcrypt/dist/index.html" failed (13: Permission denied), client: ::1, server: , request: "GET / HTTP/1.1", host: "localhost" 2018/02/27 21:33:35 [error] 15690#0: *2 open() "/home/kenny/projects/kcrypt/dist/index.html" failed (13: Permission denied), client: 127.0.0.1, server: , request: "GET / HTTP/1.1", host: "127.0.0.1" 2018/02/27 21:33:38 [error] 15690#0: *3 open() "/home/kenny/projects/kcrypt/dist/index.html" failed (13: Permission denied), client: ::1, server: , request: "GET / HTTP/1.1", host: "localhost"   I don't get what it wants... I have given it all the permissions that I can.   This is what I have in the root directory:  [root@vm3 dist]# ll total 368K drwxrwxrwx. 2 root root   98 Feb 26 23:16 . drwxrwxrwx. 6 root root  234 Feb 27 21:26 .. -rwxrwxrwx. 1 root root 1.2K Feb 26 23:16 favicon.ico -rwxrwxrwx. 1 root root 1.7K Feb 26 23:16 index.html -rwxrwxrwx. 1 root root 175K Feb 26 22:53 index.js -rwxrwxrwx. 1 root root  297 Feb 26 23:16 manifest.json -rwxrwxrwx. 1 root root 179K Feb 26 22:53 styles.css   P.S. 2  I have tried putting my static files in /var/www/kcrypt/dist/, but with no result.  I still get the same error messages:   2018/02/27 23:18:11 [error] 16157#0: *1 open() "/var/www/kcrypt/dist/index.html" failed (13: Permission denied), client: ::1, server: , request: "GET / HTTP/1.1", host: "localhost" 2018/02/27 23:20:58 [error] 16535#0: *1 open() "/var/www/kcrypt/dist/index.html" failed (13: Permission denied), client: ::1, server: , request: "GET / HTTP/1.1", host: "localhost" 2018/02/27 23:21:30 [error] 16564#0: *1 open() "/var/www/kcrypt/dist/index.html" failed (13: Permission denied), client: ::1, server: , request: "GET / HTTP/1.1", host: "localhost"
23308
I have about 10 php.ini files on my system, located all over the place, and I wanted to quickly browse through them. I tried this command:  locate php.ini | xargs vi   But vi warns me Input is not from a terminal and then the console starts getting really weird - after which I need to press :q! to quit vi and then disconnect from the ssh session and reconnect to have the console behave normally again.  I think that I sort of understand what's happening here - basically the command hasn't finished when vi started so the command maybe hasn't finished and vi doesn't think that the terminal is in normal mode.  I have no idea how to fix it. I have searched Google and also unix.stackexchange.com with poor luck.
114119
Where should I put systemd file for e.g. Nginx nginx.service or something like that on Ubuntu 16.04 ?
91040
I wrote a PHP code like this  $site="http://www.google.com"; $content = file_get_content($site); echo $content;   But when I remove "http://" from $site I get the following warning:     Warning:   file_get_contents(www.google.com)   [function.file-get-contents]: failed   to open stream:   I tried try and catch but it didn't work.
83792
Here is the directory structure  /domain.com  /public_html   /functions   /image   /mobile   /www   the /domain.com/public_html/www folder has a file index.php the default web directory is /user/public_html/www in the index file is an include that includes the functions with include"../functions/function.inc" this works without problem when I want to link to a picture in the image folder I don't get any results for example   &lt;img src="../image/graphic/logo.gif" alt="alt text"/&gt;   Does anybody has any idea why the link to the image does not work and how to link correctly to the image file ?  I tried &lt;img src="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;../image/graphic/logo.gif" alt="alt text"/&gt;  but that gives me the same result when I build a link around the image to get to the properties I get this as path  the path should be   when I try to browse directly to this url  I get an 404 file not found error because the default web directory is /domain.com/public_html/www I tried  to get to the image folder but that does not help neither.  Anybody any ideas or is it impossible to html link to graphical files outside the default web directory ?  thanks for reading this far  Thanks for the answers so far. I will try to solve my problem with one of the recommended solutions and report my working solution back here. I wanted to have the image folder at the same level as the www and mobile folder because some of the images used for the pc (www) version and the mobile version are the same. Of course it is easier to just get an image folder in the www and in the mobile folder and I think that is what I am going to do.  thank you everybody for the advice. The main reason why I am not going to work with a script is that a script will be a difficult solution to an easy problem and also because I don't really see how you can wrap your image in a css class and how to provide alt text for an image.
20779
I am building a PHP application in CodeIgniter. CodeIgniter sends all requests to the main controller: index.php. However, I don't like to see index.php in the URI. For example, http://www.example.com/faq/whatever will route to http://www.example.com/index.php/faq/whatever. I need a reliable way for a script to know what it's address is, so it will know what to do with the navigation. I've used mod_rewrite, as per CodeIgniter documentation.  The rule is as follows:  RewriteEngine on RewriteCond $1 !^(images|inc|favicon\.ico|index\.php|robots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L]    Normally, I would just check php_self, but in this case it's always index.php. I can get it from REQUEST_URI, PATH_INFO, etc., but I'm trying to decide which will be most reliable. Does anyone know (or know where to find) the real difference between PHP_SELF, PATH_INFO, SCRIPT_NAME, and REQUEST_URI? Thanks for your help!  Note: I've had to add spaces, as SO sees the underscore, and makes it italic for some reason.   Updated: Fixed the spaces.
114897
How do I actually run a file on localhost? I know it is working, but how do I run a file on it, and how do I verify that the file is in fact running on localhost?  Server newbie here, additional questions (I have xampp running Apache 2.2): From your responses it sounds like I have to type in the path in the browser in order to open the file on the localhost. So, if I want to have the file in a subdirectory, I would have to type the full path including the directory?   Is there a way to have the browser point to the localhost while I am working on my html, instead of having to type in the path all the time?  I am working in Dreamweaver CS3, and want to use include commands (either SSI or PHP), but not have to keep putting my files up on HostGator in order to see if they are working.  What is the best way to do this (please be specific, I know nothing). If there is a detailed tutorial anywhere, really appreciate a link.  Thank you
53089
I am currently trying to locate the correct php.ini file to edit it and restart apache so the changes will take place and I'm stumped.  I have found three different php.ini files (no idea why there are three)  this is how I found the files  $ sudo find / -name php.ini /etc/php5/cli/php.ini /etc/php5/apache2/php.ini /etc/php5/cgi/php.ini   I also did....  $ sudo php -i | grep 'Configuration File' Configuration File (php.ini) Path =&gt; /etc/php5/cli Loaded Configuration File =&gt; /etc/php5/cli/php.ini   I changed all of them (just to be sure) to the settings I wanted.  I restarted apache using  sudo service apache2 restart   The results...  * Restarting web server apache2   I reloaded the page and it showed that the php.ini file was not updated.  I know this because I used  echo ini_get('post_max_size');   Which was supposed to be changed to 20M but was still only 2M  I tried rebooting my computer thinking maybe that would stop the apache server and reload the php.ini file with the correct setting, but alas that attempt also failed.  Is there any chance there could be another php.ini file that could be interfering?
89463
I downloaded the latest  and installed it.  But apparently, there is no /var/www folder.  Can anyone tell me the default location of the Apache's DocumentRoot directory within XAMPP installation?
116219
My first time using Nginx, but I am more than familiar with Apache and Linux. I am using an existing project and when ever I am trying to see the index.php I get a 404 File not found.  Here is the access.log entry:  2013/06/19 16:23:23 [error] 2216#0: *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.ordercloud.lh"   And here is the sites-available file:  server {     set $host_path "/home/willem/git/console/www";     access_log  /www/logs/console-access.log  main;      server_name  console.ordercloud;     root   $host_path/htdocs;     set $yii_bootstrap "index.php";      charset utf-8;      location / {         index  index.html $yii_bootstrap;         try_files $uri $uri/ /$yii_bootstrap?$args;     }      location ~ ^/(protected|framework|themes/\w+/views) {         deny  all;     }      #avoid processing of calls to unexisting static files by yii     location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {         try_files $uri =404;     }      # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000     #     location ~ \.php {         fastcgi_split_path_info  ^(.+\.php)(.*)$;          #let yii catch the calls to unexising PHP files         set $fsn /$yii_bootstrap;         if (-f $document_root$fastcgi_script_name){             set $fsn $fastcgi_script_name;         }          fastcgi_pass   127.0.0.1:9000;         include fastcgi_params;         fastcgi_param  SCRIPT_FILENAME  $document_root$fsn;          #PATH_INFO and PATH_TRANSLATED can be omitted, but RFC 3875 specifies them for CGI         fastcgi_param  PATH_INFO        $fastcgi_path_info;         fastcgi_param  PATH_TRANSLATED  $document_root$fsn;     }      location ~ /\.ht {         deny  all;     } }   My /home/willem/git/console is owned by www-data:www-data (my web user running php etc) and I have given it 777 permissions out of frustration...  My best guess is that something is wrong with the config, but I can't figure it out...  UPDATE So I moved it to /var/www/ and used a much more basic config:  server {     #listen   80; ## listen for ipv4; this line is default and implied     #listen   [::]:80 default ipv6only=on; ## listen for ipv6      root /var/www/;     index index.html index.htm;      # Make site accessible from http://localhost/     server_name console.ordercloud;      location / {         root           /var/www/console/frontend/www/;                 fastcgi_pass   127.0.0.1:9000;                 fastcgi_index  index.php;                 fastcgi_param  SCRIPT_FILENAME  /var/www;             include        fastcgi_params;     }      location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {             try_files $uri =404;         }      location /doc/ {         alias /usr/share/doc/;         autoindex on;         allow 127.0.0.1;         deny all;     }  }   Also if I call localhost/console/frontend/www/index.php I get a 500 PHP which means it is serving there. It just isn't serving off console.ordercloud ...
110634
I'm trying to move an existing Bedrock based multisite instance to nginx and am having difficulty getting a set of nginx rules to mimic the original .htaccess. Bedrock places the crux of the files in a wp/ subdirectory, but the urls still need to be accessible from the root domain.  The .htaccess is here as follows:  RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L]  # add a trailing slash to /wp-admin RewriteRule ^wp-admin$ wp-admin/ [R=301,L]  RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule ^(wp-(content|admin|includes).*) wp/$1 [L] RewriteRule ^(.*\.php)$ wp/$1 [L] RewriteRule . index.php [L]   I need these at least as nginx conf rules or preferably nginx vhost rules.
118241
I'm trying to set up my environment such that surveyadmin.local points at one directory and surveyadmin.local/api points at another.  However, no matter what I change, the /api URL always results in a call to the directory that surveyadmin.local is pointing at. Here's a sample error from the error log specified in the vhost config:  2013/08/09 17:20:07 [error] 8911#0: *1 open() "/srv/http/surveytool/admin/build/app.php" failed (2: No such file or directory), client: 10.0.2.2, server: surveyadmin.local, request: "GET /api/organizations HTTP/1.1", host: "surveyadmin.local"   Note that the error refers to a path of /srv/http/surveytool/admin/buid/, instead of the /srv/http/surveytool/api/SurveyTool/web/ that was expected.  Here's my config for the vhost in question:  server {     listen 80;     server_name surveyadmin.local;      location / {         root /srv/http/surveytool/admin/build;         index index.html;     }      location /api {         root /srv/http/surveytool/api/SurveyTool/web;         index app.php;         try_files $uri $uri/ /app.php?$query_String;         location ~ \.php(?|$) {             fastcgi_pass unix:/var/run/php5-fpm.sock;             fastcgi_index app.php;             fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;             include /etc/nginx/fastcgi_params;         }     }     access_log  /var/log/nginx/surveyadmin.access.log;     error_log   /var/log/nginx/surveyadmin.error.log debug; }   I have tried changing the word "root" to "alias" under the location /api block. I've tried setting up a second virtual host and doing a proxy forward (with proxy_pass) to that vhost.  This seems like it shouldn't be that difficult, so I'm assuming my error is a simple one that I just haven't seen yet.  Can anyone spot any obvious problems with the above config?
74054
I have installed Apache(LAMP) web server on my ubuntu machine and I want to do the above mentioned thing.I have tried creating symbolic links in the /var/www directory but it only shows files but not directories inside the directory linked.I want to redirect /var/www to my home folder so that I can access all the files and directories contained therein.Please help me.
101940
I just installed appache, MySQL and PHP, suring my installation, I was prompted for a MySQL root user password, but when I start my MySQL, it pops the error, and I just can't seem to find a way around it, most solutions I've read doesn't solve it, moreover, I found out that the /var/run/mysqld path doesn't even exist, my php also needs the socket to connect to my Database.