Showing posts with label Apache. Show all posts
Showing posts with label Apache. Show all posts

Monday, February 11, 2013

Disable Ubuntu One, MySql, Apache services on boot – Ubuntu 12.04

Ubuntu One is great, but when I am on battery power it just drains a lot. So what I need is, disable Ubuntu One service at startup. I can start it any time I like. But the problem is Ubuntu One is a hidden service. So let's unlock all the startup hidden services.

Open your terminal and fire up the following command:
$ sudo sed -i "s/NoDisplay=true/NoDisplay=false/g" /etc/xdg/autostart/*.desktop

Now open your "Startup Applications" GUI and you will be able to see a lot of things including Ubuntu One. Uncheck to make it disabled at startup. Enjoy :)

Use the follwing command to start or stop or to get more help later on for Ubuntu One:
$ u1sdtool --start
$ u1sdtool --quit
$ u1sdtool --help

Two other services I need on my system, but don’t want them to start unless I require them. They are running MySql and Apache.

To stop mysql from starting on boot:

sudo vim /etc/init/mysql.conf
# Comment out the following line
start on runlevel [2345]

To stop apache2 from starting on boot:
sudo update-rc.d -f apache2 remove

To enable apache2 on startup
sudo update-rc.d -f apache2 defaults


Thursday, November 3, 2011

Create Domain(s), Subdomain(s) as Virtual Host on Ubuntu

Step 1:
Open using gedit editor or as u like...
sudo gedit /etc/hosts


Step 2:
Add lines like below:

127.0.0.1         localhost
127.0.0.1         mydomain.dev www.mydomain.dev

Now save the file.


Step 3:
Open...

sudo gedit /etc/apache2/httpd.conf

Add the following peace of code:

NameVirtualHost *:80
<VirtualHost mydomain.dev:80>
     ServerName www.mydomain.dev
     ServerAlias mydomain.dev *.mydomain.dev
     DocumentRoot /home/my_user_dir/www
</VirtualHost>

Save the file and restart apache.
Test using your favorite web browser with your vertual domain link i.e. http://mydomain.dev
To restart apache use the following command sudo /etc/init.d/apache2 {start | stop | restart | status}
If you want the sites to be available and enabled to the world, look the following directories:

/etc/apache2/sites-available

This contains configuration files for sites which are available but not necessarily enabled.

/etc/apache2/sites-enabled

This directory contains site files which are enabled.

Example: www.mydomain.com (file inside /etc/apache2/sites-enabled/)
<VirtualHost *:80>
     ServerAdmin webmaster@mydomain.com
     ServerName  www.mydomain.com
     ServerAlias mydomain.com

     DocumentRoot /home/my_user_dir/www/www.mydomain.com
     <Directory />
          Options FollowSymLinks
          AllowOverride None
     </Directory>
     <Directory /home/my_user_dir/www/www.mydomain.com/>
          Options Indexes FollowSymLinks MultiViews
          AllowOverride None
          Order allow,deny
          allow from all
     </Directory>

     ScriptAlias /cgi-bin/ /home/my_user_dir/www/www.mydomain.com/cgi-bin/
     <Directory "/usr/lib/cgi-bin">
          AllowOverride None
          Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
          Order allow,deny
          Allow from all
     </Directory>

     ErrorLog /home/my_user_dir/www/www.mydomain.com/error.log

     # Possible values include: debug, info, notice, warn, error, crit,
     # alert, emerg.
     LogLevel warn

     CustomLog /home/my_user_dir/www/www.mydomain.com/access.log combined

     Alias /doc/ "/usr/share/doc/"
     <Directory "/usr/share/doc/">
          Options Indexes MultiViews FollowSymLinks
          AllowOverride None
          Order deny,allow
          Deny from all
          Allow from 127.0.0.0/255.0.0.0 ::1/128
     </Directory>

</VirtualHost>

You need to save the file and restart apache2, for the changes to be reflected.

Tuesday, October 19, 2010

Creating Multiple Virtual Sites on a WAMP Server Installation

Step 1: Tell your machine to answer to different names.

By default, Windows will answer to the name "localhost" for browser requests originating on the same machine (yours). If you have WAMP Server running, you can browse to http://localhost and see your WAMP site.  We can make Windows answer to multiple names by editing a file called "hosts" located in your /windows/system32 folder.  Browse to:

"C:\windows\system32\drivers\etc"

Once there, you should see a file titled "hosts".  Open that file with a text editor like notepad.  You may have to change the open dialog to "all files" in order to see it.  You should see a line that looks like this:

127.0.0.1        localhost

That tells Windows that the name "localhost" points to the machine who's IP address is 127.0.0.1, which is a standard address for "this machine".  We can multiple entries for 127.0.0.1, and your browser will then associate all of them with your local computer. In our case, let's create one called "testwebsite.dev".  Add a line to the hosts file so it looks like this:

127.0.0.1        localhost
127.0.0.1        testwebsite.dev

You can add as many entries as you like and your browser should display your WAMP Server site for all of them.  Save your hosts file and try visiting http://testwebsite.dev in your browser.  You should see your WAMP site.
If using Windows 7, you may need to open notepad as "Run as administrator" by rightclicking on notepad. If not you may not be able to save the file once edited because of restrictions.
Note: Do not create hosts entries for external sites.  This can cause hours of frustration and needless troubleshooting.  For example, if you added this line:

# Don't do this.
127.0.0.1        google.com

You would no longer be able to access google.com, because it is now associated with your local computer.  The request never reaches the Internet. The same applies to client domains.  For this reason, stick to something identifiable as dev, like "google.dev".

Step 2: Create a Client Site Folder

We need multiple site root folders to house multiple sites. Currently WAMP Server only has one site root, which typically lives at "C:\wamp\www".  Let's create another one at "C:\wamp\testwebsite".  Navigate to "C:\wamp", and click "File -> New -> Folder".  Rename your new folder to "testwebsite". Create a test file called "index.html" in "C:\wamp\testwebsite":
<html>
     <head>
          <title>Test Website</title>
     </head>
     <body>
          Hello from Test Website!
     </body>
</html>

Step 3: Tell Apache to Serve Multiple Sites by Name

WAMP configures Apache to serve a single site that usually lives in "C:\wamp\www".  Apache can handle multiple sites if we tell it where to look.  To open your WAMP Server Apache configuration, left-click the WAMP Server icon and select "Apache -> httpd.conf".  The file should open in notepad. Look for a line like this:

Listen 80

This tells Apache to listen for browser requests on port 80. Change it to this:

Listen *:80

This tells Apache to listen to port 80 of any address. Next look for lines like this:

# Virtual hosts
# Include conf/extra/httpd-vhosts.conf

This is the config file for appache virtual host websites. Now uncomment "#Include conf/extra/httpd-vhosts.conf" like "Include conf/extra/httpd-vhosts.conf" This lets appache find the hosted root folder for the said virtual website.

Step 4: Open and edit httpd-vhosts.conf file

Open the file "httpd-vhosts.conf" file located in folder "C:\wamp\bin\apache\Apache2.2.11\conf\extra". At the end of the file copy and past (modify if required) the following peace of code:

<VirtualHost *:80>
     ServerAdmin webmaster@testwebsite.dev
     DocumentRoot "C:/wamp/www/testwebsite"
     ServerName testwebsite.dev
     ErrorLog "logs/testwebsite.dev-error.log"
     CustomLog "logs/testwebsite.dev-access.log" common
</VirtualHost>

Step 5: Restart Apache and Test

Left-Click your WAMP Server tray icon and select "Restart All Services". Browse to http://testwebsite.dev and you should see your new site.