[vc_row full_width=”stretch_row_content_no_spaces” options=”window_height,centered” vsc_text_scheme=”darker-overlay” vsc_parallax=”yes” css=”.vc_custom_1507675697110{padding-top: 50px !important;padding-bottom: 75px !important;}” vsc_bg_image=”4249″][vc_column 0=””][vsc-section-title align=”center” title=”Ubuntu PHP Installation” title_color=”#ffffff” subtitle_color=”#ffffff”]Let’s go through to setup PHP on Ubuntu[/vsc-section-title][/vc_column][/vc_row][vc_row full_width=”stretch_row_content_no_spaces” vsc_text_scheme=”darker-overlay” vsc_bg_color=”#000000″ css=”.vc_custom_1507767322673{padding-top: 50px !important;padding-bottom: 75px !important;}”][vc_column el_align=”alignleft” css=”.vc_custom_1424436615643{padding-top: 10px !important;padding-left: 75px !important;}”][vsc-section-title align=”left” title=”DOWNLOAD AND INSTALL PHP” title_color=”#ffffff”][/vsc-section-title][vc_column_text css=”.vc_custom_1507766613630{padding-right: 150px !important;}”]In your CLI window, enter the following command:
sudo apt-get install php-fpm php-mysql
[/vc_column_text][/vc_column][/vc_row][vc_row full_width=”stretch_row_content_no_spaces” vsc_text_scheme=”darker-overlay” vsc_bg_color=”#000000″][vc_column el_align=”alignright” css=”.vc_custom_1424436739791{padding-top: 25px !important;padding-right: 75px !important;}”][vsc-section-title align=”right” title=”EDIT NGINX TO USE PHP” title_color=”#ffffff” subtitle_color=”#ffffff”][/vsc-section-title][vc_column_text 0=”” text_align=”alignleft” css=”.vc_custom_1507767561017{padding-left: 150px !important;}”]From the CLI window, enter the following command:
sudo nano /etc/nginx/sites-available/default
- First, we need to add
index.php
as the first value of ourindex
directive so that files namedindex.php
are served, if available, when a directory is requested. - We can modify the
server_name
directive to point to our server’s domain name or public IP address. - For the actual PHP processing, we just need to uncomment a segment of the file that handles PHP requests by removing the pound symbols (#) from in front of each line. This will be the
location ~\.php$
location block, the includedfastcgi-php.conf
snippet, and the socket associated withphp-fpm
. - We will also uncomment the location block dealing with
.htaccess
files using the same method. Nginx doesn’t process these files. If any of these files happen to find their way into the document root, they should not be served to visitors.
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name server_domain_or_IP;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
[/vc_column_text][/vc_column][/vc_row][vc_row full_width=”stretch_row_content_no_spaces” vsc_text_scheme=”darker-overlay” vsc_bg_color=”#000000″ css=”.vc_custom_1507767322673{padding-top: 50px !important;padding-bottom: 75px !important;}”][vc_column el_align=”alignleft” css=”.vc_custom_1424436615643{padding-top: 10px !important;padding-left: 75px !important;}”][vsc-section-title align=”left” title=”TEST NGINX CONFIGURATION” title_color=”#ffffff”][/vsc-section-title][vc_column_text css=”.vc_custom_1507768498282{padding-right: 150px !important;}”]In your CLI window, enter the following command:
sudo nginx -t
sudo service nginx restart
This allows us to test the NGINX Configuration. If no errors, proceed.[/vc_column_text][/vc_column][/vc_row][vc_row full_width=”stretch_row_content_no_spaces” vsc_text_scheme=”darker-overlay” vsc_bg_color=”#000000″][vc_column el_align=”alignright” css=”.vc_custom_1424436739791{padding-top: 25px !important;padding-right: 75px !important;}”][vsc-section-title align=”right” title=”CREATE TEST PHP FILE” title_color=”#ffffff” subtitle_color=”#ffffff”][/vsc-section-title][vc_column_text 0=”” text_align=”alignleft” css=”.vc_custom_1507768524261{padding-left: 150px !important;}”]
sudo nano /var/www/html/info.php
Then Paste the following:
<?php
phpinfo();
Save and Exit…
Then goto browser and enter:
http://server_domain_or_IP/info.php
If all is well, it will display a PHP info page.[/vc_column_text][/vc_column][/vc_row][vc_row full_width=”stretch_row” vsc_text_scheme=”darker-overlay” vsc_bg_color=”#0a0a0a”][vc_column][vc_empty_space][/vc_column][/vc_row][vc_row full_width=”stretch_row” vsc_text_scheme=”darker-overlay” vsc_bg_color=”#000000″][vc_column width=”4/6″][vsc-text-icon align=”right” type=”fontawesome” icon_fontawesome=”fa fa-hand-o-right” title=”CONTINUE TO NGINX SECURING DOMAIN WITH SSL” title_color=”#ffffff” text_color=”#ffffff” icon_color=”#ffffff”]Now that NGINX is installed and is now working with PHP, let’s secure your domain with SSL.[/vsc-text-icon][/vc_column][vc_column width=”2/6″][vsc-button text=”SSL” align=”center” type=”fontawesome” icon_fontawesome=”fa fa-arrow-right” i_align=”pull-right” add_icon=”true” url=”/howtos/#reverseProxy” color=”#3a6da6″][/vc_column][/vc_row]