Skip to content

Instantly share code, notes, and snippets.

@ankibalyan
Last active May 1, 2016 10:58
Show Gist options
  • Save ankibalyan/3b395738b4ebcf28c68d to your computer and use it in GitHub Desktop.
Save ankibalyan/3b395738b4ebcf28c68d to your computer and use it in GitHub Desktop.
#Install Ubuntu Linux, nginx, MySQL, PHP 7.0 (LEMP) stack
#nginx
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install nginx
sudo apt-get update
check localhost or server ip address
"welcome message by nginx"
To stop your web server, you can type:
sudo service nginx stop
To start the web server when it is stopped, type:
sudo service nginx start
To stop and then start the service again, type:
sudo service nginx restart
Install MySQL to Manage Site Data
sudo apt-get install mysql-server
sudo mysql_install_db
sudo mysql_secure_installation
Install PHP for Processing
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ondrej/php
sudo apt-get install -y php7.0 php7.0-fpm
sudo apt-get update
sudo apt-get install php7.0-mysql php7.0-curl php7.0-json
configure php.ini
sudo vi /etc/php/7.0/fpm/php.ini
cgi.fix_pathinfo=0
sudo service php7.0-fpm restart
Configure Nginx to Use our PHP Processor
sudo vi /etc/nginx/sites-available/default
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.php index.html index.htm;
server_name server_domain_name_or_IP;
location / {
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
save it.
sudo service nginx restart
test it by putting a php file
#Few common Extentions
To install curl
sudo apt-get install curl libcurl3 libcurl3-dev php5-curl
To Install mcrypt extenstion
sudo apt-get install php5-mcrypt
To Install Gd extention
sudo apt-get install php5-gd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment