How to install Apache into Ubuntu for Laravel
How to install Apache into Ubuntu for Laravel
In this tutorial, I am going to show you how to install and configure the Apache web server inside Ubuntu OS.Step 1: Run the following command to install the Apache web server.
sudo apt install apache2
Step 2: If the “apache2” services are not already enabled, run following command to do so.sudo systemctl start apache2Step 3: To check the apache2 server status run below commandDefault apache web application folder location is /var/www/html. Here we willsudo systemctl status apache2Apache configuration of Laravel web application:
delete html folder and create a folder named laravel_app. All of our laraveldefault files and folders will keep inside this laravel_app folder. Follow belowcommendscd var/wwwrm -r html/Now open /etc/apache2/sites-enabled/000-default.conf thisfile with following commend and change it as belowsudo nano /etc/apache2/sites-enabled/000-default.conf<VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/laravel_app/public<Directory /var/www/laravel_app/public> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory><IfModule mod_dir.c> DirectoryIndex index.php index.pl index.cgi index.htm index.xhtml index.htm </IfModule>ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>Now restart the Apache server with the following commendssudo systemctl restart apache2Now enable the rewrite engine with the following commendssudo a2enmod rewriteNow restart again the Apache server with the following commendssudo systemctl restart apache2Now inter inside web root and create a new laravel project with composerwith below commendscd /var/www/composer create-project laravel/laravel laravel_app "8.5.*"Once the installation is completed the change permission to files and folders like below:sudo chown -R www-data.www-data /var/www/laravel_appsudo chmod -R 755 /var/www/laravel_appsudo chmod -R 777 /var/www/laravel_app/storageCreate and configure the Laravel .env fileNow enter inside laravel_app directory and create .env file and put the credintialsfor your application like below and save.cd /var/www/larave_app/touch .envNow browser your ip address and you will see laravel application default pageGenerate an encryption key for your app:
like below.



Comments
Post a Comment