-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 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..