Apache (httpd) - GitzJoey/DCSLab GitHub Wiki
The Apache HTTP Server Project is an effort to develop and maintain an open-source HTTP server for modern operating systems including UNIX and Windows.
Why not NGINX? the goal of this tutorial is just to cater the most default settings to run a laravel apps in webservice, hence Apache is recommended based on the availability in linux distros
This projects is using Apache 2.4 or latest
- Install
$ dnf install httpd mod_ssl mod_rewrite
- Additional
-
Project deployment
$ cd /var/www/html $ git clone http://github.com/GitzJoey/DCSLab.git DCSLab $ cd /var/www/html/DCSLab $ npm install
-
Setup .env file
$ nano /var/www/html/DCSLab/api/.env $ nano /var/www/html/DCSLab/web/.env
-
Set shared folder to apache for laravel
$ chown -R apache:apache bootstrap/ $ chown -R apache:apache storage/
-
SELinux for laravel By default SELinux is in enforcing mode, need to allow certain setting to make it work without sacrificing the whole SELinux
Allow apache to write content in storage folder
$ cd /var/www/html/DCSLab/api $ chcon -R -t httpd_sys_rw_content_t storage/
Allow httpd to connect through network (if unable to connect to db)
$ cd /var/www/html/DCSLab/api $ setsebool -P httpd_can_network_connect_db 1
-
Build the web project
$ cd /var/www/html/DCSLab/web $ npm run build
$ touch /etc/httpd/conf.d/laravel.conf
laravel.conf
<VirtualHost *:80>
ServerName dcslab.dev
DocumentRoot /var/www/html/DCSLab/api/public
<Directory /var/www/html/DCSLab/api>
AllowOverride All
</Directory>
</VirtualHost>
$ touch /etc/httpd/conf.d/vue.conf
vue.conf
<VirtualHost *:80>
DocumentRoot "/var/www/html/DCSLab/web/dist/"
ServerName dcslab.dev
<Directory /var/www/html/DCSLab/web/dist/>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Require all granted
Order allow,deny
allow from all
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
</Directory>
</VirtualHost>
- Install
$ dnf install python3-certbot-apache -y $ certbot --apache -d dcslab.duckdns.org
- For renewal
$ certbot renew --apache
- Create a cron job for auto renewal
$ crontab -e add 0 1 1 */2 * root certbot -q renew --apache
- Optimize Laravel with cache
$ sudo -u apache php artisan config:cache $ sudo -u apache php artisan route:cache $ sudo -u apache php artisan view:cache