4

I am learning PHP, which means I'd have to install LAMP on my laptop and I think LAMP would degrade my battery life which is already very low, So is there substitute to the LAMP so that I can see how the PHP pages renders on the browser? Please recommend a software to test the php webpage rendering, Some kind of virtual Web Server or something.

PS: yes, battery is the main reason I am trying to avoid LAMP, Because each time the system boots LAMP would start and I wont be working on that all the time.

1
  • using a light docker container like php-nginx should be a nice solution !
    – bcag2
    Apr 1 at 9:32

4 Answers 4

3

Running Apache and PHP will not burden your machine much more than its current state. The other solutions of "Install XAMPP, etc" will present the same problem. They're just other "LAMP" stacks you can install. I recommend installing lamp-server with tasksel by typing the following in the command line sudo tasksel install lamp-server Once LAMP Server is installed you can disable it from launching on start up:

sudo update-rc.d apache2 stop
sudo update-rc.d mysql stop

When you need to start either MySQL or Apache you can invoke it from the service command

sudo service apache2 start

to stop the service

sudo service apache2 stop

The advantage of installing lamp-server over other third party stacks, Ubuntu will constantly update and maintain these packages for you. You also are eligible for support here and on other Ubuntu support sites for questions. Most third party stacks need to be supported by their providers, which limits your outlets.

4
  • Also, because it isn't stated and is important, the localhost or 127.0.0.1 server is located in /var/www
    – dkuntz2
    Dec 8, 2010 at 23:45
  • @DKuntz2 Correct, however that can be changed in the VirtualHost /etc/apache2/sites-available/default - For instance I have all my code in ~/Projects so my DocumentRoot is /home/marco/Projects/ allowing me to visit localhost/<ProjectName> and keep permissions, etc in tact Dec 9, 2010 at 3:28
  • Understood, but that's a bit complex, and it's nice to let people know where things are initially. On a similar note, you'll also have to change the permissions of that folder, because you only have read access by default.
    – dkuntz2
    Dec 9, 2010 at 3:43
  • Mysql isn't usng rc.d anymore but uses upstart instead!
    – papukaija
    Jun 24, 2011 at 12:31
3

LAMPP is just an easy way of running apache with php, mysql and some other stuff. If you were not using LAMPP, you would have to install and configure these (or an alternate webserver) yourself. So in general, no.

You don't have to run lampp on system startup. It's as simple as opening a command line and typing sudo /opt/lampp/lampp start to start it, or sudo /opt/lampp/lampp stop to stop it.

I'm using Gnome Do a lot, and have made some scripts to help me. I have put launchers in my application menu to run these scripts, and can therefore start them from Gnome Do.

The script to start lampp and show progress via notify-osd:

#!/usr/bin/python

import pynotify
import os

pynotify.init('Lampp loader')

imageURI = 'file:///opt/lampp/xampp.png'
notifyString = "Powering up lampp\n"

n = pynotify.Notification("lampp", notifyString, imageURI)
n.show()
f = os.popen('gksudo /opt/lampp/lampp start')
try:
    for line in f:
        notifyString += line
        n.update("lampp",notifyString)
        n.show()
finally:
    f.close()

And the similar to stop lampp: #!/usr/bin/python

import pynotify
import os

pynotify.init('Lampp loader')

imageURI = 'file:///opt/lampp/xampp.png'
notifyString = "Powering down lampp\n"

n = pynotify.Notification("lampp", notifyString, imageURI)
n.show()
f = os.popen('gksudo /opt/lampp/lampp stop')
try:
    for line in f:
        notifyString += line
        n.update("lampp",notifyString)
        n.show()
finally:
    f.close()

Both require python and pynotify (sudo apt-get install python-notify).

To create a launcher, simply right click on the Applications menu, select Edit Menus, select a category to the left, and click the New Item button to the right. Put the path to the script in the command field, and make sure the file is executable.

0

In order for PHP to run, you definetely need a web server installed.
If apache is not preferred, you could try lighttpd, nginx or abyss.

The only part that is really not necessary is MySQL, if you're not interested in having any database backend.

On the other hand, you can just install LAMP and make sure that the servers don't start automatically at boot by running:

sudo update-rc.d mysql stop
sudo update-rc.d apache2 stop
0

You do need a LAMP server to run PHP code, however, I would recommend you to try XAMPP (a.k.a. LAMPP).

It's pretty easy to set up:

  1. Download the latest version of XAMPP as a .tar.gz archive.
  2. Extract the archive into the /opt directory:
    $ sudo tar xvfz xampp-linux-<version>.tar.gz -C /opt
  3. The server is already configured as a development server, so you don't need to do anything else.

XAMPP does not start automatically when the system boots, so it shouldn't drain your battery unless you start it manually:

$ sudo /opt/lampp/lampp start

Then just put your PHP files into the /opt/lampp/htdocs directory, and they should be available at http://localhost/ immediately. When you're done, just stop the server again:

$ sudo /opt/lampp/lampp stop
2
  • LAMPP, XAMPP are LAMP stacks. Dec 8, 2010 at 22:08
  • @Marco, I know, I never said it wasn't, but my point was that it solves his problem, by not starting when the system boots and thus not unnecessarily draining his battery.
    – Frxstrem
    Dec 8, 2010 at 22:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .