Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build LAMP PHP Development Environment under Linux

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article focuses on "how to build a LAMP PHP development environment under Linux". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to build a LAMP PHP development environment under Linux.

My OS is ubuntu 9.10. Thanks to the powerful features of apt-get, I refer to this article http://wiki.ubuntu.org.cn/index.php?title=Apache&variant=zh-cn#.E5.AE.89.E8.A3.85LAMP and easily complete the construction of LAMP.

If you can't tickle your hands, delete all the environment and build it again with the source package. The steps are as follows:

(since you are logged in with a non-root account, use sudo when root permission is required)

1. Installation of build-essential

# bulid-essential is a compilation tool needed to compile the source code package (CCMG + program)

# it is not installed by default under ubuntu, but sudo apt-get install build-essential can be executed under ubuntu

Install package build-essential_11.4.tar.gz

# installation commands

Tar-zxvf build-essential_11.4.tar.gz

Cd build-essential-11.4

. / configure

Make

Sudo make install

Make clean

II. Installation of MySql

Step.1

Installation of ncurses

# if the lack of ncurses package mysql compilation will report the error of No curses/termcap library found

Install package ncurses-5.6.tar.gz

Tar-zxvf ncurses-5.6.tar.gz

Cd ncurses-5.6

. / configure-prefix=/usr/local/ncurses-with-shared-without-debug-enable-widec

Make

Sudo make install

Make clean

Step.2

Installation of mysql

Install package mysql-5.1.42.tar.gz

Step.a

# installation commands

Tar-zxvf mysql-5.1.42.tar.gz

Cd mysql-5.1.42

. / configure-- prefix=/usr/local/mysql-- with-named-curses-libs=/usr/local/ncurses/lib/libncursesw.so.5.6-- with-charset=gbk

#-the installation path of prefix=/usr/local/mysql mysql

# description of mysql profile path: mysql searches for my.cnf in the following order

# / etc,mysql installation directory, such as / usr/local/mysql/etc, and the data directory under the installation directory, such as / usr/local/mysql/data, whichever is found first. The configuration of my.cnf under / etc is a global setting

#-installation path for with-named-curses-libs=/usr/local/ncurses/lib/libncursesw.so.5.6 ncurses library files

#-default storage path for localstatedir=/usr/local/mysql/var database (you can set other paths, such as / var/lib/mysql)

#-with-charset=gbk settings database supports Chinese character set

Make

Sudo make install

Step.b

# copy the mysql configuration file to the target directory / usr/local/mysql/etc

# create a new / usr/local/mysql/etc directory (this directory is not automatically created)

Sudo mkdir / usr/local/mysql/etc

Sudo cp support-files/my-medium.cnf / usr/local/mysql/etc/my.cnf

# Delete temporary files generated by installation (be sure to execute after copying the configuration file, otherwise my-medium.cnf will be deleted)

Make clean

Step.c

# add a linux system group named mysql (refer to mysql manual 2.8.1. Source code installation overview)

Sudo groupadd mysql

# create a new linux system user named mysql and add it to the mysql system group

# if Linux only launches the command line interface, you can add the required accounts with the following actions

# sudo useradd-M-s / bin/false-g mysql mysql

#-M this option does not create a user directory

#-s specifies that the shell,/bin/false used by the newly created user means that the user cannot log in to the system

#-g mysql adds user mysql to group mysql

# the time desktop system I am using now, use the above command to add an account. The mysql user is displayed in the login interface when the system starts, although it does not log in.

# use the following command instead, the mysql account will not be displayed on the login screen

Sudo useradd-r-s / bin/false-g mysql mysql

#-r set up a system account without creating a user directory, and the uid assigned by the user is less than 1000

Step.d

# create mysql Authorization form

# if you run a command with root, you should use the-- user option. The value of the option should be the same as the login account you created in stpe.czz. If you use this user login to run the command, you can omit the-- user option

Sudo / usr/local/mysql/bin/mysql_install_db-- user=mysql

Step.e

# enter the installation directory of mysql (/ usr/local/mysql)

Cd / usr/local/mysql

# change all attributes of the file to root users

Sudo chown-R root.

# change all attributes of the data directory to mysql users (that is, users created in step.c)

Sudo chown-R mysql var

# change the group attribute to mysql group

Sudo chgrp-R mysql.

Step.f

# start the mysql service

Sudo / usr/local/mysql/bin/mysqld_safe-- user=mysql &

# logging in to the database

/ usr/local/mysql/bin/mysql-uroot

Mysql installation is complete

III. Installation of Apache

# dynamic compilation using DSO. For the difference between dynamic compilation and static compilation, please refer to http://www.ha97.com/2612.html

Install package httpd-2.2.14.tar.gz

Tar-zvxf httpd-2.2.14.tar.gz

Cd httpd-2.2.14

