-
-
Save xerardoo/395a20e01f332681a1b44e52bafe45cb to your computer and use it in GitHub Desktop.
Lumen + Nginx + Ubuntu
This file contains hidden or 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
cd ~ | |
sudo apt-get update | |
1. Install PHP and Nginx | |
#apt-get install software-properties-common | |
sudo apt-get -y install nginx php7.0 php7.0-fpm php7.0-mbstring php7.0-xml git composer | |
2. Config Nginx | |
cat <<EOF > /etc/nginx/sites-available/lumen.com | |
server { | |
listen 80; | |
#listen [::]:80 ipv6only=on; | |
root /var/www/lumen/public; | |
index index.php index.html index.htm; | |
server_name lumen; | |
charset utf-8; | |
gzip on; | |
gzip_vary on; | |
gzip_disable "msie6"; | |
gzip_comp_level 6; | |
gzip_min_length 1100; | |
gzip_buffers 16 8k; | |
gzip_proxied any; | |
gzip_types | |
text/plain | |
text/css | |
text/js | |
text/xml | |
text/javascript | |
application/javascript | |
application/x-javascript | |
application/json | |
application/xml | |
application/xml+rss; | |
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 ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc|svg|woff|woff2|ttf)\$ { | |
expires 1M; | |
access_log off; | |
add_header Cache-Control "public"; | |
} | |
location ~* \.(?:css|js)\$ { | |
expires 7d; | |
access_log off; | |
add_header Cache-Control "public"; | |
} | |
location ~ /\.ht { | |
deny all; | |
} | |
} | |
EOF | |
3. Fixing php-fpm | |
sudo nano /etc/php/7.0/fpm/php.ini | |
Uncomment and set "cgi.fix_pathinfo=0" | |
4. A little more config... | |
export PATH=$PATH:~/.composer/vendor/bin/ | |
sudo /etc/init.d/nginx restart | |
sudo /etc/init.d/php7.0-fpm restart | |
sudo usermod -a -G www-data nginx | |
5. Creating project | |
sudo composer global require "laravel/lumen-installer" | |
cd /var/www/ | |
sudo chown <your user name> /var/www/ | |
sudo composer create-project --prefer-dist laravel/lumen lumen | |
6. Fixing permissions | |
sudo chown -R www-data:www-data /var/www/lumen | |
sudo chmod -R 775 /var/www/lumen/storage | |
7. Optional fixes | |
sudo nano /php/7.0/fpm/pool.d/www.conf | |
listen.mode = 0660 | |
sudo chmod -R 775 storage | |
Nginx error log: | |
tail -f /var/log/nginx/error.log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment