Hi guys,
I apologize if this is a duplicated question, I have been trying to find an answer through the related posts I have managed to find with no luck so far…
I have an apache2 server running on Ubuntu 18.04 (DNS for DigitalOcean set) with two subdomains: php.example.com and blog.example.com (DNS A Records set for the droplet IP). I installed phpMyAdmin (/usr/share/phpmyadmin) and a wordpress blog (/var/www/wordpress).
I wanted to access phpMyAdmin through php.example.com and the blog through blog.example.com / www.example.com but I cannot get to it; all the subdomains go to one of the DocumentRoots.
I have followed some tutorials (https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-18-04) and tips I have seen here and on different sites, and so far I have completed these steps:
wordpress.conf: <VirtualHost *:80>
ServerAdmin example@mail.com
ServerName www.example.com
ServerAlias blog.example.com
DocumentRoot /var/www/wordpress
<Directory /var/www/wordpress/>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:443> ServerAdmin example@mail.com ServerName www.example.com ServerAlias blog.example.com DocumentRoot /var/www/wordpress
SSLEngine on
SSLCertificateFile /certroute
SSLCertificateKeyFile /keyroute
SSLCertificateChainFile /chainroute
<Directory /var/www/wordpress/>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
phpmyadmin.conf: <VirtualHost *:80>
ServerAdmin example@mail.com
ServerName php.example.com
DocumentRoot /var/www/phpmyadmin
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:443> ServerAdmin example@mail.com ServerName php.example.com DocumentRoot /var/www/phpmyadmin
SSLEngine on
SSLCertificateFile /certroute
SSLCertificateKeyFile /keyroute
SSLCertificateChainFile /chainroute
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Enabled both .conf files and disabled 000-default.conf / default-ssl.conf
Set up a symlink from /var/www/phpmyadmin to /usr/share/phpmyadmin
Reloaded Apache2
Still going to wordpress when I try to load https://php.example.com and at this point I really don’t know what to try next.
Any help would be much appreciated.
Thanks!
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi @fgazpiazu,
You want to access PHPMyAdmin like this php.domain.com instead of domain.com/phpmyadmin.
If you’re running an apache server and you have installed PHPMyAdmin, So the one thing is extra you have to do.
Just create a symbolic link in apache2 directory to access the PHPMyAdmin:
sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
sudo a2enconf phpmyadmin.conf
Now, create a new configuration file in apache directory for you subdomain php.domain.com.conf, and add following lines
<VirtualHost *:80> ServerName php.website.com RedirectPermanent / http://php.website.com:/ </VirtualHost>
Now when you open php.domain.com, it will redirect you to domain.com/phpmyadmin
If you have install PHPMyAdmin in /etc directory, then this will work, otherwise, you have to make some changes.
Sorry, @fgazpiazu,
This is the right configuration, I made a mistake above.
server {
# Permanent redirect to new URL
server_name php.yourdomain.com;
rewrite ^/(.*)$ http://yourdomain.com/phpmyadmin permanent;
}
reload configuration:
$ sudo systemctl reload nginx
Add the following record in your DNS manager.
CNAME php yourdoamin.com
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.