Install Php 7.3 on Ubuntu 20
sudo mysql -u root
mysql> USE mysql;
mysql> UPDATE user SET plugin='mysql_native_password' WHERE User='root';
mysql> FLUSH PRIVILEGES;
mysql> exit;
service mysql restart
For use Vscode for saving files
sudo chown -R myuser /path/to/folder
Using Laravel to Deploy an Application
On the contrary, if we are going to use our VPS as the server of a Laravel application, then we have to make some adjustments to avoid problems.
First, we need to move the previously created project directory to the Apache web root. Remember, in our case, the folder name is Example. Execute the following command:
sudo mv example /var/www/html/
After that, set the necessary permissions to ensure the project runs smoothly:
sudo chgrp -R www-data /var/www/html/example/
sudo chmod -R 775 /var/www/html/example/storage
It is necessary to create a new virtual host for the project. It can be done easily with the commands below:
cd /etc/apache2/sites-available
sudo nano laravel_project.conf
Add the following to create the new Virtual host. Remember to replace thedomain.com with your server’s IP address.
<VirtualHost *:80>
ServerName thedomain.com
ServerAdmin webmaster@thedomain.com
DocumentRoot /var/www/html/example/public
<Directory /var/www/html/example>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Save the file and close it.
After that, disable the default configuration file of the virtual hosts in Apache with this command:
sudo a2dissite 000-default.conf
Afterwards, enable the new virtual host:
sudo a2ensite laravel_project
Enable the Apache rewrite module, and finally, restart the Apache service:
sudo a2enmod rewrite
sudo systemctl restart apache2
Now, open the web browser and go to the servers IP and voila. If you get the same Laravel landing screen you have seen last time, you’re ready to start working.
Now we can get to work with this great PHP framework.
Comments
Post a Comment