Jump to content

Wordpress and Apache2

Go to solution Solved by ionbasa,
12 minutes ago, Joveice said:

If I change the permalinks in wordpress it makes the website unusable since it cannot find the sites so I'm waiting with this to every setting needed to be configrued is done.

I don't know about mod_rewrite, It's on the default settings since i havent changed that much in the Apache configs

Ahh. You dont have mod_rewrite enabled then.

sudo a2enmod rewrite
sudo service apache2 restart

Then try adjusting the permalinks option again.

 

So how do you configure the URL? if i go the permlinks and just change it from old one /index.php/%postname% to /%postname%/ it cannot view any pages it just says page not found so how do i remove the index.php from the URL?

Back-end developer, electronics "hacker"

Link to comment
https://linustechtips.com/topic/555966-wordpress-and-apache2/
Share on other sites

Link to post
Share on other sites

33 minutes ago, Joveice said:

So how do you configure the URL? if i go the permlinks and just change it from old one /index.php/%postname% to /%postname%/ it cannot view any pages it just says page not found so how do i remove the index.php from the URL?

Not 100% sure with php, but I think it should be done like this?

 

open up your apache2.conf file and change the directory to /index.php/%postname%/
 

 

The directory is relative to whatever global variable you chose when installing apache. For example, on my machine it is "/var/ www/" 

▶ Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning. - Einstein◀

Please remember to mark a thread as solved if your issue has been fixed, it helps other who may stumble across the thread at a later point in time.

Link to comment
https://linustechtips.com/topic/555966-wordpress-and-apache2/#findComment-7324905
Share on other sites

Link to post
Share on other sites

1 minute ago, Joveice said:

cloudflare keep blocking me http://pastebin.com/ncnvPgVe

Create an new virtual host following the guide here: http://httpd.apache.org/docs/2.2/vhosts/name-based.html

Set the documentroot to /var/ www/index.php

PS: Add an space in /var/ www/ to prevent from cloudflare blocking.

▶ Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning. - Einstein◀

Please remember to mark a thread as solved if your issue has been fixed, it helps other who may stumble across the thread at a later point in time.

Link to comment
https://linustechtips.com/topic/555966-wordpress-and-apache2/#findComment-7324970
Share on other sites

Link to post
Share on other sites

8 minutes ago, ionbasa said:

Create an new virtual host following the guide here: http://httpd.apache.org/docs/2.2/vhosts/name-based.html

Set the documentroot to /var/ www/index.php

PS: Add an space in /var/ www/ to prevent from cloudflare blocking.

Already have a virtualhost for it so i tryed editing it and adding /index.php but that just resulted in it saying index.php does not exsist and when visiting the site i could still use it but when trying to access wordpress it dident work :P

Back-end developer, electronics "hacker"

Link to comment
https://linustechtips.com/topic/555966-wordpress-and-apache2/#findComment-7325012
Share on other sites

Link to post
Share on other sites

21 minutes ago, Joveice said:

Already have a virtualhost for it so i tryed editing it and adding /index.php but that just resulted in it saying index.php does not exsist and when visiting the site i could still use it but when trying to access wordpress it dident work :P

Wait, this is for wordpress?

In that case, you'll need to modify Wordpress' Permalinks.  http://codex.wordpress.org/Using_Permalinks#Choosing_your_permalink_structure

 

Also per: http://codex.wordpress.org/Using_Permalinks#Using_.22Pretty.22_permalinks

make sure you have the following setup on Apache:

Quote
  • Apache web server with the mod_rewrite module installed
  • In WordPress's home directory,
    • The FollowSymLinks option enabled
    • FileInfo directives allowed (e.g. AllowOverride FileInfo or AllowOverride All)
    • An .htaccess file (if this file is missing, WordPress will try to create it when you activate "pretty" permalinks)
    • If you want WordPress to update the .htaccess file automatically, WordPress will need write access to the file.

 

▶ Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning. - Einstein◀

Please remember to mark a thread as solved if your issue has been fixed, it helps other who may stumble across the thread at a later point in time.

Link to comment
https://linustechtips.com/topic/555966-wordpress-and-apache2/#findComment-7325142
Share on other sites

Link to post
Share on other sites

1 minute ago, ionbasa said:

Wait, this is for wordpress?

In that case, you'll need to modify Wordpress' Permalinks.  http://codex.wordpress.org/Using_Permalinks#Choosing_your_permalink_structure

 

Also per: http://codex.wordpress.org/Using_Permalinks#Using_.22Pretty.22_permalinks

make sure you have the following setup on Apache:

 

Ok i see that .htaccess needs to be configured, i have most of that in it already tho how do I do this? I'm really new to this stuff

Back-end developer, electronics "hacker"

Link to comment
https://linustechtips.com/topic/555966-wordpress-and-apache2/#findComment-7325162
Share on other sites

Link to post
Share on other sites

Just now, Joveice said:

Ok i see that .htaccess needs to be configured, i have most of that in it already tho how do I do this? I'm really new to this stuff

Wordpress should auto generate an .htaccess file. Did you modify the Permalink option?

.htaccess should be in the same directory as index.php

▶ Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning. - Einstein◀

Please remember to mark a thread as solved if your issue has been fixed, it helps other who may stumble across the thread at a later point in time.

Link to comment
https://linustechtips.com/topic/555966-wordpress-and-apache2/#findComment-7325184
Share on other sites

Link to post
Share on other sites

5 minutes ago, ionbasa said:

