Structure of lamp under Ubuntu14.04 (Php&&python)

Source: Internet
Author: User
Tags auth

Build the Python environment:

Ubuntu14.04 self-with Python


Install Apache2

sudo apt-get install apache2


Installing apache2 to support Python modules

sudo apt-get install python-setuptools Libapache2-mod-wsgi


Restart Apache2

sudo service apache2 restart


installing MySQL

sudo apt-get install Mysql-server


Login MySQL

Mysql-u root-p


Install apache2 support MySQL module

sudo apt-get install Libapache2-mod-auth-mysql


Restart Apache2

sudo service apache2 restart


Installing the Mysql-python module


sudo apt-get install python-setuptools

sudo apt-get install libmysqld-dev

sudo apt-get install Libmysqlclient-dev

sudo apt-get install python-dev

sudo easy_install mysql-python

under test:

In the Python interactive window, the import mysqldb try, without an error, it is proved that the installation is good.

Build PHP Environment


Install Apache2

sudo apt-get install apache2

Installing PHP

sudo apt-get install php5

installing MySQL

sudo apt-get install Mysql-server

Other modules installed:

sudo apt-get install libapache2-mod-php5
 
sudo apt-get install libapache2-mod-auth-mysql
 
sudo apt-get install Php5-mysql
 
sudo apt-get install PHP5-GD

The first two are easy to understand, to the Apache can parse PHP, you need to use these two modules to find PHP engine.

The third is used in PHP to manipulate the MySQL database, most people have database programming experience, so this is not much to explain

Fourth GD library.


Apache2 Related Configuration

After the installation of the above modules, in fact, the basic match is OK, just a few small details of the problem

Basically many configurations are done in the/etc/apache2 directory and its subdirectories, so be sure to understand the directory structure.

1.apache root directory

After installing apache2, the root directory under/VAR/WWW, can be tested by http://localhost/.

Of course, you can also create a new file in the directory test.html to try http://localhost/test.html.

2.PHP parsing Problem

After installation seems to have a PHP resolution is a bit of a problem, browsing the PHP page will be saved, Apache did not resolve it as a Web page.

It is generally said that you need to add XXXX to the httpd.conf, which may be true for other Linux systems, but Ubuntu is a bit special.

The Ubuntu Apache2 is configured in the/etc/apache2 directory.

There is a apache2.conf file in this directory that covers all APACHE2 system configuration information by including other configuration files.

PHP parsing section in the configuration in the/etc/apache2/mods-available under the php5.conf and Php5.load, apache2.conf file does not include these two files, as long as included in the OK. Found in the apache2.conf.

# Include Module configuration:
 
include/etc/apache2/mods-enabled/*.load
 
include/etc/apache2/mods-enabled/ *.conf
After which you add
Include/etc/apache2/mods-available/php5.load
 
include/etc/apache2/mods-available/php5.conf

Another way is to link the two files to the mods-enabled directory:

sudo ln-s/etc/apache2/mods-available/php5.load/etc/apache2/mods-enabled/php5.load
 
sudo ln-s/etc/apache2/ Mods-available/php5.conf/etc/apache2/mods-enabled/php5.conf
This is a better way, without destroying the configuration structure of the apache2 itself.

3. Change the default directory of Apache2 to the current development directory

The default directory for APACHE2 is configured in the/etc/apache2/sites-enabled/00default file.

Locate the DocumentRoot item in the file and change the/var/www to your development directory for OK.

Of course, there is another way is not to edge the default directory, just under the var/www to create a link to your directory.

For example, your catalogue is in/home/username/phptest, so you just

sudo ln-s/home/username/phptest/var/www/phptest

This will allow you to access your working directory through http://localhost/phptest.

[note] The link file name cannot contain '. ', otherwise apache2 will attempt to parse it as a file and not reach the linked directory effect.

It is recommended in the latter way, so that multiple working directories can be developed in parallel.

Common commands in configuration

Restart Apache

sudo service apache2 restart
Simple test

For a simple test, create a new PHP file in the Phptest directory: test.php

<! DOCTYPE html>

Save exit.

Open the browser, enter: localhost/phptest/tset.php, you can see the results of our PHP operation. Good luck! :-)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.