Apache 2 start Wordpress instead of standard file - php

how to startup to wordpress instead of standard apache 2 file
I'm a complete noob when it comes to webdevelopment. I decided to find out how it worked a bit.
I created an apache 2 server on my raspberry pi model 3b plus. I installed a mysql database, and installed wordpress under /var/www/html/wordpress. I did it all according to this tutorial online. Only gave my database a different name and so on.
The only thing missing in the tutorial is how to now let my ipadress point to wordpress instead of index.html. My plan is to host a very simple wordpress site on my raspberry pi. And let my domainname point to the ip of the raspberry through a portforward on my router. So I need to start wordpress on the raspberry instead of the standard apache 2 files. Just to clarify extra: when I enter the Rpi adress into my browser now, it directs me to the "it works!" index.html file from apache2. I want it to go to the wordpress site I created when I enter the Rpi's ip adress. So I can go to my DNS host and let the domain name I own point to the outside IP adress of my router with a port, which I then redirect to the pi. I.E. host my own little website for fun.
I looked for the answer on the internet but couldn't really find an answer that explained this. The whole server thing, and hosting your own websites is still a bit vaque to me. As I said, never worked with it before. Any help will be appriciated.

There's a small mistake in the tutorial you followed.
To get things to work so hitting http://203.0.113.114/ where 203.0.113.114 is your machine's local IP address, you must install WordPress in your web server's root directory. The tutorial suggests you install it so you can hit http://203.0.113.114/wordpress to get it. That's not what you want.
The tutorial says to do this.
cp -R wordpress /var/www/html/
Instead you want to do this.
cp -R wordpress/* /var/www/html
That puts WordPress's files in /var/www/html/, not /var/www/html/wordpress/. After you do this, you should be able to say ls -al /var/www/html and see a bunch of files, including among others index.php.
Once you've done that, do the permission-changing stuff in your tutorial again. Then use your web browser to hit
https://10.11.12.13/
and you should get WordPress's setup wizard on your browser. Here are WordPress's own instructions.
Here's the thing to keep in mind: apache exposes a subset of your machine's file system to web browsers. That subset is rooted at the directory /var/www/html/. And also, when you have php installed, apache interprets files like foobar.php not as text, but as php programs. It runs them instead of just sending them to the browser. It's worth your trouble to wrap your brain around these concepts; they're the heart of web server technology.
Again, use your own IP address in place of 203.0.113.114.

You can create virtual host and access site from subdomain for example.
create host file
/etc/apache2/sites-available/wordpress.com.conf
enter
<VirtualHost *:80>
DocumentRoot "/var/www/html/wordpress/"
ServerName wp.localhost
</VirtualHost>
Then enable host with command sudo a2ensite wordpress.com
Then you should be able to access wordpress on subdomain wp.localhost / wp.{yourserveraddress}

Solved
I found the answer with both of the answers from O.jones and Koxo.
I created a new .conf file in /etc/apache2/sites-available called something.com.conf (just to test).
entered this bit of code in there:
<VirtualHost *:80>
DocumentRoot "/var/www/html/wordpress/"
ServerName something.com
</VirtualHost>
After that I did a2dissite 000-default.conf to turn the "old" config off. This is the config that directs you to index.html. Then I did a2ensite something.com which enables the website on the apache server. After that I did: sudo service apache2 restart to restart the service and everything worked.
Thank you O.Jones and Koxo for the help!

Related

Is this possible to create subdomains on local server?

I am working on a project using ZF3 and my requirenment related to local server. Suppose user 'test' login on the system then url for that user should be http://test.10.1.1.55
I have already googled for this and found a post
Create subdomains on the fly with .htaccess (PHP)
For production environment subdomain is working properly but not for development environment. My server guys said to me this is not possible for local server so my question is this posible to create subdomains on local server like as live server?
e.g.
http://test.10.1.1.55
http://test1.10.1.1.55
Note: Local server means I am talking about a system that can be accessed from others system on browser.
If you are using apache on Linux then you would go to
cd /etc/apache2/sites-avaiable/
cp 000-default.conf subname.localhost
nano subname.localhost.conf
Modify DocumentRoot to the root folder of your subdomain
Underneath add
ServerAlias subname.localhost
ServerName subname.localhost
Then remove the entry for:
<Directory /var/www/html>
</Directory>
Save and exit
Then enable your new sub
sudo a2ensite subname.localhost.conf
sudo service apache2 reload
or
sudo service apache2 restart
Re-reading your question you may be able to just use test.localhost instead of the IP.
localhost is the url for your local server by default.
In this case, test.10.1.155 becomes a name, rather than an actual IP address.
You could edit your /etc/hosts file, to add all these named entries, mapped to the same local IP address.
Some additional help about the Hosts file:
https://www.howtogeek.com/howto/27350/beginner-geek-how-to-edit-your-hosts-file/

How to change apache domain name(locally) for a laravel site on ubuntu?

Good day guys in my application I want to change the normal http://127.0.0.1:8000/ that laravel uses to serve sites when one runs php artisan serve to example.com and this should have sub domains like app1.example.com and app2.example.com.
In the main time I have tried to create a virtual host for my site by creating a .conf file inside of etc/apache2/sites-available/example.com.conf and here is how it looks:
<VirtualHost *:80>
ServerAdmin webmaster#example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /home/tangaye/sites/example/public/index.php
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
After doing that I enable the virtual host I created by running sudo a2ensite example.com.conf and sudo service apache2 reload to reload apache2 configuartions and sudo service apachIe2 restart from the on I added the address my site points to in /etc/hosts:
127.0.0.1 localhost example.com
127.0.1.1 tangaye
After doing all this when I run php artisan serve from my laravel site directory I still see my site being launch like this:
Laravel development server started: http://127.0.0.1:8000
After all I have done I expected to rather see this:
Laravel development server started: example.com
The worst thing is when I try to access example.com in my browser it tends to search for it on the internet.
At this point I don't really understand what really I'm doing. All I want is to be able to customize my site domain name LOCALLY and add other sub domains.
Will appreciate any help. Thanks!
You can't specify port numbers in /etc/hosts. There's no way to get around that part.
You should be able to just throw example.com after the localhost definition:
127.0.0.1 localhost example.com
and then it will also resolve to 127.0.0.1 ... then it's just a matter of name-based hosting configurations in Apache. Your file looks pretty good, but DocumentRoot is specifying a folder, not a file. Remember to do an a2ensite to enable your site (it's really just creating a symlink in sites-enabled pointing at the sites-available file) and restart Apache.
To avoid your browser interpreting a web address as a search term, you can prefix it with http://
Note that PHP's built-in development server and Apache are two completely separate ways to serve a PHP webpage/app.
php artisan serve is a rapid development tool, allowing for easy access to a PHP project without the need to set up a full-fledged web server (e.g. Apache). All you need is PHP and you can run Laravel or other PHP projects. (It's also important to note that this should be used for development only, never in production.)
Apache, on the other hand, is a full-featured web server, with all the bells and whistles, including virtual host management. And it works over port 80, so no need to add the port to your URLs.
If you want to use a named URL in your development environment, you should:
Install Apache
Configure Apache, including virtual hosts and PHP configuration.
Modify your hosts file to point your chosen development domain name to your local machine (or the machine serving your app, which could be a Vagrant box, Docker, etc. if you choose to use such tools).
Don't bother using php artisan serve at all.

Owncloud not available after installation on Ubuntu server 14.04

With the goal to install owncloud (version 6.0.3-0) on my ubuntu server (14.04), I followed this guideline:
http://doc.owncloud.org/server/6.0/admin_manual/installation/installation_source.html
After having this completed, the /var/www/owncloud folder exists with the following content:
3rdparty core index.html occ robots.txt themes apps cron.php index.php ocs search version.php config data l10n public.php settings console.php db_structure.xml lib remote.php status.php
Visiting
http://localhost
results in a site like this: https://assets.digitalocean.com/articles/lamp_1404/default_apache.png indicating, that the apache-server works.
Visiting
http://localhost/owncloud
leads to server error 404: "Not Found".
Meanwhile, I tried the installation (owncloud 6.0.3-0) on my laptop (Ubuntu 13.10) to compare results. Skipping the above guidelines, just installing owncloud using the package-manager works out of the box, while the content of /var/www/owncloud results only in config data
Since it works on my laptop, I have the suspect, that I screwed up some configuration on my ubuntu server. Even so, reinstalling apache2 (including purge) did not help.
Do you have any ideas, where to start over?
This is because Apache 2.4's default web root is /var/www/html as opposed to /var/www. ownCloud's default installation ends up in /var/www/owncloud, which is outside of the web root.
I first solved this by creating a symbolic link at /var/www/html/owncloud, but I found it cleaner to simply change Apache's document root to /var/www/owncloud. If you want to preserve the owncloud subdirectory, you can point it to /var/www and get rid of /var/www/html and its contents.
Edit /etc/apache2/sites-enabled/000-default.conf (and/or the appropriate configuration for the SSL site in the same location, depending on your setup) to point DocumentRoot to /var/www or /var/www/owncloud, whichever works for you.
I just figured this out myself, so it may warrant further configuration changes. I will update this post if/when I figure out more tweaks need to be made, but it seems to be working for me, anyway.
Also this has nothing to do with programming and really belongs on superuser.com or perhaps serverfault.com.
This would be more appropriate as a comment as I'm completely clueless as to the solution, but the strange system of SO doesn't allow me to post comments. I have an idea that may not help but just want to confirm that it's not the problem.
Have you tried the following URL?
http://localhost/owncloud/index.html
The first thing that came to mind is that there is a problem with your Default Document settings.
If the above works, you can fix it so you don't have to define the HTML file in the URL by creating a .htaccess file in your server root directory with the contents being:
DirectoryIndex index.php index.html index.htm default.html default.htm home.html
Hope this helps.

Cannot create local copy of Magento

I'm trying to create a copy of an existing Magento website on my localhost for developing purposes.
I followed all the steps listed here: Copy ec2 files to local
I also created a fake domain for my localhost so that there’s a “.” in it as I read somewhere this is required by magento. So now my localhost fake URL is something like: www.mysite.local
I have XAMPP installed on OS X 10.9.1 and I placed the magento filesystem as follows:
/Applications/XAMPP/xamppfiles/htdocs/magento/
In the database I added the local URL as follows:
update core_config_data
set value = ‘http://www.mysite.local/’
where config_id = 6;
and on local.xml I entered the following parameters:
<host><![CDATA[localhost]]></host>
<username><![CDATA[myusername]]></username>
<password><![CDATA[mypassword]]></password>
<dbname><![CDATA[mydatabase]]></dbname>
where localhost is just localhost, myusername is the username for the db I restored on my local XAMPP server, mypassword is the password for that same db, mydatabase is the name of the same db.
Still, when I browse to www.mysite.local/magento/ or www.mysite.local I don’t see anything appear.
What am I doing wrong?
Thank you so much!
If you're using a local server, here's some basic trouble shooting to help you debug:
Firstly, is the local server active? Can you visit http://localhost without it displaying server not found? If you can't, your local server is most not running. Try firing up xampp and launching Apache.
Secondly, it seems you're trying to create a virtual host for your local server. That's great! Virtual hosts allow you to create individual URLs for projects on the same server. E.g. http://myproject.dev.
However, you first need to make sure that the server understands what you're doing.
You will need to create a virtual host in your server if you haven't already.
I see you're using xampp. What you need to do is navigate to your xampp install, and edit your apache/conf/extra/httpd-vhosts.conf file, which is the file xampp recommends you use solely for virtual hosts.
Reading: Setting Up Virtual Hosts for XAMPP
For example, in Apache, a hosts config file may look like this:
# Base
<VirtualHost *:80>
DocumentRoot "X:/"
ServerName localhost
</VirtualHost>
# Project - Some Project of Mine
<VirtualHost *:80>
DocumentRoot "X:/projects/myproject/public"
ServerName myproject.dev
ErrorLog X:/projects/myproject/logs/apache.error.log
CustomLog X:/projects/myproject/logs/apache.access.log common
php_value error_log X:/projects/myproject/logs/php.error.log
</VirtualHost>
(navigating to myproject.dev displays the files in my X:/projects/myproject/public directory)
This answer is not to explain virtual hosts to you however. There are plenty of amazing resources online to help you get started with setting up your own.
Don't forget to restart your server when you add a virtual host!
If this is already set up, is your computer's hosts file set up to point to your server?
Your hosts file on your computer is used to tell it to do certain actions when you enter a matching url in your browser.
Reading: The Hosts File and what it can do for you
Reading: How to Edit Your Hosts File
For example, using the apache conf file settings above, my hosts file must also include:
# My project - Localhost
127.0.0.1 myproject.dev
It tells my computer to send the request to my local server (at localhost) when I use the URL myproject.dev. The local server then picks up the request, sees that you're accessing myproject.dev and checks if it has any virtual hosts matching that name. Well, whaddya know, it does! It then looks at the DocumentRoot setting for the location of the server files, and continues the process. Think of your hosts file as a local DNS of sorts.
If you've just added the site to your hosts file, it may take a few minutes to start resolving correctly. Wait a little, clear your browser cache and try again.
Finally, if these steps are done, and you're receiving nothing, it may be a server configuration problem, or a .htaccess issue.
If you're running on windows, you can check your event log for apache server errors. If you have set up logging on the virtual host, you can check those files to see if it's picking up your requests, and what it's doing with them if it is.
Most issues after that point will at least yield a visible error in your browser (or a blank page).
I hope this helps!
Also checking the magento error logs could tell you what the issue is, assuming it's actually hitting magento at all at this point.
As Sean mentioned above, one of the most common problems I've seen when copying a magento site is accidentally omitting the .htaccess file - make sure it's present in your site root.
If you tested your site before making the change to core_config_data, then you can also try deleting everything in var/cache and var/session. Also make sure that the web user has write permissions on var.
Regards
Hans

Koala-Framework Website doesn't show first page

I got a question about a special php framework called Koala-Framework.
I've set up an apache2 on my virtual ubuntu OS, added a virtual host reserved only for my first website with this cms, also added the hosts entry and followed the tutorial on http://www.koala-framework.org/about/cms/installation , but if I enter the local domain (in my case the configured kwf-cms-demo.localhost), I'm only redirected to see the folder-structure and not the downloaded demo-website...
Which DocumentRoot the virtual hosts needs to be redirecting? (Because I think this could be the root of this problem...)
PS:
/var/www/kwf-cms-demo$ php bootstrap.php setup returns:
Application seems to be set up already. (update file exists)
so, I think the setup has to be finished without any problem...
Seems Apache isn't starting up the bootstrap.php because the rewrite rules in .htaccess are not honored.
Enable mod_rewrite like that:
sudo a2enmod rewrite
Also see point 5 here:
http://www.koala-framework.org/about/server_requirements/ubuntu_example_configuration

Categories