Wordpress should auto generate an .htaccess file. Did you modify the Permalink option?

.htaccess should be in the same directory as index.php

Yep i have the .htaccess file in the same directory as my index.php

My htaccess now looks like this

<VirtualHost *:80>
  ServerName wordpress.lan
  ServerAlias www.hereismydomain.com
  ServerAdmin someuser@localhost
  DocumentRoot /var/ www/ html
  
  <Directory "/var/ www/ html">
    AllowOverride All
    Order allow,deny
    Allow from all
    Require all granted
  </Directory>
  
  ErrorLog well you get it
  CustomLog
</VirtualHost>

 

Back-end developer, electronics "hacker"

Link to comment
https://linustechtips.com/topic/555966-wordpress-and-apache2/#findComment-7325220
Share on other sites

Link to post
Share on other sites

Just now, Joveice said:

Yep i have the .htaccess file in the same directory as my index.php

My htaccess now looks like this


<VirtualHost *:80>
  ServerName wordpress.lan
  ServerAlias www.hereismydomain.com
  ServerAdmin someuser@localhost
  DocumentRoot /var/ www/ html
  
  <Directory "/var/ www/ html">
    AllowOverride All
    Order allow,deny
    Allow from all
    Require all granted
  </Directory>
  
  ErrorLog well you get it
  CustomLog
</VirtualHost>

 

Ok, but did you change the permalinks option in Wordpress? and do you have mod_rewrite enabled on apache?

▶ Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning. - Einstein◀

Please remember to mark a thread as solved if your issue has been fixed, it helps other who may stumble across the thread at a later point in time.

Link to comment
https://linustechtips.com/topic/555966-wordpress-and-apache2/#findComment-7325226
Share on other sites

Link to post
Share on other sites

Just now, ionbasa said:

Ok, but did you change the permalinks option in Wordpress? and do you have mod_rewrite enabled on apache?

If I change the permalinks in wordpress it makes the website unusable since it cannot find the sites so I'm waiting with this to every setting needed to be configrued is done.

I don't know about mod_rewrite, It's on the default settings since i havent changed that much in the Apache configs

Back-end developer, electronics "hacker"

Link to comment
https://linustechtips.com/topic/555966-wordpress-and-apache2/#findComment-7325247
Share on other sites

Link to post
Share on other sites

12 minutes ago, Joveice said:

If I change the permalinks in wordpress it makes the website unusable since it cannot find the sites so I'm waiting with this to every setting needed to be configrued is done.

I don't know about mod_rewrite, It's on the default settings since i havent changed that much in the Apache configs

Ahh. You dont have mod_rewrite enabled then.

sudo a2enmod rewrite
sudo service apache2 restart

Then try adjusting the permalinks option again.

 

▶ Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning. - Einstein◀

Please remember to mark a thread as solved if your issue has been fixed, it helps other who may stumble across the thread at a later point in time.

Link to comment
https://linustechtips.com/topic/555966-wordpress-and-apache2/#findComment-7325340
Share on other sites

Link to post
Share on other sites

1 minute ago, ionbasa said:

Ahh. You dont have mod_rewrite enabled then.


sudo a2enmod rewrite
sudo service apache2 restart

Then try adjusting the permalinks option again.

 

Before I do this, What does mod_rewrite do ?

Back-end developer, electronics "hacker"

Link to comment
https://linustechtips.com/topic/555966-wordpress-and-apache2/#findComment-7325348
Share on other sites

Link to post
Share on other sites

Formal explanation from: http://httpd.apache.org/docs/current/mod/mod_rewrite.html

Quote

The mod_rewrite module uses a rule-based rewriting engine, based on a PCRE regular-expression parser, to rewrite requested URLs on the fly. By default, mod_rewrite maps a URL to a filesystem path. However, it can also be used to redirect one URL to another URL, or to invoke an internal proxy fetch.

mod_rewrite provides a flexible and powerful way to manipulate URLs using an unlimited number of rules. Each rule can have an unlimited number of attached rule conditions, to allow you to rewrite URL based on server variables, environment variables, HTTP headers, or time stamps.

mod_rewrite operates on the full URL path, including the path-info section. A rewrite rule can be invoked in httpd.conf or in .htaccess. The path generated by a rewrite rule can include a query string, or can lead to internal sub-processing, external request redirection, or internal proxy throughput.

 

My explanation: allows manipulation of URLs by apache when an rule is applied. Many websites use it, like Wordpress, to change hard coded structures, like the index.php in the URL to anything else an user wants. Which is the Wordpress permalinks option uses.

▶ Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning. - Einstein◀

Please remember to mark a thread as solved if your issue has been fixed, it helps other who may stumble across the thread at a later point in time.

Link to comment
https://linustechtips.com/topic/555966-wordpress-and-apache2/#findComment-7325372
Share on other sites

Link to post
Share on other sites

Just now, ionbasa said:

Formal explanation from: http://httpd.apache.org/docs/current/mod/mod_rewrite.html

 

My explanation: allows manipulation of URLs by apache when an rule is applied. Many websites use it, like Wordpress, to change hard coded structures, like the index.php in the URL to anything else an user wants. Which is the Wordpress permalinks option uses.

Ah okey neat to know a little what all this stuff do. I now did this and changed the permalinks and it's now working as I want it to. Thank you :)

Back-end developer, electronics "hacker"

Link to comment
https://linustechtips.com/topic/555966-wordpress-and-apache2/#findComment-7325376
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×