. / configure-- prefix=/usr/local/apache-- enable-mods-shared=most-- enable-so

#-prefix=/usr/local/apache installs apache to the / usr/local/apache path

#-enable-mods-shared=most dynamically compiles all standard modules into DSO modules

#-the enable-so apache core loads DSO, but does not actually compile any dynamic modules

Make

Make install

Make clean

# start apache

Sudo / usr/local/apache/bin/apachectl start

# Open the browser and enter the browser and you will see It works!

Apache installation is complete

IV. Installation of PHP

Step.1

Installation of freetype

Install package freetype-2.3.11.tar.gz

# installation commands

Tar-zxvf freetype-2.3.11.tar.gz

Cd freetype-2.3.11

. / configure-- prefix=/usr/local/freetype

Make

Sudo make install

Make clean

Step.2

Installation of zlib

Install package zlib-1.2.3.tar.gz

# installation commands

Tar-zxvf zlib-1.2.3.tar.gz

Cd zlib-1.2.3

. / configure

Make

Sudo make install

Make clean

# changed the installation directory of zlib such as / usr/local/zlib during installation, and the installation of the modified libpng was also successful. When you failed to install the gd library, you had no choice but to install zlib to the default path.

Step.3

Installation of libpng

Install package libpng-1.4.0.tar.gz

# installation commands

Tar-zxvf libpng-1.4.0.tar.gz

Cd libpng-1.4.0

. / configure-- prefix=/usr/local/libpng

Make

Sudo make install

Make clean

# many people use cp scripts/makefile.std makefile instead of. / configure (the difference between the two remains to be verified)

Step.4

Installation of jpeg

Install package jpegsrc.v7.tar.gz

# installation commands

Tar-zxvf jpegsrc.v7.tar.gz

Cd jpeg-7

. / configure-- prefix=/usr/local/jpeg7

Make

Sudo make install

Make clean

# many people manually set up the directory structure of jpeg. I don't know whether it is because of different or other reasons (to be verified)

# all the above packages are required for the gd library. Install the GD library below

Step.5

Installation of gd library

Install package gd-2.0.35.tar.gz

# installation commands

Step.a

Tar-zxvf gd-2.0.35.tar.gz

Cd gd-2.0.35

. / configure-prefix=/usr/local/gd2-with-freetype=/usr/local/freetype-with-png=/usr/local/libpng-with-jpeg=/usr/local/jpeg7

Step.b

# Edit the Makefile file and find about 232 lines

# see something like CPPFLAGS =-I/usr/local/freetype/include/freetype2-I/usr/local/freetype/include-I/usr/local/freetype/include-I/usr/local/jpeg7/include

# modified to CPPFLAGS =-I/usr/local/freetype/include/freetype2-I/usr/local/freetype/include-I/usr/local/freetype/include-I/usr/local/libpng/include-I/usr/local/jpeg7/include

Step.c

# Edit the gd_png.c file to find if (! png_check_sig (sig, 8)) {/ * bad signature * /

# modified to if (png_sig_cmp (sig, 0,8)) {

Step.d

# execute command

Make

Sudo make install

Make clean

# installation of gd library is complete

Step.6

Installation of libxml2

# libxml2 is used to parse xml

# installation commands

Tar-zxvf libxml2-2.6.26.tar.gz

Cd libxml2-2.6.26

. / configure-- prefix=/usr/local/libxml

Make

Make install

Make clean

Step.7

Installation of php

Install package php-5.3.1.tar.gz

# installation commands

Step.a

Tar-zxvf php-5.3.1.tar.gz

Cd php-5.3.1.tar

. / configure-- prefix=/usr/local/php-- with-apxs2=/usr/local/apache/bin/apxs-- with-mysql=/usr/local/mysql-- with-libxml-dir=/usr/local/libxml2-- with-zlib-- with-png-dir=/usr/local/libpng-- with-jpeg-dir=/usr/local/jpeg7-- with-freetype-dir=/usr/local/freetype-- with-gd=/usr/local/gd2

Make

Sudo make install

Make clean

Step.b

Copy the PHP configuration file

Sudo cp php.ini-development / usr/local/php/lib/php.ini

# php configuration file names vary from version to version. There are two files in the current version, php.ini-development (used in development environment) php.ini-production (used in production environment)

Step.d

Modify apache configuration file / usr/local/apache/conf/httpd.conf

# add support for php

LoadModule php5_module modules/libphp5.so

AddType application/x-httpd-php .php

Step.e

# if you log in with a root account, skip this step

# change directory web directory permissions

Sudo chown-R login user: login user / usr/local/apache/htdocs

Step.f

# restart apache

Sudo / usr/local/apache/bin/apachectl restart

At this point, I believe you have a deeper understanding of "how to build a LAMP PHP development environment under Linux". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report