Last active
July 8, 2022 11:49
-
-
Save miladimos/03d8930a61c045b0c4774fa651f930be to your computer and use it in GitHub Desktop.
install php 8 laravel ubuntu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install php8 | |
sudo apt update | |
sudo apt upgrade | |
sudo apt install ca-certificates apt-transport-https software-properties-common | |
sudo add-apt-repository ppa:ondrej/php | |
sudo apt update | |
sudo apt -y upgrade | |
sudo apt install php8.1 php8.1-common php8.1-gd php8.1-curl php8.1-mailparse php8.1-opcache php8.1-yaml php8.1-zip php8.1-mbstring php8.1-uuid php8.1-imagick php8.1-bz2 php8.1-imap php8.1-xml php8.1-soap php8.1-mysql php8.1-cli php8.1-fpm libapache2-mod-php8.1 php8.1-cgi php8.1-gd php-imagick php8.1-intl php8.1-pspell php8.1-tokenizer php8.1-mcrypt | |
# Enable PDO module | |
sudo phpenmod pdo_mysql | |
# on Apache | |
sudo vim /etc/apache2/sites-available/laravel.conf | |
<VirtualHost *:80> | |
ServerName example.com | |
ServerAdmin [email protected] | |
DocumentRoot /var/www/html/laravelapp/public | |
<Directory /var/www/html/laravelapp> | |
AllowOverride All | |
</Directory> | |
ErrorLog ${APACHE_LOG_DIR}/error.log | |
CustomLog ${APACHE_LOG_DIR}/access.log combined | |
</VirtualHost> | |
sudo a2ensite laravel.conf | |
sudo a2enmod rewrite | |
sudo systemctl restart apache2 | |
# on Nginx | |
sudo apt install nginx | |
sudo apt enable nginx | |
sudo nano /etc/nginx/sites-available/laravel | |
server { | |
listen 80; | |
server_name server_domain_or_IP; | |
root /var/www/travellist/public; | |
add_header X-Frame-Options "SAMEORIGIN"; | |
add_header X-XSS-Protection "1; mode=block"; | |
add_header X-Content-Type-Options "nosniff"; | |
index index.html index.htm index.php; | |
charset utf-8; | |
location / { | |
try_files $uri $uri/ /index.php?$query_string; | |
} | |
location = /favicon.ico { access_log off; log_not_found off; } | |
location = /robots.txt { access_log off; log_not_found off; } | |
error_page 404 /index.php; | |
location ~ \.php$ { | |
fastcgi_pass unix:/var/run/php/php8.0-fpm.sock; | |
fastcgi_index index.php; | |
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; | |
include fastcgi_params; | |
} | |
location ~ /\.(?!well-known).* { | |
deny all; | |
} | |
} | |
sudo ln -s /etc/nginx/sites-available/laravel /etc/nginx/sites-enabled/ | |
sudo nginx -t | |
sudo systemctl reload nginx | |
sudo systemctl restart nginx | |
# Database Mysql | |
sudo apt install mysql | |
sudo mysql_secure_installation | |
CREATE USER 'user'@'localhost' IDENTIFIED BY 'password'; | |
GRANT ALL ON database.* TO 'user'@'%'; | |
# Firewall | |
for i in ssh http https | |
do | |
ufw allow $i | |
done | |
sudo ufw enable | |
# Enable Laravel queue production | |
sudo apt install supervisor | |
sudo nano /etc/supervisor/conf.d/queue-worker.conf | |
---------------------------------------------- | |
[program:queue-worker] | |
process_name = %(program_name)s_%(process_num)02d | |
command=php /var/www/html/project-folder/artisan queue:listen | |
autostart=true | |
autorestart=true | |
user=root | |
numprocs=1 | |
redirect_stderr=true | |
stdout_logfile=/var/www/html/project-folder/public/worker.log | |
sudo supervisorctl reread | |
sudo supervisorctl update | |
sudo supervisorctl start all | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment