LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 09-20-2015, 10:43 PM   #1
luofeiyu
Member
 
Registered: Aug 2015
Posts: 237

Rep: Reputation: Disabled
Why wordpress can work only on nginx but not apache2 ?


I have built wordpress on nginx and apache2 .
1.close apache2 and start nginx.

The wordpress work when to input 127.0.0.1:8080/wp in the firefox.

Here is my nginx config file.
Code:
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
	worker_connections 768;
}
http {
        server {
        listen 8080;
        server_name localhost;
        index index.html index.htm index.php;
        root /var/www/html;
        location / {
            try_files $uri $uri/ /index.html;
        }
        error_page 404 /404.html;
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
            root /usr/share/nginx/html;
        }
        location ~ \.php$ {
            try_files $uri =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;
        }
    }
	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;
	ssl_prefer_server_ciphers on;
	access_log /var/log/nginx/access.log;
	error_log /var/log/nginx/error.log;
	gzip on;
	gzip_disable "msie6";
	include /etc/nginx/conf.d/*.conf;
	include /etc/nginx/sites-enabled/*;
}
2.close nginx and start apache2.
The wordpress can't work when to input 127.0.0.1:8080/wp in the firefox.
Here is the apache2 config file.
cat /etc/apache2/sites-available/000-default.conf
Code:
<VirtualHost *:8080>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
cat /etc/apache2/ports.conf
Code:
Listen 8080
<IfModule ssl_module>
	Listen 443
</IfModule>
<IfModule mod_gnutls.c>
	Listen 443
</IfModule>
3.wordpress ownership
Code:
ls  -al  /var/www/html/wp
total 192
drwxr-xr-x  5 www-data www-data  4096 Sep 21 09:30 .
drwxr-xr-x  4 www-data www-data  4096 Sep 18 15:53 ..
-rwxr-xr-x  1 www-data www-data   418 Aug 10 19:56 index.php
-rwxr-xr-x  1 www-data www-data 19930 Aug 10 19:56 license.txt
-rwxr-xr-x  1 www-data www-data  7360 Sep 16 11:50 readme.html
-rwxr-xr-x  1 www-data www-data  4951 Aug 10 19:56 wp-activate.php
drwxr-xr-x  9 www-data www-data  4096 Aug 10 19:56 wp-admin
-rwxr-xr-x  1 www-data www-data   271 Aug 10 19:56 wp-blog-header.php
-rwxr-xr-x  1 www-data www-data  5007 Aug 10 19:56 wp-comments-post.php
-rwxr-xr-x  1 www-data www-data  2782 Sep 18 19:02 wp-config.php
-rwxr-xr-x  1 www-data www-data  2727 Aug 10 19:56 wp-config-sample.php
drwxr-xr-x  6 www-data www-data  4096 Sep 18 19:19 wp-content
-rwxr-xr-x  1 www-data www-data  3115 Aug 10 19:56 wp-cron.php
drwxr-xr-x 12 www-data www-data  4096 Aug 10 19:56 wp-includes
-rwxr-xr-x  1 www-data www-data  2380 Aug 10 19:56 wp-links-opml.php
-rwxr-xr-x  1 www-data www-data  3123 Aug 10 19:56 wp-load.php
-rwxr-xr-x  1 www-data www-data 34241 Aug 10 19:56 wp-login.php
-rwxr-xr-x  1 www-data www-data  8252 Aug 10 19:56 wp-mail.php
-rwxr-xr-x  1 www-data www-data 11048 Aug 10 19:56 wp-settings.php
-rwxr-xr-x  1 www-data www-data 25152 Aug 10 19:56 wp-signup.php
-rwxr-xr-x  1 www-data www-data  4035 Aug 10 19:56 wp-trackback.php
-rwxr-xr-x  1 www-data www-data  3032 Aug 10 19:56 xmlrpc.php
Why wordpress can work only on nginx but not apache2 ?
 
Old 09-21-2015, 06:26 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,154
Blog Entries: 1

Rep: Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019
Quote:
2.close nginx and start apache2.
The wordpress can't work when to input 127.0.0.1:8080/wp in the firefox.
What you mean by "wordpress can't work"? What you get in the browser?
Check the apache error_log and post here any relevant lines
 
Old 09-24-2015, 03:04 AM   #3
luofeiyu
Member
 
Registered: Aug 2015
Posts: 237

Original Poster
Rep: Reputation: Disabled
1.nginx start and apache2 stop.
http://imgur.com/gX2pr7V
2.apache2 start and nginx stop
http://imgur.com/pAJc6Rj

3. log info
cat /var/log/apache2/access.log

127.0.0.1 - - [24/Sep/2015:15:00:32 +0800] "GET /wp/?p=1946 HTTP/1.1" 200 678 "http://127.0.0.1:8080/wp/?p=1924" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36"
127.0.0.1 - - [24/Sep/2015:15:00:35 +0800] "GET /wp/?p=1938 HTTP/1.1" 200 677 "http://127.0.0.1:8080/wp/?p=1924" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36"
127.0.0.1 - - [24/Sep/2015:15:00:40 +0800] "GET /wp/?m=201411 HTTP/1.1" 200 677 "http://127.0.0.1:8080/wp/?p=1924" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36"

Last edited by luofeiyu; 09-24-2015 at 03:41 AM.
 
Old 09-24-2015, 03:18 AM   #4
descendant_command
Senior Member
 
Registered: Mar 2012
Posts: 1,873

Rep: Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643
Don't have everything owned by the webserver user - you will get owned and then start bothering me...
 
Old 09-24-2015, 04:02 AM   #5
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,154
Blog Entries: 1

Rep: Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019
Quote:
2.apache2 start and nginx stop
http://imgur.com/pAJc6Rj
If you get the php code in the browser when using apache, then you don't have php support for apache
To use php for both apache and nginx, you need to install 2 different instances of php. One as a DSO for apache and another as a FastCGI for nginx! I don't know if that's even possible using a distro package manager.
Right now I guess that you have installed only the php-FRM (for nginx), that's why php works on nginx while in apache you get the php code
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: How to install Wordpress with Nginx, MariaDB and HHVM on Debian 8 LXer Syndicated Linux News 0 08-07-2015 04:51 PM
Apache2 Configuration or Wordpress Configuration: Wordpress index.php not loading khun Linux - Newbie 5 05-18-2012 09:26 AM
Nginx Virtual Hosts & Wordpress Rewrite Rules Coburn64 Linux - Server 1 09-15-2010 02:58 PM
wordpress on nginx sandeepthug Linux - Software 1 07-23-2010 12:54 PM
[SOLVED] how to config NGINX for multiple domains with wordpress on Debian? karelkap Linux - Server 1 06-21-2010 12:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 12:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration