-1

Can someone actually give me the steps on how to create a subdomain and not link me to some random ressources? I have a TLD and run a site on that, but I want create a subdomain for it and install wordpress onto the subdomain. can someone please help me? UPDATE Would this be correct?

setting up the database

1.

sudo mysql -u root -p

2.

CREATE DATABASE db_name;

3.

CREATE USER 'user_name'@'localhost' IDENTIFIED BY 'password';

4.

GRANT ALL ON db_name.* TO 'database_name'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;

5.

FLUSH PRIVILEGES;

6.

EXIT;

7.

cd /tmp && wget https://wordpress.org/latest.tar.gz

8.

tar -zxvf latest.tar.gz

9.

sudo mv wordpress /var/www/html/subdomain

10.

sudo chown -R www-data:www-data /var/www/html/subdomain/

11.

sudo chmod -R 755 /var/www/html/subdomain/

12.

sudo nano /etc/apache2/sites-available/subdomain.conf

13.

<VirtualHost *:80>
ServerAdmin admin@example.com
    DocumentRoot /var/www/html/subdomain/
    ServerName subdomain.domain.com
    ServerAlias www.subdomain.domain.com

<Directory /var/www/html/subdomain/>
    Options +FollowSymlinks
    AllowOverride All
    Require all granted
</Directory>

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

</VirtualHost>

14.

sudo a2ensite subdomain.conf

15.

sudo a2enmod rewrite

16.

sudo systemctl restart apache2.service

17.

sudo mv /var/www/html/subdomain/wp-config-sample.php   /var/www/html/subdomain/wp-config.php

18.

sudo nano /var/www/html/subdomain/wp-config.php

19.

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'db_name');

/** MySQL database username */
define('DB_USER', 'db_username');

/** MySQL database password */
define('DB_PASSWORD', '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', '');

20. Go To

subdomain.domain.com

Is this correct????

BadWo1f
  • 21
  • 1
  • 4
  • Hi, please dont repost. A comment on your last question tried to answer you; You need to create the subdomain entry inside your DNS server (godady, etc..) and after in your webserver, if IIS in exemple; you add a website that bind to that subdomain, like subdomain.domain.com > c:\inetpub\folderX, inside that folder you drop the wordpress installation zip. Its done after. If using a linux webserver it’s in the .conf, you add the binding there. – yagmoth555 Nov 29 '19 at 04:13
  • In big, a webserver will listen to anything, but if the user put a domain inside the request field, like serverfault.com, then the webserver check if it use the default web site folder or use another folder, it depend on your config. – yagmoth555 Nov 29 '19 at 04:16
  • Check for virtualhost and the servername directive under apache; a example there https://serverfault.com/questions/82306/apache-default-catch-all-virtual-host – yagmoth555 Nov 29 '19 at 04:20
  • Mention clearly where your hosting is and where you kept your servers ? – Manikandan Ram Nov 29 '19 at 04:24
  • It is my own server, I'm running an ubuntu apache web server. I would just like to know the steps on how to create a subdomain that doesn't redirect to my main domain – BadWo1f Nov 29 '19 at 04:25
  • Using apache, VirtualHost and Servername directive is your answer – yagmoth555 Nov 29 '19 at 04:30
  • " I have a TLD and run a site on that," No, you do not have a "TLD". TLD is Top Level Domain such as `com`, or `info`. You have a domain name more probably. – Patrick Mevzek Dec 04 '19 at 06:07
  • what are you talking about, i do have a TLD, you are actually dumb – BadWo1f Dec 07 '19 at 03:24

1 Answers1

1

First create Virtual host using the below code.

Create a virtual host config file for your domain.

   vi  /etc/apache2/sites-available/your_domain.conf

Then add the host configuration inside your_domain.conf file

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName your_domain
    ServerAlias www.your_domain
    DocumentRoot /var/www/your_domain
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Then enable the a2ensite for your config file using the command mentioned below.

sudo a2ensite your_domain.conf

Then check the configurations you made using

sudo apache2ctl configtest

If the syntax is ok. Then restart the apache,

sudo systemctl restart apache2

Still confused check this blog..

Manikandan Ram
  • 389
  • 1
  • 14