Build a lamp environment (III)

Source: Internet
Author: User

Compile and install PHP, MySQL, and Apache

1. Download Software:

# Wget http://apache.etoak.com/httpd/httpd-2.2.11.tar.gz
# Wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.35.tar.gz/from/ftp://ftp.jaist.ac.jp/pub/mysql/
# Wget http://cn2.php.net/get/php-5.2.9.tar.bz2/from/cn.php.net/mirror

Zendoptimizer: http://www.zend.com/en/products/guard/downloads

2. Compile and install MySQL

# Tar zxvf mysql-5.1.35.tar.gz

# Cd mysql-5.1.35

#./Configure \
"-- Prefix =/usr/local/MySQL "\
"-- Localstatedir =/var/lib/MySQL "\
"-- With-Comment = source "\
"-- With-server-suffix =-comsenz "\
"-- With-mysqld-user = MySQL "\
"-- Without-Debug "\
"-- With-big-tables "\
"-- With-charset = GBK "\
"-- With-collation = gbk_chinese_ci "\
"-- With-extra-charsets = all "\
"-- With-pthread "\
"-- Enable-static "\
"-- Enable-thread-safe-client "\
"-- With-client-ldflags =-all-static "\
"-- With-mysqld-ldflags =-all-static "\
"-- Enable-Cycler "\
"-- Without-isam "\
"-- Without-InnoDB "\
"-- Without-NDB-Debug"

# Make

# Make install

Attached MySQL Character Set settings table

Show Character Set;
+ ---------- + ----------------------------- + --------------------- +
| Charset | description | default collation |
+ ---------- + ----------------------------- + --------------------- +
| Big5 | big5 traditional Chinese | big5_chinese_ci |
| Dec8 | dec West European | dec8_swedish_ci |
| Cp850 | dos West European | cp850_general_ci |
| HP8 | HP West European | hp8_english_ci |
| Koi8r | KOI8-R relcom Russian | koi8r_general_ci |
| Latin1 | cp1252 West European | latin1_swedish_ci |
| Latin2 | ISO 8859-2 Central European | latin2_general_ci |
| Swe7 | 7bit Swedish | swe7_swedish_ci |
| ASCII | us ASCII | ascii_general_ci |
| Ujis | EUC-JP Japanese | ujis_japanese_ci |
| Sjis | shift-JIS Japanese | sjis_japanese_ci |
| Hebrew | ISO 8859-8 Hebrew | hebrew_general_ci |
| Tis620 | tis620 Thai | tis620_thai_ci |
| Euckr | EUC-KR Korean | euckr_korean_ci |
| Koi8u | KOI8-U Ukrainian | koi8u_general_ci |
| Gb2312 | gb2312 Simplified Chinese | gb2312_chinese_ci |
| Greek | ISO 8859-7 Greek | greek_general_ci |
| Cp1250 | Windows Central European | cp1250_general_ci |
| GBK Simplified Chinese | gbk_chinese_ci |
| Latin5 | ISO 8859-9 Turkish | latin5_turkish_ci |
| Armscii8 | ARMSCII-8 Armenian | armscii8_general_ci |
| Utf8 | UTF-8 Unicode | utf8_general_ci |
| Ucs2 | UCS-2 Unicode | ucs2_general_ci |
| Cp866 | dos Russian | cp866_general_ci |
| Keybcs2 | dos kamenicky Czech-Slovak | keybcs2_general_ci |
| Macce | Mac Central European | macce_general_ci |
| Macroman | Mac West European | macroman_general_ci |
| Cp852 | dos Central European | cp852_general_ci |
| Latin7 | ISO 8859-13 Baltic | latin7_general_ci |
| Cp1251 | Windows Cyrillic | cp1251_general_ci |
| Cp1256 | Windows Arabic | cp1256_general_ci |
| Cp1257 | Windows Baltic | cp1257_general_ci |
| Binary pseudo charset | binary |
| Geostd8 | geostd8 Georgian | geostd8_general_ci |
| Cp932 | sjis for Windows Japanese | cp932_japanese_ci |
| Eucjpms | ujis for Windows Japanese | eucjpms_japanese_ci |
+ ---------- + ----------------------------- + --------------------- +

 

 

# Useradd MySQL
# Cd/usr/local/MySQL
# Bin/mysql_install_db -- user = MySQL
# Chown-r root: MySQL.
# Chown-r MySQL/var/lib/MySQL
# Cp share/MySQL/my-huge.cnf/etc/My. CNF
# Cp share/MySQL. Server/etc/rc. d/init. d/mysqld
# Chmod 755/etc/rc. d/init. d/mysqld
# Chkconfig -- add mysqld
#/Etc/rc. d/init. d/mysqld start

# Bin/MySQL-u Root Password "password_for_root"

3. Compile and install Apache

# Cd/usr/local/src
# Tar xjvf httpd-2.2.3.tar.bz2
# Cd httpd-2.2.3
#./Configure \
"-- Prefix =/usr/local/apache2 "\
"-- Enable-module = So "\
"-- Enable-Deflate = shared "\
"-- Enable-expires = shared "\
"-- Enable-Rewrite = shared "\
"-- Enable-static-support "\
"-- Enable-static-htpasswd "\
"-- Enable-static-htdigest "\
"-- Enable-static-rotatelogs "\
"-- Enable-static-logresolve "\
"-- Enable-static-htdbm "\
"-- Enable-static-AB "\
"-- Enable-static-checkgid "\
"-- Disable-userdir"
# Make
# Make install
# Echo '/usr/local/apache2/bin/apachectl start'>/etc/rc. Local

4. Compile and install PHP

