Installing and Working With Apache Web Server
Installing and Working With Apache Web Server
Getting apache onto your Ubuntu machine is easy. Using either the Synaptic
“apache2” module. Alternatively, you can open a terminal and type the
following command:
“http://localhost“. If you see the word “It Works!“, then your installation of
apache is successful.
How do I start, restart or stop Apache 2 web server under Ubuntu Linux
operating systems?
1
/etc/init.d/apache2 is service script used to start / stop / restart the Apache2
service under Debian or Ubuntu Linux. You need to login as root or use sudo
command restart Apache.
# /etc/init.d/apache2 start
or
$ sudo /etc/init.d/apache2 start
# /etc/init.d/apache2 restart
or
$ sudo /etc/init.d/apache2 restart
# /etc/init.d/apache2 stop
or
$ sudo /etc/init.d/apache2 stop
Configuring Apache
Start, Stop and Restart Apache
After you have installed Apache, it will be added to the init.d list and will auto
start whenever you boot up your computer. The following commands allow
you to start, restart, stop Apache.
2
To prevent Apache from autostart when booting up:
Ubuntu) only.
By default, apache will operate on the “/var/www” folder. This means that
whatever files you place in this /var/www folder will be visible from the URL
simple html file, name it index.html and place it in the public_html folder.
/home/user/public_html.
/home/user/public_html/>.
3
Save and exit the file.
Now, in your browser, reload the URL http://localhost. You should see the
4
The above trick allows you to change the default operating folder of apache,
however, some of you might not want to override the default settings. An
alternative is to create multiple sites and point apache to the active site.
sudo cp /etc/apache2/sites-available/default
/etc/apache2/sites-available/site1
/home/user/public_html/>.
Disable the default setting and make active the site1 settings
With this trick, you can create multiple site configuration file, each pointing to
a different folder. You can then easily switch between the sites with
.htaccess file is a powerful file that can be used to control and customize a
site server behavior without editing the core Apache module. By default, the
.htaccess functionality is turned off and all instances of .htaccess files are
5
completely ignored. The server will not even attempt to read .htaccess files in
the filesystem.
To enable .htaccess file, open up the settings file that you have created
earlier:
Scroll down the file until you see the part “<Directory
/home/user/public_html/>“. Underneath that line of code,