Deploying Laravel on Ubuntu
1. Install pre-requisite
sudo add-apt-repository ppa:ondrej/php sudo apt-get install software-properties-common sudo apt-get install python-software-properties sudo apt-get install zip unzip wget -q -O- http://nginx.org/keys/nginx_signing.key | sudo apt-key add -
2. Install Nginx and PHP7
sudo apt-get update sudo apt-get install nginx-full php7.0 php7.0-mysql php7.0-fpm php7.0-mbstring php7.0-xml php7.0-curl php7.0-zip
3. Setup Nginx
sudo pico /etc/nginx/nginx.conf client_max_body_size 30M;
sudo pico /etc/nginx/sites-available/default server { listen 80 default_server; listen [::]:80 default_server; root /path/to/app/public; index index.php index.html index.htm; server_name server_name; charset utf-8; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { try_files $uri /index.php =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/run/php/php7.0-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ /\.ht { deny all; } }
4. Setup PHP7
sudo pico /etc/php/7.0/fpm/php.ini cgi.fix_pathinfo=0 upload_max_filesize=30M
5. Install MySQL client
sudo apt-get install libmysqlclient-dev mysql-client
6. Install Composer
cd ~ curl -sS https://getcomposer.org/installer | php sudo mv composer.phar /usr/local/bin/composer
7. Clone Application Files
git clone path/to/app.git
8. Install Laravel
cd /path/to/app composer install
9. Setup Laravel env file
pico .env (or php artisan key:generate)
10. Set log directory ownership
sudo chown -R www-data:www-data /path/to/app/storage
11. Restart service
sudo service nginx restart sudo service php7.0-fpm restart
AI Summary
Chrome On-device AI
2024-10-04 22:00:36
Share Article