2

My php apache2 site is configured and ready but somehow I keep getting the default page.

sworup@sandwitchslayer:/etc/apache2/sites-enabled$ ls -l
total 0
lrwxrwxrwx 1 root root 34 Sep 17 00:38 sworup.com.conf -> ../sites-available/sworup.com.conf
sworup@sandwitchslayer:/etc/apache2/sites-enabled$ cat sworup.com.conf
<VirtualHost *:80>

    ServerName sworup.com.np
    ServerAlias sworup.com.np

    ServerAdmin sworup@sworup.com.np
    DocumentRoot /home/sworup/Code/sworup.com/current/public

    <Directory /home/sworup/Code/sworup.com/current/public>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
    </Directory>

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

  </VirtualHost>
hjpotter92
  • 78,589
  • 36
  • 144
  • 183
Sworup Shakya
  • 1,328
  • 3
  • 16
  • 44
  • Have you tried disabling apparmor and restarting Apache? This could be a permissions thing. If that works you will need to properly configure apparmor to allow apache to read rom a non-standard folder. – JasonD Sep 16 '16 at 19:20
  • ALternately, or course, you could check your logs to see if there are any apparmor error messages. – JasonD Sep 16 '16 at 19:20
  • I stopped apparmor, restared apache and still showing default page – Sworup Shakya Sep 16 '16 at 19:23
  • Any errors in httpd log file? Have you tried starting httpd up manually to see if there are any uncaught errors? If so, please post. – JasonD Sep 16 '16 at 19:25
  • root@sandwitchslayer:/var/log/apache2# cat error.log [Sat Sep 17 01:26:34.374591 2016] [mpm_prefork:notice] [pid 27897] AH00163: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations [Sat Sep 17 01:26:34.374625 2016] [core:notice] [pid 27897] AH00094: Command line: '/usr/sbin/apache2' – Sworup Shakya Sep 16 '16 at 19:42
  • Do you have an index.html file in the folder? I seem to remember that Ubuntu will display a default page if there is none. An empty index.html file (or one with simple text) will do the job. – JasonD Sep 16 '16 at 19:46
  • added index.html still not showing – Sworup Shakya Sep 16 '16 at 19:57
  • Stupid question perhaps, but have you restarted apache after making the conf file changes? – JasonD Sep 16 '16 at 20:03
  • And the dns entry is pointing to the correct server, right? It's currently pointing to 45.55.83.211 – JasonD Sep 16 '16 at 20:07
  • Where do I check that? – Sworup Shakya Sep 16 '16 at 20:11
  • I checked it for you - it's pointing to the IP 45.55.83.211. Is that the IP of the server you are working on? – JasonD Sep 16 '16 at 20:11
  • yes, its digital ocean vm – Sworup Shakya Sep 16 '16 at 20:12
  • OK, try this: Add "Listen 8091" above the virtualhost section, then change the "*:80" to "*:8091". Restart the server and check if apache is listening on port 8091 (netstat -tnlp | grep 8091) (turn apparmor off again, pls) – JasonD Sep 16 '16 at 20:16
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/123569/discussion-between-jasond-and-sworup-shakya). – JasonD Sep 16 '16 at 20:16
  • Please do not forget to select an answer if one of them solved your problem. If neither helped, perhaps also consider upvoting answers that helped you to find a solution, and add your own solution as an answer. – JasonD Sep 19 '16 at 18:14

2 Answers2

0

OK, edit your conf file and change the port back to *:80. Delete the new listen line.

Then edit your "000-default.conf" file (should be in sites-enabled) and REMOVE all references to sworup.com.np. ONLY your sworop.com.conf virtualhost file should have it listed.

Restart apache and you should be good to go. Remember to follow all these steps. I'm off to bed, if this doesn't work (I'm confident it will) then I will try to help again tomorrow.

Have a great [insert timezone appropriate time period here].

JasonD
  • 114
  • 6
0

Just listing out the issues based on your comments and conversations, both here and in the chats.

  1. Disable your default apache2 virtual host!

    sudo a2dissite 000-default.conf
    
  2. Check your apache's root server configurations and comment out the DocumentRoot directive there.
  3. Use a VHostUser directive in your VHost config as you're serving the files from another user's account, who may/may not grant access to the www-data user.
  4. I'd also recomment changing the log files from default to instead be something named similar to your chost/domain itself. Checking them is easier that way ;-)
  5. Change the server's listening port back to 80. The final VHost config should be as follows

<VirtualHost *:80>

    ServerName sworup.com.np
    ServerAlias sworup.com.np

    VHostUser sworup
    VHostGroup sworup

    ServerAdmin sworup@sworup.com.np
    DocumentRoot /home/sworup/Code/sworup.com/current/public

    <Directory /home/sworup/Code/sworup.com/current/public>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/sworup.com.np-error.log
    CustomLog ${APACHE_LOG_DIR}/sworup.com.np-access.log combined

</VirtualHost>
hjpotter92
  • 78,589
  • 36
  • 144
  • 183