LAMP Installation Configuration Apache+php+mysql environment

Source: Internet
Author: User
Tags bz2 curl install php mysql client pack posix time limit phpmyadmin

LAMP installation Configuration
Configuring the Environment
Operating system: Redhat Enterprise as 4
Packages installed: httpd2.0.4, mysql4.1,libxml2.6.16, zlib1.2.1.2,gd2.0.28, libpng1.2.7
Description: The various installation instructions on the Internet are not very good description of the reasons for configuration parameters, this article will be as far as possible to identify the need for each step. The installed package is not required, where MySQL can be installed independently, and the httpd of the RPM package is installed because it is not mod-so, and if you want to support PHP or another module, force the Remove reinstall encoded version. #rpm--nodeps--erase httpd
Other modules that PHP may need to be functional description:
Libxml2:xml Parsing Library
Zlib: Open Source Compression Library
GD: Graphics Library
Libpng: Libraries used to process PNG image format files
Freetype:truetype Font Drawing engine
Zendoptimizer:
JPEG Library:
Then download the file mysql,apache,php, please download the corresponding software at the following URL
http://www.apache.org/
http://www.php.net/
http://www.mysql.com/

First step: Install Apache
Enter the installation directory, followed by the following command:
Extract Source Pack
# TAR-ZXF Httpd-2.0.55.tar.gz
Enter the installation directory
# CD httpd-2.0.55
Configure Apache installation information, configure post-installation directory, module dynamic configuration, allow override reconfiguration
#./configure--prefix=/usr/local/apache--enable-modules=so--enable-rewrite
Perform make installation
# make; Make install

Step Two: Configure Apache
modifying httpd.conf files
ServerName Modify host name, if no DNS, then use IP instead
ServerName 192.168.36.163:80

DocumentRoot Modify the document path, where you want to place the destination page
DocumentRoot "/var/www/html"


DirectoryIndex Modify the default first name
DirectoryIndex index.html index.php index.htm

Step Three: Install PHP
Enter the installation directory, followed by the following command:
Extract Source Pack
# TAR-ZXF Php-5.0.5.tar.gz
Enter the installation directory
# CD php-5.05
Configure PHP installation information, configure post installation directory, module dynamic configuration, allow rewrite reconfiguration
# Way One
./configure--prefix=/usr/local/php--with-apxs2=/usr/local/apache/bin/apxs--with-mysql=/usr/local/mysql/-- With-curl=/usr/local/curl--enable-ftp--with-libxml-dir=/usr/local/libxml2--with-expat-dir=/usr/lib-- Enable-soap--with-xsl=/usr/local/libxslt--enable-xslt--with-gd=/usr/local/gd2/--with-jpeg-dir=/usr/local/jpeg6 /--with-zlib-dir=/usr/lib--with-png--with-freetype-dir=/usr/local/freetype--enable-mbstring

#方式二
'./configure '--prefix=/usr/local/php '--with-apxs2=/usr/local/apache/bin/apxs '--with-mysql=/usr/local/mysql/ '--with-mssql=/usr/local/freetds/'--with-curl=/usr/local/curl '

of which./configure after the
--prefix=/usr/local/php
--with-apxs2=/usr/local/apache/bin/apxs
--with-mysql=/usr/local/mysql/
--with-libxml-dir
--enable-mbstring
is the necessary option

--with-gd=/usr/local/gd2/
--with-jpeg-dir=/usr/local/jpeg6/
--with-png
--with-zlib-dir=/usr/lib
--with-freetype-dir=/usr/local/freetype
This is the configuration option for PHP to support the GD library

Perform make installation
# make; Make install

Fourth step: Configure HTTPD.CONF to have Apache support PHP
# vi/usr/local/apache/conf/httpd.conf
PHP after installation will automatically add the following line in httpd.conf (if not, please manually added):
LoadModule Php5_module modules/libphp5.so

Find AddType application/x-gzip gz. tgz to add the following content below
AddType application/x-httpd-php. php
AddType Application/x-httpd-php-source. Phps

Restart Apache
#/usr/local/apache/bin/apachectl Restart

Attached: Some important configuration options for Apache
1 Directory

Options FollowSymLinks
AllowOverride None
Order Deny,allow #说明先执行denny, then execute allow
Allow from all #此句是允许所有地址访问, where you can set specific IP access rights

2 scriptalias/cgi-bin/"/var/www/cgi-bin/" #脚本路径
3 redirects (HTTP return status code)
ErrorDocument "The server made a boo boo."
ErrorDocument 404/missing.html
ErrorDocument 404 "/cgi-bin/missing_handler.pl"
ErrorDocument 402 http://www.example.com/subscription_info.html

