Install apache into your Ubuntu is easy enough using either the Synaptic Package Manager, Software Center Ubuntu, and install "apache2" module. Or, you can open a terminal and type the following command:
After installation is complete, open a browser and type to "http://localhost" URL. If you see the words "It Works!", then your apache installation succeeded.
After you install Apache, it will be added to the list of init.d and will automatically start each time you boot up your computer. The following command allows you to start, restart, stop Apache.
sudo / etc/init.d/apache2 start # start apache
sudo / etc/init.d/apache2 stop # stop apache
sudo / etc/init.d/apache2 restart # restart apache
To prevent Apache from auto start at boot:
sudo update-rc.d-f apache2 remove
To return back to auto start Apache type the following:
sudo update-rc.d apache2 defaults
Changing the default folder localhost
By default, Apache will operate in "/ var / www"folder. This means that whatever you place the files in / var / www folder will be visible from the http://localhost URL. In some cases you might want to "localhost" to point to another folder instead, eg / home / user / public_html. Here's how to do it:
First, make sure / home / Damien / public_html folder exists. Create a simple html file, the name of index.html and place it in public_html folder.
Open a terminal and type:
gksu gedit / etc/apache2/sites-enabled/000-default
Change DocumentRoot / var / www to DocumentRoot / home / user / public_html.
Change to.
then Restart Apache
sudo / etc/init.d/apache2 restart
Now, in your browser, Reload the URL http://localhost. you should see your html file that has been placed in the public_html folder.
Sites of different configurations
Way above allows you to change the default folder apache operation, however, some of you may not want to override the default settings. An alternative is to create multiple sites and apache leads to the active site.
Create a new settings file for your new site.
sudo cp / etc/apache2/sites-available/default / etc/apache2/sites-available/site1
Next, edit the settings file.
gksu gedit / etc/apache2/sites-available/site1
Change DocumentRoot / var / www to DocumentRoot / home / user / public_html.
Change to.
Save the settings and exit, then disables the default settings and make active site1 settings.
sudo a2dissite default & & sudo a2ensite site1
Finally, restart apache again. In this way, you can make multiple site configuration files, each pointing to a different folder. You can then easily switch between sites with and a2ensite a2dissite command.
Enabling file. htaccess
file. htaccess is a powerful file that can be used to control and customize the behavior of site server without editing the core Apache modules. By default, the function. htaccess is turned off and all the case files. htaccess is totally ignored. The server will not even attempt to read. htaccess file in the filesystem ..
To activate htaccess file, open the settings file that you created previously:
gksu gedit / etc/apache2/sites-available/site1
Save and Exit.
No comments:
Post a Comment