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.
===========================
- <!DOCTYPE html>
- <html lang="en" dir="ltr">
- <head>
- <meta charset="utf-8">
- <title>Welcome to example.com</title>
- </head>
- <body>
- <h1>Success! example.com home page!</h1>
- </body>
- </html>
Step6:create virtual host
keenable@isgec:/etc/apache2/sites-available$ sudo vim example.com.conf
============================
- <VirtualHost *:80>
- ServerName example.com
- ServerAlias www.example.com
- ServerAdmin webmaster@example.com
- DocumentRoot /var/www/example.com/public_html
- <Directory /var/www/example.com/public_html>
- Options -Indexes +FollowSymLinks
- AllowOverrideAll
- </Directory>
- ErrorLog${APACHE_LOG_DIR}/example.com-error.log
- CustomLog${APACHE_LOG_DIR}/example.com-access.log combined
- </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
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
========================================
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
=========================
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 link4844 apache2
3408 apache2
4304 apache2
4060 apache2
3928 apache2
1688 apache2
1688 apache2
https://hostadvice.com/how-to/how-to-setup-apache-virtual-hosts-on-ubuntu-18/
https://scriptverse.academy/tutorials/php-hello-world.html
Comments
Post a Comment