Oh, I began to learn PHP, learning PHP first to learn to build a lamp (linux+apache+mysql+php), I configured a day to configure the success of the installation documents are all Chinese, fortunately there is a teacher in the next step of the step-by-step for me to explain carefully, I just configure it, I want to thank my teacher here!
Well, below I will introduce you to configure every step of lamp, you follow my steps to do can certainly configure the success, but also save everyone look distressed English time.
The operating system I use is red Hat linux9,apache:httpd-2.0.53.tar.gz,mysql:mysql-standard-4.1.10-pc-linux-gnu-i686.tar.gz,php: php-4.3.10.tar.bz2.
First check to see if the operating system has Apache, Mysql, PHP installed, and remove it if it has been installed.
To check if MySQL is installed as an example:
#rpm –qa |grep–i MySQL
If there are any packages displayed, use the
#rpm-E package name--nodeps Delete
We can also use the following method to remove the MySQL that has been installed:
#for i in ' rpm–qa|grep–i MySQL '
>do rpm–e $i –nodeps
>done

After checking out, we started installing Apache, MySQL, and PHP.
First, install APAHCE server
#tar-ZXVF httpd-2.0.53.tar.gz-c/usr/local//extract Apahce2 to/usr/local directory
#./configure--enable-so
#make
#make Install

Second, the installation of PHP
#tar-ZJVF php-4.3.10.tar.bz2//uncompressed PHP Package
#cd. /php-4.3.10//Enter into PHP uncompressed directory
#./configure--with-apxs2=/usr/local/apache/bin/apxs--with-mysql
#make
#make Install
#cp Php.ini-dist/usr/local/lib/php.ini//php.ini-dist files are copied to the/usr/local/lib folder under the name PHP.ini
#cd/usr/local/apahce2/conf//Enter/usr/local/apache2/conf folder
#vi http.conf//Enter http.conf file
Php4:loadmodule Php4_module libexec/libphp4.so
Php5:loadmodule Php5_module libexec/libphp5.so

Add parsing, add PHP support for APAHCE, join:
AddType application/x-httpd-php. php. phtml
AddType Application/x-httpd-php-source. Phps
After joining Save exit Wq.

#/usr/local/apache2/bin/apachectl Start//Starting APAHCE service

Sometimes you will find that the wrong system defaults on the IP address and port number that are not specified, modify the method:
#cd/usr/local/apache2/conf
#vi http.conf
/ServerName
Find servername www.example.com:80 and change it to servername 127.0.0.1:80
Save Exit Wq After you have finished modifying it.
Now restart the APAHCE service and it's OK!

We can open the browser, enter http://your server address test Apahce whether the configuration is successful, if successful will appear APAHCE server's "feather" flag. It also indicates that static Web pages are configured in the/usr/local/apahce2/htdocs folder, and that Apache can display static Web pages. For example: http://127.0.0.1, the APAHCE server "feather" flag will appear when the configuration succeeds.

Here we will write a simple PHP Web page to test whether PHP is configured successfully
#cd/usr/local/apahce2/htdocs//into the/usr/local/apache2/htdocs folder, to write PHP Dynamic Web page
#vi test.php//Establish test.php
PHPinfo (); Write a PHP test page www.111cn.net
?>
Save Exit Wq When you are finished writing.
OK, then we'll restart the APAHCE service to see the PHP test page. #/usr/local/apache2/bin/apachectl restart
Then open the browser and enter http://127.0.0.1:80/test.php in the Address bar.
Displays information about APAHCE, PHP, and servers.

installing MySQL
#tar-ZXVF mysql-standard-4.1.10-pc-linux-gnu-i686.tar.gz//uncompressed MySQL Packets
#cd mysql-standard-4.1.10-pc-linux-gnu-i686//Enter MySQL uncompressed directory
#groupadd MySQL//add MySQL Group
#useradd-G MySQL MySQL//add MySQL user and add to MySQL group
#cd/usr/local//Enter/usr/local folder
#gunzip </path/to/mysql-version-os.tar.gz | Tar xvf-///First unpack with tar, output data to Gunzip
#ln-S Full-path-to-mysql-version-os mysql//build soft link MySQL to current directory
#cd/usr/local/mysql//Enter/usr/local/mysql folder
#scripts/mysql_install_db--user=mysql//initialization of the MySQL database, scripts: directory name;--user=mysql:mysql user initialization of MySQL database
#chown-R Root.
#chown-R MySQL Data
#chgrp-R MySQL.
#bin/mysqld_safe--user=mysql &

