Deploying yii2 application

Posted March 23, 2021 601 views
ApachePHPDigitalOceanUbuntu 18.04

I was deploying a web application using the yii2 framework, it was working fine on my previous dev machine, I’m using xampp as my webserver. I already copied the application on default directory /var/www/html/myfolder. But I got an error 404 Not Found (The requested URL was not found on this server). I’m using Apache/2.4.29. Is there anything I need to setup or reconfigure? Do I need to install yii framework too?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Hi @solutionbasecorp,

When using Apache, you need to configure your domain in a virtualconfig file so that Apache knows from where to load the files.

Since you are using ubuntu, go to folder

cd /etc/apache2/sites-available

Inside create he configuration file like so

touch DomainName.conf

where DomainName, is your actual domain name. The most basic configuration file looks like so

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

Again, remember to put our own DocumentRoot folder and in the ServerName and SeverAlias spaces to put your actual domain name.

Now to enable the file you need to run

sudo a2ensite DomainName.conf
sudo systemctl restart apache2
sudo systemctl status apache2

That’s it, you should now have a working website.