Configure Apache with index,html and index.php


Step1: Install Apache
Step2:Check status

Step 3 Check on browser.
 
Step4: Now set up Apache virtual host on Ubuntu
keenable@isgec:~$ sudo mkdir -p /var/www/example.com/public_html

Step5 Edit index.html in public_html folder,with following config.
===========================
  1. <!DOCTYPE html>
  2. <html lang="en" dir="ltr">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Welcome to example.com</title>
  6. </head>
  7. <body>
  8. <h1>Success! example.com home page!</h1>
  9. </body>
  10. </html>
===========================
Step6:create virtual host
keenable@isgec:/etc/apache2/sites-available$ sudo vim example.com.conf
============================
  1. <VirtualHost *:80>
  2. ServerName example.com
  3. ServerAlias www.example.com
  4. ServerAdmin webmaster@example.com
  5. DocumentRoot /var/www/example.com/public_html

  6. <Directory /var/www/example.com/public_html>
  7. Options -Indexes +FollowSymLinks
  8. AllowOverrideAll
  9. </Directory>

  10. ErrorLog${APACHE_LOG_DIR}/example.com-error.log
  11. CustomLog${APACHE_LOG_DIR}/example.com-access.log combined
  12. </VirtualHost>
================================

Step7:create symbolic link
keenable@isgec:~$ sudo a2ensite example.com
output.
Enabling site example.com.
To activate the new configuration, you need to run:
  systemctl reload apache2
keenable@isgec:~$ sudo ln -s /etc/apache2/sites-available/example.com.conf /etc/apache2/sites-enable

Step8 varify.
keenable@isgec:~$ sudo apachectl configtest
output.
Syntax OK

Step9:reload Apache and check on browser
step10 check memory used.
keenable@isgec:/var/www/example.com/public_html$ ps -ef |grep html
keenable@isgec:/var/www/example.com/public_html$ ps -aux |grep apache2
root      8265  0.0  0.3 331288 14960 ?        Ss   15:51   0:00 /usr/sbin/apache2 -k start
www-data  8268  0.0  0.2 335692  8104 ?        S    15:51   0:00 /usr/sbin/apache2 -k start
www-data  8269  0.0  0.2 335692  8104 ?        S    15:51   0:00 /usr/sbin/apache2 -k start
www-data  8270  0.0  0.2 335692  8104 ?        S    15:51   0:00 /usr/sbin/apache2 -k start
www-data  8271  0.0  0.2 335692  8104 ?        S    15:51   0:00 /usr/sbin/apache2 -k start
www-data  8275  0.0  0.2 335692  8104 ?        S    15:51   0:00 /usr/sbin/apache2 -k start
keenable  8701  0.0  0.0  21536  1100 pts/0    S+   16:10   0:00 grep apache2
 ========================================
keenable@isgec:/var/www/example.com/public_html$ ps aux | grep 'apache2' | awk '{print $6/1024 " MB";}'
14.6094 MB
7.91406 MB
7.91406 MB
7.91406 MB
7.91406 MB
7.91406 MB
0.980469 MB
=========================
step 11:create an index.php file.
Create a hello folder in varww/html,create hello.php file in that folder with following.
<!DOCTYPE html>
<html>
<head>
<title>Hello, World! Page</title>
</head>
<body>
<?php
 echo 'Hello, World!';
?>
</body>
</html>
=============================================
start apache,check on browser,http://localhost/hello/hello.ph
out put
 
 

===============================
memory used by each Apache process
keenable@isgec:/etc/apache2/mods-available$ ps -C apache2 -o rss,ucmd
output.
RSS CMD
 4844 apache2
 3408 apache2
 4304 apache2
 4060 apache2
 3928 apache2
 1688 apache2
 1688 apache2
I have followed below link

https://hostadvice.com/how-to/how-to-setup-apache-virtual-hosts-on-ubuntu-18/

https://scriptverse.academy/tutorials/php-hello-world.html





Comments

Popular posts from this blog