http://dev.mysql.com/doc/refman/... L#installing-source

Linux Simple installation Mysql+apach+php+phpmyadmin

Linux Simple installation Mysql+apach+php+phpmyadmin
June 02, 2008, Monday 01:00
See a lot of apache+mysql+php installation documents from the Internet, but some will always have write errors, recently I found some documents on the Internet, and correct the errors, wrote a detailed installation steps for everyone's learning and reference, if there is a mistake and corrected:

My system is Redhat AS5 recommend that you install completely, so as not to install when the relevant compiler and so on.
First, install MySQL (mysql-5.0.21.tar.gz)
# tar zxf mysql-5.0.21.tar.gz
# CD mysql-5.0.21
#./configure--prefix=/usr/local/mysql--sysconfdir=/etc--localstatedir=/var/lib/mysql/
Description
#prefix =/usr/local/mysql mysql Installation target directory
Path to #sysconfdir =/etc my.ini configuration file
#localstatedir the path that the =/var/lib/mysql database stores
# make
# make Install
# Groupadd MySQL
# useradd Mysql-g MySQL
# CP SUPPORT-FILES/MY-MEDIUM.CNF/ETC/MY.CNF
# (this folder is in the original compiled directory) asks if you want to overwrite, enter "Y"
#/usr/local/mysql/bin/mysql_install_db--user=mysql
# Cd/usr/local/mysql Then Set permissions
# Chown-r Root. #设定root能访问/usr/local/mysql
# chown-r Mysql/var/lib/mysql #设定mysql用户能够访问/var/lib/mysql
# chgrp-r Mysql/usr/local/mysql #设定mysql组能访问/usr/local/mysql
#/usr/local/mysql/bin/mysqld_safe--user=mysql & #安全启动mysql
# path= $PATH:/usr/local/mysql/bin//Let the system find MySQL
# Export PATH
# echo "/usr/local/mysql/lib/mysql" >>/etc/ld.so.conf
# ldconfig-v

Second, the installation of Apache (httpd-2.0.59.tar.gz)
# tar zxf httpd-2.0.59.tar.gz
# CD httpd-2.0.59
#./configure--prefix=/usr/local/apache--enable-so--enable-rewrite--enable-mods-shared=most
Description
--ENABLE-SO option: Let Apache can support DSO mode, note that here is the Apache2.0 syntax. If your Apache is version 1.3, you should change to--enable-module=so.
--enable-mods-shared=most option: Tells the compiler to compile all standard modules into the DSO module. If you use Apache1.3, change to--enable-shared=max.
--enable-rewrite option: Support address rewrite, use 1.3 version of Friends please change it to--enable-module=rewrite.

