Note:
Operating system: CentOS 6.5 64-bit
Requirements:
Compile and install the LAMP runtime environment
The software versions are as follows:
MySQL: mysql-5.1.73
Apache: httpd-2.2.31
PHP: php-5.2.17
Specific operations:
Preparation
1. Configure the firewall and enable port 80 and Port 3306
Vi/etc/sysconfig/iptables # Edit the firewall configuration file
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
* Filter
: Input accept [0: 0]
: Forward accept [0: 0]
: Output accept [0: 0]
-A input-m state -- state ESTABLISHED, RELATED-j ACCEPT
-A input-p icmp-j ACCEPT
-A input-I lo-j ACCEPT
-A input-m state -- state NEW-m tcp-p tcp -- dport 22-j ACCEPT
-A input-m state -- state NEW-m tcp-p tcp -- dport 3306-j ACCEPT
-A input-m state -- state NEW-m tcp-p tcp -- dport 80-j ACCEPT
-A input-j REJECT -- reject-with icmp-host-prohibited
-A forward-j REJECT -- reject-with icmp-host-prohibited
COMMIT
: Wq! # Save and exit
Service iptables restart # restart the firewall to make the configuration take effect.
II. Disable SELINUX
Vi/etc/selinux/config
# SELINUX = enforcing # Comment out
# SELINUXTYPE = targeted # Comment out
SELINUX = disabled # Add
: Wq! # Save and exit
Setenforce 0 # Make the configuration take effect immediately
III. System conventions
Software source code package storage location:/usr/local/src
Source code package compilation and installation location:/usr/local/software name
4. Download the software package
1. Download Apache
Http://www.apache.org/dist/httpd/httpd-2.2.31.tar.gz
2. Download MySQL
Http://mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.73.tar.gz
3. Download php
Http://museum.php.net/php5/php-5.2.17.tar.gz
4. Download libmcrypt (php extension)
Http://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
5. Download yasm (php extension)
Http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
6. t1lib (php extension)
Ftp://sunsite.unc.edu/pub/Linux/libs/graphics/t1lib-5.1.2.tar.gz
7. Download the gd Library installation package
Https://bitbucket.org/libgd/gd-libgd/downloads/libgd-2.1.0.tar.gz
8. libvpx (required by the gd Library)
Https://webm.googlecode.com/files/libvpx-v1.3.0.tar.bz2
9. tiff (required by the gd Library)
Http://download.osgeo.org/libtiff/tiff-4.0.3.tar.gz
10. libpng (required by the gd Library)
Ftp://ftp.simplesystems.org/pub/png/src/libpng16/libpng-1.6.15.tar.gz
11. freetype (required by the gd Library)
Http://ring.u-toyama.ac.jp/archives/graphics/freetype/freetype2/freetype-2.5.4.tar.gz
12. Required src (required by the gd Library)
Http://www.ijg.org/files/jpegsrc.v9a.tar.gz
Upload the software package to the/usr/local/src directory.
5. Install the compilation tool and library file (use the yum command for installation)
Yum install-y apr * autoconf automake bison bzip2 bzip2 * cloog-ppl compat * cpp curl-devel fontconfig-devel freetype * freetype-devel gcc-c ++ gtk + -devel gd gettext-devel glibc kernel-headers keyutils-libs-devel krb5-devel libcom_err-devel libpng * libpng-devel libjpeg * libsepol-devel runtime-devel libstdc ++-devel libtool * libgomp libxml2 libxml2-devel libXpm * libX * libtiff * make mpfr ncurses * ntp openssl nasm * openssl-devel patch pcre-devel perl php-common php-gd policycoreutils ppl telnet t1lib t1lib * wget zlib-devel
Installation
1. Install MySQL
Cd/usr/local/src
Tar zxvf mysql-5.1.73.tar.gz
Cd mysql-5.1.73
. /Configure -- prefix =/usr/local/mysql -- localstatedir =/usr/local/mysql/data/-- with-mysqld-ldflags =-all-static -- with-client-ldflags =-all-static -- with-unix-socket-path =/tmp/mysql. sock -- without-debug -- with-extra-charsets = all -- without-embedded-server -- enable-profiling -- enable-plugin er -- enable-thread-safe-client -- enable-shared -- with-server-suffix =-community -- with-plugins = innobase -- with-extra-charsets = all
Make
Make install
Note: During the make install compilation process, if you see the following line on the screen, which is stuck there, you will not be able to get through for a long time. Do not think it is a compilation error, or the server gets stuck. You only need to stick to it and wait patiently for a few minutes to complete the compilation!
Make [4]: Entering directory '/usr/local/src/mysql-5.1.73/mysql-test'
Groupadd mysql # Add a mysql Group
Useradd-g mysql-s/bin/false # Create a user mysql and add it to the mysql group. mysql users are not allowed to log on directly to the system.
Chown-R root/usr/local/mysql/# Allow root access
Chgrp-R mysql/usr/local/mysql/# Allow mysql group access
Cd/usr/local/mysql/# enter the mysql installation directory
Cp share/mysql/my-huge.cnf/etc/my. cnf # Copy the configuration file (note:/etc directory under the default my. cnf, directly overwrite it)
Cp share/mysql. server/etc/init. d/mysqld # Add Mysql to system startup
Chmod 755/etc/init. d/mysqld # execution permission
Vi/etc/profile # add the mysql service to the system environment variable:
Add the following line at the end
Export PATH = $ PATH:/usr/local/mysql/bin
Source/etc/profile # Make the configuration take effect immediately
The following two lines link the myslq library file to the default system location. You do not need to specify the mysql library file address when compiling software such as PHP.
Ln-s/usr/local/mysql/lib/mysql/usr/lib/mysql
Ln-s/usr/local/mysql/include/mysql/usr/include/mysql
/Usr/local/mysql/bin/mysql_install_db -- user = mysql -- datadir =/usr/local/mysql/data # generate a mysql system database
/Usr/local/mysql/bin/mysqld_safe -- user = mysql & -- datadir =/usr/local/mysql/data # start mysql
/Etc/rc. d/init. d/mysqld start # start
Chkconfig mysqld on # add to startup
Mysql_secure_installation # set the Mysql password
Press Y to enter the password twice as prompted.
Or directly change the password/usr/local/mysql/bin/mysqladmin-u root-p password "123456" # change the password
Service mysqld restart # restart
At this point, mysql installation is complete!
II. Install Apache
Cd/usr/local/src
Tar zxvf httpd-2.2.31.tar.gz
Cd httpd-2.2.31
. /Configure -- prefix =/usr/local/apache -- with-stored Ded-apr -- enable-module = so -- enable-deflate -- enable-expires -- enable-ssl -- enable-headers -- enable-module = rewrite -- enable-static-support -- enable-MoD-shared = all
Make # compile
Make install # install
/Usr/local/apache/bin/apachectl-k start # start
Vi/usr/local/apache/conf/httpd. conf # Edit the configuration file
Find: # ServerName www.example.com: 80
Changed to: ServerName www.osyunwei.com: 80
Find: DirectoryIndex index.html
Changed to: DirectoryIndex index.html index. php
Find Options Indexes FollowSymLinks.
Change to: Options FollowSymLinks # Do not display the directory structure
Locate AllowOverride None
Changed to: AllowOverride All # enable apache to support pseudo-static state, with three modifications made
LoadModule rewrite_module modules/mod_rewrite.so # cancel the preceding annotation and enable apache to support pseudo-static
Vi/etc/profile # add the apache service system environment variable and add the following line at the end
Export PATH = $ PATH:/usr/local/apache/bin
: Wq! # Save and exit
Cp/usr/local/apache/bin/apachectl/etc/rc. d/init. d/httpd # Add apache to the system startup
Vi/etc/init. d/httpd # edit the file in #! Add the following two lines under/bin/sh:
# Chkconfig: 2345 10 90
# Description: Activates/Deactivates Apache Web Server
: Wq! # Save and exit
Chown daemon. daemon-R/usr/local/apache/htdocs # Change the directory owner
Chmod 700/usr/local/apache/htdocs-R # change apache website directory permissions
Chkconfig httpd on # set startup
/Etc/init. d/httpd start
Service httpd restart
System O & M www.osyunwei.com reminder: Original System O & M content © copyright. For details, refer to the source and original link.
3. Install PHP
1. Install yasm
Cd/usr/local/src
Tar zxvf yasm-1.3.0.tar.gz
Cd yasm-1.3.0
./Configure
Make
Make install
2. Install libmcrypt
Cd/usr/local/src
Tar zxvf libmcrypt-2.5.8.tar.gz
Cd libmcrypt-2.5.8
./Configure
Make
Make install
3. Install libvpx
Cd/usr/local/src
Tar xvf libvpx-v1.3.0.tar.bz2
Cd libvpx-v1.3.0
./Configure -- prefix =/usr/local/libvpx -- enable-shared -- enable-vp9
Make
Make install
4. Install tiff
Cd/usr/local/src
Tar zxvf tiff-4.0.3.tar.gz
Cd tiff-4.0.3
./Configure -- prefix =/usr/local/tiff -- enable-shared
Make
Make install
5. Install libpng
Cd/usr/local/src
Tar zxvf libpng-1.6.15.tar.gz
Cd libpng-1.6.15
./Configure -- prefix =/usr/local/libpng -- enable-shared
Make
Make install
6. Install freetype
Cd/usr/local/src
Tar zxvf freetype-2.5.4.tar.gz
Cd freetype-2.5.4
./Configure -- prefix =/usr/local/freetype -- enable-shared
Make # compile
Make install # install
7. Install jpeg
Cd/usr/local/src
Tar zxvf restart src.v9a.tar.gz
Cd jpeg-9a
./Configure -- prefix =/usr/local/jpeg -- enable-shared
Make # compile
Make install # install
8. Install libgd
Cd/usr/local/src
Tar zxvf libgd-2.1.0.tar.gz # extract
Cd libgd-2.1.0 # go to the Directory
. /Configure -- prefix =/usr/local/libgd -- enable-shared -- with-jpeg =/usr/local/jpeg -- with-png =/usr/local/libpng --- freetype =/usr/local/freetype -- with-fontconfig =/usr/local/freetype -- with-xpm =/usr/-- with-tiff =/usr/local/tiff -- -vpx =/usr/local/libvpx # configuration
Make # compile
Make install # install
9. Install t1lib
Cd/usr/local/src
Tar zxvf t1lib-5.1.2.tar.gz
Cd t1lib-5.1.2
./Configure -- prefix =/usr/local/t1lib -- enable-shared
Make without_doc
Make install
10. Install php
Note: If the system is 64-bit, run the following two commands. Otherwise, an error will occur when installing php (the 32-bit system does not need to be executed)
\ Cp-frp/usr/lib64/libltdl. so */usr/lib/
\ Cp-frp/usr/lib64/libXpm. so */usr/lib/
Cd/usr/local/src
Tar-zvxf php-5.2.17.tar.gz
Cd php-5.2.17
Export LD_LIBRARY_PATH =/usr/local/libgd/lib
. /Configure -- prefix =/usr/local/php -- with-config-file-path =/usr/local/php/etc -- with-apxs2 =/usr/local/apache/bin/ apxs -- with-mysql =/usr/local/mysql -- with-mysqli =/usr/local/mysql/bin/mysql_config -- with-mysql-sock =/tmp/mysql. sock -- with-pdo-mysql =/usr/local/mysql -- with-gd -- with-png-dir =/usr/local/libpng -- with-jpeg-dir =/usr /local/jpeg -- with-freetype-dir =/usr/local/freetype -- with-xpm-dir =/usr/-- with-vpx-dir =/usr/local/libvpx /-- with-zlib-dir =/usr/local/zlib -- with-t1lib =/usr/local/t1lib -- with-iconv -- enable-libxml -- enable-xml -- enable-bcmath -- enable-shmop -- enable-sysvsem -- enable-inline-optimization -- enable-mbregex -- enable-mbstring -- enable-ftp -- enable-gd-native-ttf -- with-openssl -- enable-ttf- pcntl -- enable-sockets -- with-xmlrpc -- enable-zip -- enable-soap -- without-pear -- with-gettext -- enable-session -- with-mcrypt -- with-curl -- enable- ctype
Make # compile
Make install # install
Cp php. ini-production/usr/local/php/etc/php. ini # Copy the php configuration file to the installation directory
Rm-rf/etc/php. ini # Delete the built-in configuration file of the system
Ln-s/usr/local/php/etc/php. ini/etc/php. ini # Add a soft link to the/etc directory
Vi/usr/local/php/etc/php. ini # Edit
Find:; open_basedir =
Change to: open_basedir =.:/tmp/# It is important to prevent php Trojans from being cross-site!
Find: disable_functions =
Changed to disable_functions = passthru, exec, system, chroot, scandir, chgrp, chown, shell_exec, proc_open, proc_get_status, ini_alter, ini_alter, rewrite, dl, openlog, syslog, readlink, symlink, delimiter, dll, popen, disk_free_space, checkdnsrr, checkdnsrr, getservbyname, getservbyport, delimiter, posix_ctermid, delimiter, delimiter, posix_getegid, delimiter, posix_getgrnam, posix_getgroups, upper, lower, lower, posix_getpid, lower, posix_getpwnam, lower, lower, posix_getsid, posix_getuid, lower, posix_kill, posix_mkfifo, lower, posix_setsid, posix_setuid, posix_strerror, posix_times, posix_ttyname, posix_uname
# List functions that can be disabled by PHP. If some programs need this function, they can be deleted and disabled.
Locate:; date. timezone =
Changed to: date. timezone = PRC
Find: expose_php = On
Change to: expose_php = OFF # Disable Display of php version information
Find: display_errors = On
Changed to display_errors = OFF # disable error message
: Wq! # Save and exit
4. Configure apache to support php
Vi/usr/local/apache/conf/httpd. conf # Edit the apache configuration file and add it under AddType application/x-gzip. gz. tgz.
AddType application/x-httpd-php. php (note: There is a space in front of php. php)
: Wq! # Save and exit
Service httpd restart # restart apache
Service mysqld restart # restart mysql
V. Test
Cd/usr/local/apache/htdocs
Vi index. php # enter the following content
<? Php
Phpinfo ();
?>
: Wq! # Save
Enter the server IP address in the client browser to view the configuration information!
Upload the website program to the/usr/local/apache/htdocs Directory. If there is a problem with the installation, check the directory permission to ensure that the directory has the following permissions:
Chown daemon. daemon-R/usr/local/apache/htdocs
Chmod-R 700/usr/local/apache/htdocs