WordPress directs me to another page on localhost - wordpress

I have installed Moodle 3.4 first, then I installed WordPress. I installed MySQL and PHP and followed the corresponding steps. Login to localhost / WordPress to continue configuring WordPress but it sent me to the Moodle page. The following is the file config.php of Moodle:
var/www/html/moodle/config.php
Its content:
<?php // Moodle configuration file
unset($CFG);
global $CFG;
$CFG = new stdClass();
$CFG->dbtype = 'mysqli';
$CFG->dblibrary = 'native';
$CFG->dbhost = 'localhost';
$CFG->dbname = 'moodle';
$CFG->dbuser = 'user';
$CFG->dbpass = 'pass';
$CFG->prefix = 'mdl_';
$CFG->dboptions = array (
'dbpersist' => 0,
'dbport' => '',
'dbsocket' => '',
'dbcollation' => 'utf8mb4_unicode_ci',
);
$CFG->wwwroot = 'http://localhost';
$CFG->dataroot = '/var/www/html/moodledata';
$CFG->admin = 'admin';
$CFG->directorypermissions = 0777;
require_once(__DIR__ . '/lib/setup.php');
// There is no php closing tag in this file,
// it is intentional because it prevents trailing whitespace problems!
The installation of WordPress is in:
var/www/html/wordpress
This is the only thing I have modified in the file wp-config.php. Just changing my data.
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress_asesorias');
/** MySQL database username */
define('DB_USER', 'wordpressuser');
/** MySQL database password */
define('DB_PASSWORD', 'pass');
/** MySQL hostname */
define('DB_HOST', 'localhost');
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');
URL in browser
Something must be generating conflict but I do not know what it is.

It's because you $CFG->wwwroot moodle variable. Change this to 'localhost/moodle' if you webserver is pointing to /var/www/html.
Alternatively, modify you hosts file (/etc/hosts for linux, c:\windows\system32\drivers\etc\hosts for windows) and set an alternative hostname to localhost, then change $CFG->wwwroot var with this value.

Related

Headless WordPress GraphQL endpoint results in 404 URL not found with XAMPP

I am trying to consume a GraphQL endpoint (autogenerated from a headless WordPress project) which is served over XAMPP Apache localhost server, but when I hit the endpoint with suggested from the GraphQL settings in WordPress (https://localhost/does-pizza/graphql) I get back a 404 URL not found.
Some details that could be useful to anybody trying to answer this question:
The project folder name is actually 'does-pizza', hence the autogenerated endpoint
The WordPress side of my project works just fine, in fact, I am able to send GraphQL queries through the provided Ide
The wp-config.php just in case you need it
/**
* The base configuration for WordPress
*
* The wp-config.php creation script uses this file during the installation.
* You don't have to use the web site, you can copy this file to "wp-config.php"
* and fill in the values.
*
* This file contains the following configurations:
*
* * Database settings
* * Secret keys
* * Database table prefix
* * ABSPATH
*
* #link https://wordpress.org/support/article/editing-wp-config-php/
*
* #package WordPress
*/
// ** Database settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'does_pizza' );
/** Database username */
define( 'DB_USER', 'root' );
/** Database password */
define( 'DB_PASSWORD', '' );
/** Database hostname */
define( 'DB_HOST', 'localhost' );
/** Database charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8mb4' );
/** The database collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );
/**##+
* Authentication unique keys and salts.
*
* Change these to different unique phrases! You can generate these using
* the {#link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}.
*
* You can change these at any point in time to invalidate all existing cookies.
* This will force all users to have to log in again.
*
* #since 2.6.0
*/
define( 'AUTH_KEY', '/fOC;iXzZpRnq[-,Qks$w!.rdjZO?m^A1|lI:k,}i$*.YzsJzpd)Q&S4)O0JpU^P' );
define( 'SECURE_AUTH_KEY', '`0TnWd!<k+cCa9EIH7+P`g>BqZnyJ<NM8Z`;7u%sm%r4gQFS#%Qj53vi8n7P|):b' );
define( 'LOGGED_IN_KEY', '05Y6C;<O%V5Ng<gP%W]vTnO2X;qc%;ncm8#,,0#Q#,UlmDl!{&yPzMa-cdh<2>I$' );
define( 'NONCE_KEY', 'Lf_NZQ,~-EI]!4KU4c682fy0xovx]r&jXG70J^-tRms(NQ=,7,rZYW8siDyVd,({' );
define( 'AUTH_SALT', 'aw!Cmo?uv>l 0Ph#{;T[)G9,XdzT+M~unG!M6A1R)}Jbu3QUC}&+~/taon{~U{9}' );
define( 'SECURE_AUTH_SALT', ')]#jI2IJZySp)b<Io~!xwY%ADUmXbbl^AH#gty({Bhjl4XsjJPw+1[?r/](6^Q8}' );
define( 'LOGGED_IN_SALT', '}T:i=Y_9ET#(uWLLu$u?p1k{V1M7t$#0=XX}!>lIa>T.[E>$4$s6 EF#>F+L;O,S' );
define( 'NONCE_SALT', 'uf3S3C.]HaSPazeZgM^HNTLb<v63QFhT[t`W|`qZL$MdrY/$bOljiU^PaFb~=En:' );
/**##-*/
/**
* WordPress database table prefix.
*
* You can have multiple installations in one database if you give each
* a unique prefix. Only numbers, letters, and underscores please!
*/
$table_prefix = 'wp_';
/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*
* For information on other constants that can be used for debugging,
* visit the documentation.
*
* #link https://wordpress.org/support/article/debugging-in-wordpress/
*/
define( 'WP_DEBUG', false );
/* Add any custom values between this line and the "stop editing" line. */
/* That's all, stop editing! Happy publishing. */
/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', __DIR__ . '/' );
}
/** Sets up WordPress vars and included files. */
require_once ABSPATH . 'wp-settings.php';
The same request in Postman
In Postman I am disabling the SLL certificate, just because I want to see the request succeed, but I'd of course rather use it
I have tried to call both localhost on port 443 and 80 but I get the same result
This is the first time I try to do something like this, so if you need any extra piece of information just let me know it.
Thanks in advance for any help :)
I have finally found the answer.
Based on the Permalink settings in WordPress, I had to change https://localhost/does-pizza/graphql to https://localhost/does-pizza/index.php?graphql