# make
# make Install
# vi/usr/local/apache/conf/httpd.conf #启动Apache中的php选项, find the next two lines
DirectoryIndex index.php #修改默认启动页
DocumentRoot #指定主目录 (/usr/local/apache2/htdocs)
ServerName 127.0.0.1:80
#/usr/local/apache/bin/apachectl Start
Third, install PHP (php-5.1.6.tar.bz2)
# tar jxf php-5.1.6.tar.bz2
# CD php-5.1.6
#./configure--with-apxs2=/usr/local/apache/bin/apxs--disable-debug--enable-safe-mode--enable-trans-sid-- With-xml--with-mysql=/usr/local/mysql--enable-short-tags--with-gd--with-zlib--with-jpeg-- Enable-memory-limit--disable-posix--with-config-file-path=/usr/local/lib
Description
? --with-apxs2=/usr/local/apache/bin/apxs This is the location to join the DSO module in Apache
? --disable-debug #关闭php内部调试
? --enable-safe-mode #打开php的安全模式
? --enable-trans-sid
? --with-xml #支持xml
? --with-mysql #支持mysql
? --enable-short-tags #支持PHP的短标记
? --WITH-GD #支持GD库
? --with-zlib #支持zlib
? --with-jpeg
? --with-png
? --enable-memory-limit
? --disable-posix
? --with-config-file-path=/usr/local/lib
Anyway, copy and paste on it,-_-.
#./configure--prefix=/usr/local/php--with-mysql=/usr/local/mysql--with-apxs2=/usr/local/apache/bin/apxs
Note: If Mysql+apache is the default installation, the Configure configuration method
#./configure--with-apxs2=/usr/sbin/apxs--disable-debug--enable-safe-mode--enable-trans-sid--with-xml-- With-mysql=/usr/share/mysql--enable-short-tags--with-gd--with-zlib--with-jpeg--with-png-- Disable-posix--with-config-file-path=/usr/local/lib
# make
# make Install
# CP Php.ini-dist/usr/local/lib/php.ini copy PHP configuration file
# cd/usr/local/lib/
# vi php.ini Modify configuration file
Register_globals = on generally 414 lines
Max_execution_time = 30; To 600 (increase the time limit for processing scripts)
Max_input_time = 600; Maximum output time 600 seconds
Memory_limit = 8M; 40M (in order to send 10M attachment)
Register_global =on
Post_max_size = 2M; PHP acceptable post method size 2M
File_uploads = on; Allow files to be uploaded
Upload_max_filesize = 2M; Max upload file 2M
Session.auto_start = 1; Session Auto Start
If compile Php:make error
Configure:error:Cannot find MySQL header files under Yes.
The MySQL client library is not bundled anymore.
Solution:
If you do not know where header file is, use the "find/-name mysql.h" command to find its location;
If you have a hand? The shadow of Shame B MySQL suite, directly specify the location.
Under./configure The parameter specifies the location of the header file (that is, the MySQL installation directory), as follows:
./configure--with-apxs2=/usr/local/apache2/bin/apxs--with-mysql=/usr/local/mysql
Iv. integrating Apache and PHP www.111cn.net
# vi/usr/local/apache/conf/httpd.conf modifies Apache's configuration file
Add: AddType application/x-httpd-php. php
AddType Application/x-httpd-php-source. PHPS/Note Add these two lines behind the other AddType
Make sure the following paragraph is in the file, and if not, add after all LoadModule
LoadModule Php5_module modules/libphp5.so
Because I installed a higher version so it is PHP5, if it is loadmodule php4_module modules/libphp4.so words can also
#/usr/local/apache/bin/apachectl Start//If this place is reported as the following error
Httpd:syntax error on line of/usr/local/apache/conf/httpd.conf:cannot load/usr/local/apache/modules/libphp5.so int O Server:/usr/local/apache/modules/libphp5.so:cannot Restore segment prot after Reloc:permission denied
Reason: Linux has a SELinux protection mode.
Solution:
1 ways to close selinux:
Vi/etc/selinux/config change selinux=enforcing to selinux=disabled needs to be restarted.
This approach can pose a risk to the server.
2 Do not close the SELinux method:
# Setenforce 0
# chcon-c-v-r-u system_u-r object_r-t textrel_shlib_t/usr/local/apache/modules/libphp5.so
# Service httpd Restart
# setenforce 1
Server httpd start Error: Starting httpd:[wed may 02:17:20 2008] [warn] module php4_module is already loaded, skipping
Solution: View # vi/usr/local/apache/conf/httpd.conf
Whether there are two identical instructions loadmodule php4_module modules/libphp4.so Delete one, you can
V. Installation of phpMyAdmin (phpmyadmin-2.6.0.tar.gz)
# tar zxf phpmyadmin-2.6.0.tar.gz
# MV Phpmyadmin-2.6.0/usr/local/apache/htdocs/
# vi config.inc.php Modify this file
$cfg [' Servers '] [$i] [' host '] = ' localhost '; Change to your database server hostname or IP address;
$cfg [' Servers '] [$i] [' user '] = ' root '; The user name of the MySQL database;
$cfg [' Servers '] [$i] [' password '] = '; Password for MySQL database;
Major changes to these items, save exit
Test:
http://IP/phpMyAdmin-2.6.0
Here you can modify the name of the phpMyAdmin-2.6.0 directory so that it is easier to access

Methods of solving cannot load/usr/local/apache/modules/libphp5.so

The last step restarts the Apache report with the following error:
Httpd:syntax error on line of/usr/local/apache/conf/httpd.conf:cannot load/usr/local/apache/modules/libphp5.so int O Server:/usr/local/apache/modules/libphp5.so:cannot Restore segment prot after Reloc:permission denied
Reason: Linux has a SELinux protection mode.
Solution:
1 ways to close selinux:
Vi/etc/selinux/config change selinux=enforcing to selinux=disabled needs to be restarted.
This approach can pose a risk to the server.
2 Do not close the SELinux method:
# Setenforce 0
# chcon-c-v-r-u system_u-r object_r-t textrel_shlib_t/usr/local/apache/modules/libphp5.so
# Service httpd Restart
# setenforce 1

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.