# Cd/usr/local/src
# Tar xjvf php-5.2.0.tar.bz2
# Cd php-5.2.0
#./Configure \
"-- Prefix =/usr/local/PHP "\
"-- With-apxs2 =/usr/local/apache2/bin/apxs "\
"-- With-config-file-Path =/etc "\
"-- With-mysql =/usr/local/MySQL "\
"-- With-libxml-Dir =/usr/local/libxml2 "\
"-- With-Gd =/usr/local/GD2 "\
"-- Enable-Gd-native-TTF "\
"-- With-JPEG-Dir "\
"-- With-PNG-Dir "\
-- With-bz2 "\
"-- With-FreeType-Dir "\
"-- With-iconv-Dir "\
"-- With-zlib-Dir "\
"-- Enable-mbstring "\
"-- Disable-ipv6" \ # IPv6 is far away from us, don't use it for now
"-- Disable-cgi" \ # disable CGI support for security reasons
"-- Disable-CLI" # For security reasons, it is forbidden to compile the php Command Line shell command.
# Make
# Make install
# Cp PHP. ini-Dist/etc/PHP. ini

Configure Error
"Configure: Error: LibPNG. (A | so) Not found ."

Check FreeType, libjpeg, and libpng one by one

The procedure is as follows:

1. Check whether FreeType is installed
# Rpm-Qa | grep FreeType
Compile FreeType: http://www.freetype.org/index2.html if not
#./Configure -- prefix =/usr/local/FreeType
# Make & make install
2. Check whether libjpeg is installed.
# Rpm-Qa | grep libjpeg
Compile libjpeg: http://www.ijg.org/files/ if no
I haven't installed libjpeg either. Download it and start compiling.
Jpegsrc.v6b.tar.gz
# Tar-xzvf restart src.v6b.tar.gz
# Cd jpeg-6b/
#./Configure -- prefix =/usr/local/JPEG -- enable-shared
# Make & make install
An error occurred while making install:
/Usr/bin/install-C-M 644 jconfig. h/usr/local/JPEG/include/jconfig. h
/Usr/bin/install: cannot create regular file '/usr/local/JPEG/include/jconfig. H': no such file or directory
Make: *** [install-headers] Error 1
/Usr/bin/install: cannot create regular file '/usr/local/JPEG/lib/libjpeg. so.62.0.0': no such file or directory
/Usr/bin/install: cannot create regular file '/usr/local/JPEG/bin/cjpeg': no such file or directory
Make: *** [install-lib] Error 1
... Create a directory by yourself...
# Mkdir-P/usr/local/JPEG/include
# Mkdir-P/usr/local/JPEG/lib
# Mkdir-P/usr/local/JPEG/bin
# Mkdir-P/usr/local/JPEG/man/Man1
OK, then the compilation is successful.
3. Check whether libpng is installed.
# Rpm-Qa libpng
If not, compile libpng: http://www.libpng.org/pub/png/libpng.html
#./Configure -- prefix =/usr/local/PNG
# Make & make install

After installation is complete

PHP configure parameters are adjusted as follows:

#./Configure \
"-- Prefix =/usr/local/PHP "\
"-- With-apxs2 =/usr/local/apache2/bin/apxs "\
"-- With-config-file-Path =/etc "\
"-- With-mysql =/usr/local/MySQL "\
"-- With-libxml-Dir =/usr/local/libxml2 "\
"-- With-Gd =/usr/local/GD2 "\
"-- Enable-Gd-native-TTF "\
"-- With-JPEG-Dir =/usr/local/JPEG "\
"-- With-PNG-Dir =/usr/local/PNG "\
-- With-bz2 "\
"-- With-FreeType-Dir =/usr/local/FreeType "\
"-- With-iconv-Dir "\
"-- With-zlib-Dir "\
"-- Enable-mbstring "\
-- Disable-ipv6 "\
"-- Disable-cgi "\
"-- Disable-CLI"

 

5. Install Zend Optimizer# Cd/usr/local/src

# Tar xzvf ZendOptimizer-3.2.0-linux-glibc21-i386.tar.gz
#./ZendOptimizer-3.2.0-linux-glibc21-i386/install. Sh
Do not restart Apache after installing Zend optimizer.

6. Integrate Apache and PHP

# Vi/usr/local/apache2/CONF/httpd. conf
Find:
Addtype application/X-gzip. GZ. tgz
Add
Addtype application/X-httpd-PHP. php
Addoutputfilterbytype deflate text/HTML text/plain text/XML

Find:
<Ifmodule dir_module>
Directoryindex index.html. var
</Ifmodule>
Change this row
<Ifmodule dir_module>
Directoryindex index.html index.htm index. php
</Ifmodule>

Find:
# Include CONF/extra/httpd-mpm.conf
# Include CONF/extra/httpd-info.conf
# Include CONF/extra/httpd-vhosts.conf
# Include CONF/extra/httpd-default.conf
Remove the previous "#", uncomment, and set the relevant module configuration file.

Save the modification and exit.
#/Usr/local/apache2/bin/apachectl restart

 

7. check and confirm the l.a. m.p environment information to improve PHP security

# Echo '#! /Usr/local/PHP/bin/PHP \
<? PHP \
Phpinfo ();\
?> '>/Usr/local/PHP/phpinfo. php
# Chmod 755/usr/local/PHP/phpinfo. php
#/Usr/local/PHP/phpinfo. php>/usr/local/PHP/phpinfo
# More/usr/local/PHP/phpinfo
Check whether the information in phpinfo is correct.

After confirming that PHP works properly, set in PHP. ini to improve PHP security.
# Vi/etc/PHP. ini
Find:
Disable_functions =
Set:
Disable_functions = phpinfo, passthru, exec, system, popen, chroot, escapeshellcmd, escapeshellarg, shell_exec, proc_open, proc_get_status, ini_restore

Then restart the apache service.

 

 

 

 

 

 

 

 

 

 

 

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.