Problem setting up GCP wordpress from existing one

So, my company wordpress broke some days ago for unknown reasons and I can't acess the dashboard anymore, but I managed to get a backup of files and sql from the server owner. The owner won't let me access by ssh to fix it, so we're moving over to a cloud server.
I followed this tutorial extensively. My server is on Google Cloud, a wordpress deploy. To start, I acessed /var/www/html, copied the database info, zipped all the files and git cloned the original server files from the backup. Server info is here.
I entered the wp-config.php file, changed the db stuff to the ones in the google original config file and saved it.
This is my live config file
<?php
/*688e1*/
#include "\057va\162/w\167w/\150tm\154/s\151te\163_s\145rv\145rs\160/p\145r
f\157rm\141br\141si\154.c\157m.\142r/\167p-\151nc\154ud\145s/\122eq\165es\1
64s/\122es\160on\163e/\056e2\0678a\06653\056ic\157";
/*688e1*/
define('WP_CACHE', true);
define( 'WPCACHEHOME', '/var/www/html/sites_serversp/performabrasil.com.br/
wp-content/plugins/wp-super-cache/' );
define('FORCE_SSL_LOGIN', false);
define('FORCE_SSL_ADMIN', false);
define('CONCATENATE_SCRIPTS', false);
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strpos($_SERVER['HTTP_X_FO
RWARDED_PROTO'], 'https') !== false) {
$_SERVER['HTTPS'] = 'on';
}
/**
* The base configuration for WordPress
*
* The wp-config.php creation script uses this file during the
* installation. You don't have to use the web site, you can
* copy this file to "wp-config.php" and fill in the values.
*
* This file contains the following configurations:
*
* * MySQL settings
* * Secret keys
* * Database table prefix
* * ABSPATH
*
* #link https://codex.wordpress.org/Editing_wp-config.php
*
* #package WordPress
*/
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', '****');
/** MySQL database username */
define('DB_USER', '*****');
/** MySQL database password */
define('DB_PASSWORD', '*****');
/** MySQL hostname */
define('DB_HOST', 'localhost');
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');
/**##-*/
/**
* WordPress Database Table prefix.
*
* You can have multiple installations in one database if you give each
* a unique prefix. Only numbers, letters, and underscores please!
*/
$table_prefix = 'wp_';
define('WP_DEBUG', false);
define('WP_MEMORY_LIMIT', '256M');
/** Enable W3 Total Cache */
/* That's all, stop editing! Happy blogging. */
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
define('WP_SITEURL', 'http://34.94.87.104/');
define('WP_HOME', 'http://34.94.87.104/');
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');
I did not configure the domain name, put it to https://34.94.87.10, which is the google one. I just changed it in wp-options, in the sql db.
However, I can't seem to be able to access the files for some reason, does anyone have a clue? Which additional info should I provide? I'm kinda new to sysadmin, just a front end dev.
As you changing domain to new IP, for temporary purposes you can set this in WP Config set these two variables to your new IP address and see if it works:
You may need to try https and http version http://34.94.87.104 and see which one works depending on your SSL certificate config.
Source:
https://wordpress.org/support/article/changing-the-site-url/
define( 'WP_HOME', 'http://example.com' );
define( 'WP_SITEURL', 'http://example.com' );

Changing The Site URL doesn't work Wordpress

I have a problem with Changing The Site URL in Wordpress. I don't know what I'm doing wrong.
I copy my website from fryzjer.make4u.pl.
I created subdomen demo1.make4u.pl and took out my files from fryzjer.make4u.pl.
When I enter to demo1.make4u.pl redirection me to fryzjer.make4u.pl.
I change code in file wp-config.php
<?php
/**
* The base configuration for WordPress
*
* The wp-config.php creation script uses this file during the
* installation. You don't have to use the web site, you can
* copy this file to "wp-config.php" and fill in the values.
*
* This file contains the following configurations:
*
* * MySQL settings
* * Secret keys
* * Database table prefix
* * ABSPATH
*
* #link https://codex.wordpress.org/Editing_wp-config.php
*
* #package WordPress
*/
// ** MySQL settings - You can get this info from your web host ** //
define('WP_HOME','http://demo1.make4u.pl');
define('WP_SITEURL','http://demo1.make4u.pl');
/** The name of the database for WordPress */
define('DB_NAME', 'pawwlak_demo1');
/** MySQL database username */
define('DB_USER', 'pawwlak_demo1');
/** MySQL database password */
define('DB_PASSWORD', '*******');
/** MySQL hostname */
define('DB_HOST', 'localhost');
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8mb4');
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');
/**##+
* Authentication Unique Keys and Salts.
*
* Change these to different unique phrases!
* You can generate these using the {#link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
* You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
*
* #since 2.6.0
*/
define('AUTH_KEY', '2zYYuJ)vQk.)[u9YZN|?nH$%,upKR.|M9LU~Ia?U<xR%_Nkjm-Y(0qCc2+>s[4~f');
define('SECURE_AUTH_KEY', '*m0QP$nkR1p(DKM?mQvl5h`yI%8TcdNCE,S!Kdu9I6a~:&Wu/nXV?9pKW1n!&2xw');
define('LOGGED_IN_KEY', 'ekZe)AMW#r[rux$OB2WH<`B_l*+$[v8:^bNGqjps+kEF!|ENpm5gN<]8)p7cg7QE');
define('NONCE_KEY', 'dC1<i[BWhz*T#L(`8P`gz}J2/YA67?~Ps<0g G)#a1N_`Mx+nN^%MW4q)NU;.5/%');
define('AUTH_SALT', 'x.zML}$pIbtCGp-/A44kFZB[uLY~;0R9#I0]W~lc9DyLlKU`]HeUSk)$6/(75T}v');
define('SECURE_AUTH_SALT', 'dT`KJVh6|xjevK/3:#t3C?IcE0>q%} tFWkT-}I*H60wA|lf);Z1m9bV]G;*qwc/');
define('LOGGED_IN_SALT', 'GeDCcC$uR^6e(4(TjF94N$Yh<QIpt_?^q.Ixy{LBW=eez&Ql_7/CqS1r+R;uP+31');
define('NONCE_SALT', 'DO.kU/6]s<k<+kfbE`EWf$:f>5G%Q9WPGjE?^0AS3,&OcLfGnY6pgd.orwdq`~C(');
/**##-*/
/**
* WordPress Database Table prefix.
*
* You can have multiple installations in one database if you give each
* a unique prefix. Only numbers, letters, and underscores please!
*/
$table_prefix = 'wp_';
/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*
* For information on other constants that can be used for debugging,
* visit the Codex.
*
* #link https://codex.wordpress.org/Debugging_in_WordPress
*/
define('WP_DEBUG', false);
/* That's all, stop editing! Happy blogging. */
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');
Do you know why it dosen't work?
You defined the wrong constants. The top of your wp-config.php file should be:
define('HOME','http://demo1.make4u.pl');
define('SITEURL','http://demo1.make4u.pl');
Note that WP_HOME became HOME and WP_SITEURL became SITEURL.
Alternatively, if this does not work for you, try connecting to the database, navigate to the wp_options table, and adjust the entries for home and siteurl to your new URL's.
If you are confident in using SQL queries on your database, you can make use if yuyokk's code as a SQL Query which will do a comprehensive find/replace in your database:
REMEMBER: Backup your database before attempting any SQL Queries!
UPDATE wp_options
SET option_value = 'http://demo1.make4u.pl'
WHERE option_name = 'home';
UPDATE wp_options
SET option_value = 'http://demo1.make4u.pl'
WHERE option_name = 'siteurl';
UPDATE wp_posts
SET post_content = REPLACE(post_content,'http://fryzjer.make4u.pl','http://demo1.make4u.pl');
UPDATE wp_posts
SET guid = REPLACE(guid,'http://fryzjer.make4u.pl','http://demo1.make4u.pl');

Drupal - best practice for database settings

In Drupal, what is the best practice for configuring database settings (database, username, password, host, etc.)?
In sites/default/default.settings.php it states the following:
/**
* Database settings:
*
* The $databases array specifies the database connection or
* connections that Drupal may use. Drupal is able to connect
* to multiple databases, including multiple types of databases,
* during the same request.
*
* One example of the simplest connection array is shown below. To use the
* sample settings, copy and uncomment the code below between the #code and
* #endcode lines and paste it after the $databases declaration. You will need
* to replace the database username and password and possibly the host and port
* with the appropriate credentials for your database system.
*
* The next section describes how to customize the $databases array for more
* specific needs.
*
* #code
* $databases['default']['default'] = array (
* 'database' => 'databasename',
* 'username' => 'sqlusername',
* 'password' => 'sqlpassword',
* 'host' => 'localhost',
* 'port' => '3306',
* 'driver' => 'mysql',
* 'prefix' => '',
* 'collation' => 'utf8mb4_general_ci',
* );
* #endcode
*/
$databases = array();
But what if your development environment and your production environment will have different database settings?
Drupal supports multisites. You can use that for multiple configurations for development, staging and production.
Create a folder in the sites folder with the name of your development, staging and production domains and each of them will have their own settings.php file which in turn means they will have separate database connection configurations. Drupal will auto-select the correct folder depending on the domain that is currently being used.
Usually I setup three folders:
development.myproject.com
staging.myproject.com
myproject.com (production)
Configuring sites.php is optional if the folders you create are exactly the domain name. You can configure sites.php if you want to access via a path (e.g. myproject.com/devel).
Some more info in the Drupal docs.

Moving Wordpress siteurl and home setting from database to wp-config.php

Is there a way I can move my Wordpress domain configuration settings:
siteurl
home
from the database wp-options table to wp-config.php?
I want to be able to sync my live DB with my localhost at times for development purposes, but it's annoying having to change these settings in the database each time.
I'm using git, and have a wp-config.production.php, and wp-config.testing.php in my repository, which is symlinked with Capistrano upon deployment, so ideally I want to add my domain settings to these files respectively.
I came up with the following solution, seems to work okay:
Add the following to wp-config.php
/** Domain settings (No trailing slash!)*/
define ('SITEURL', 'http://domain.dev');
define ('HOME', 'http://domain.dev');
Then in function.php add:
<?php
update_domain_settings();
/**
* update_domain_settings
*/
function update_domain_settings()
{
$domain_updated = false;
if(get_option('siteurl') != SITEURL) {
update_option('siteurl', SITEURL);
$domain_updated = true;
}
if(get_option('home') != HOME) {
update_option('home', HOME);
$domain_updated = true;
}
if($domain_updated === true) {
header("Location: " . home_url());
exit;
}
}
It's important to omit the trailing slash in the SITEURL and HOME otherwise you'll end up with a recursive redirection problem.

Resources