I hosted several websites on AWS EC2. It works fine.
I just upgraded my Ubuntu server with sudo do-release-upgrade
, and the process of updating seems fine as well.
$ lsb_release -d
Description: Ubuntu 18.04.3 LTS
However, while I visit example.com
, it shows the following code rather than a homepage:
<?php
/**
* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*/
/**
* Tells WordPress to load the WordPress theme and output it.
*
* @var bool
*/
define('WP_USE_THEMES', true);
/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
I checked the configurations with the help of PHP code is not being executed, instead code shows on the page, but still failed to make it right.
1. My machine did installed PHP and apache.
$ php -version
PHP 7.2.24-0ubuntu0.18.04.1 (cli) (built: Oct 28 2019 12:07:07) ( NTS )
$ sudo apt-get install apache2
apache2 is already the newest version (2.4.29-1ubuntu4.11).
2. Add LoadModule php
Add the following line at the end of apache2.conf
:
LoadModule php7_module /usr/lib/apache2/modules/libphp7.2.so
3. Add types
Append the following codes to apache2.conf
,
AddType application/x-httpd-php-source .phps
AddType application/x-httpd-php .php
Restart apache with sudo service apache2 restart
.
Bingo, everything goes well:-)