有人能给我步骤,如何创建一个子域,而不是链接到一些随机的资源?我有一个TLD并在上面运行一个站点,但是我希望为它创建一个子域,并将wordpress安装到子域上。有人能帮我吗?更新这是正确的吗?
数据库中的setting
1.
sudo mysql -u root -p2.
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.gz8.
tar -zxvf latest.tar.gz9.
sudo mv wordpress /var/www/html/subdomain10.
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.conf13.
ServerAdmin admin@example.com
DocumentRoot /var/www/html/subdomain/
ServerName subdomain.domain.com
ServerAlias www.subdomain.domain.com
Options +FollowSymlinks
AllowOverride All
Require all granted
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined14.
sudo a2ensite subdomain.conf15.
sudo a2enmod rewrite16.
sudo systemctl restart apache2.service17.
sudo mv /var/www/html/subdomain/wp-config-sample.php /var/www/html/subdomain/wp-config.php18.
sudo nano /var/www/html/subdomain/wp-config.php19.
// ** 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', '');subdomain.domain.comIs这是正确的?
发布于 2019-11-29 04:59:54
首先使用下面的代码创建虚拟主机。
为您的域创建虚拟主机配置文件。
vi /etc/apache2/sites-available/your_domain.conf然后在your_domain.conf文件中添加主机配置
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然后使用下面提到的命令为您的配置文件启用a2ensite。
sudo a2ensite your_domain.conf然后检查您使用的配置
sudo apache2ctl configtest如果语法没问题。然后重新启动apache,
sudo systemctl restart apache2https://serverfault.com/questions/993710
复制相似问题