CentOS6.5 compile and install Apache2.4.1 + mysql5.21 + PHP5.3.10 server ring
Source: Internet
Author: User
Preparations: 1. configure the IP address, DNS, and Gateway. make sure that you can use the remote connection tool to connect to the CentOS server to set the IP address, Gateway, DNS, and other steps. Please search for other tutorials on this site. 2. configure the firewall and enable port 80 and Port 3306 vi/etc/sysconfig/iptables-AINPUT-mstate -- stateNEW-mtcp-ptcp -- dp Preparation:
1. configure the IP address, DNS, and gateway to ensure that the remote connection tool can be used to connect to the server. For instructions on setting IP addresses, gateways, and DNS in CentOS, please search other tutorials on this site.
2. configure the firewall and enable port 80 and Port 3306
Vi/etc/sysconfig/ Iptables
-A input-m state -- state NEW-m tcp-p tcp -- dport 80-j ACCEPT (allow port 80 to pass through the firewall)
-A input-m state -- state NEW-m tcp-p tcp -- dport3306-j ACCEPT (Port 3306 is allowed to pass through the firewall)
Note: Many users add these two rules to the last line of the firewall configuration, which causes firewall startup failure. the correct rule should be added to the default port 22.
The firewall rules are as follows:
######################################## #################
# 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-jACCEPT
-A input-m state -- state NEW-m tcp-p tcp -- dport 80-jACCEPT
-A input-m state -- state NEW-m tcp-p tcp -- dport 3306-jACCEPT
-A input-j REJECT -- reject-with icmp-host-prohibited
-A forward-j REJECT -- reject-with icmp-host-prohibited
COMMIT
######################################## #################
/Etc/init. d/iptables restart # restart the firewall to make the configuration take effect.
3. disable SELINUX
Vi/etc/selinux/config
# SELINUX = enforcing # Comment out
# SELINUXTYPE = targeted # Comment out
SELINUX = disabled # Add
: Wq save, close
Shutdown-r now # restart the system
IV. system conventions
Software source code package storage location:/usr/local/src
Source code package compilation and installation location:/usr/local/software name
5. download the software package
1. download apache
Http://www.apache.org/dist/httpd/httpd-2.4.1.tar.gz
2. download MySQL
Http :// Mysql.Mirror.kangaroot.net/Downloads/MySQL-5.5/ Mysql-5.5.21.tar.gz
3. Download php
Http://cn.php.net/distributions/php-5.3.10.tar.gz
4. download cmake (MySQL compilation tool)
Http://www.cmake.org/files/v2.8/cmake-2.8.7.tar.gz
5. download libmcrypt (PHPlibmcrypt module)
Ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz
6. download apr (Apache library file)
Http://mirror.bit.edu.cn/apache/apr/apr-1.4.6.tar.gz
7. download apr-util (Apache library file)
Http://mirror.bit.edu.cn/apache/apr/apr-util-1.4.1.tar.gz
Remotely connect to the server using WinSCP and upload the downloaded software to the server/usr/local/src. 6. install the compilation tool and library file (use the CentOS yum command for installation) Yum install make apr * autoconf automake gcc-c ++ zlib-developenssl openssl-devel pcre-devel gd kernel keyutils patch perl kernel-headers compat * mpfr cpp glibc libgomplibstdc ++-devel ppl cloog-ppl keyutils-libs-devel libcom_err-devellibsepol-devel libselinux-devel krb5-devel zlib-devel libXpm * freetype libjpeg * libpng * php-common php-gd ncurses * libtool * libxml2 libxml2-devel patch
Installation
Use putty to remotely log on to the server.
1. install libmcrypt
Cd/usr/local/src
Tar zxvf libmcrypt-2.5.7.tar.gz # extract
Cd libmcrypt-2.5.7 # go to the Directory
./Configure # configuration
Make # compile
Make install # install
2. install cmake
Cd/usr/local/src
Tar zxvf cmake-2.8.7.tar.gz
Cd cmake-2.8.7
./Configure
Make # compile
Make install # install
3. install apr
Cd/usr/local/src
Tar zxvf apr-1.4.6.tar.gz
Cd apr-1.4.6
./Configure -- prefix =/usr/local/apr
Make
Make install
4. install apr-util Cd/usr/local/src
Tar zxvf apr-util-1.4.1.tar.gz
Cd apr-util-1.4.1
./Configure -- prefix =/usr/local/apr-util -- with-apr =/usr/local/apr/bin/apr-1-config
Make
Make install
5. install mysql
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.
Mkdir-p/data/mysql # Create a directory for storing MySQL databases
Chown-R mysql: mysql/data/mysql # set MySQL database directory permissions
Mkdir-p/usr/local/mysql # create the MySQL installation directory
Cd/usr/local/src
Tar zxvf mysql-5.5.21.tar.gz # extract
Cd mysql-5.5.21
Cmake.-DCMAKE_INSTALL_PREFIX =/usr/local/mysql-DMYSQL_DATADIR =/data/mysql-DSYSCONFDIR =/etc # configuration
Make # compile
Make install # install
Cd/usr/local/mysql
Cp./support-files/my-huge.cnf/etc/my. cnf # Copy the configuration file (Note: Under the/etc directory there is a default my. cnf, directly overwrite it)
Vi/etc/my. cnf # Edit the configuration file and add the following line in the [mysqld] Section
Datadir =/data/mysql # add the MySQL database path
: Wq! # Save and exit
./Scripts/mysql_install_db -- user = mysql # generate a mysql system database
Cp./support-files/mysql. server/etc/rc. d/init. d/mysqld # Add Mysql to the system to start
Chmod 755/etc/init. d/mysqld # Add execution permission
Chkconfig mysqld on # add to startup
Vi/etc/rc. d/init. d/mysqld # Edit
Basedir =/usr/local/mysql # MySQL installation path
Datadir =/data/mysql # MySQl database storage directory
Service mysqld start # start
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
The following two lines link the myslq library file to the default system location, so that 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
Shutdown-r now # restart the system. wait until the system is restarted and continue to perform the following operations on the terminal command line.
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!
6. install apache2 Cd/usr/local/src
Tar-zvxf httpd-2.4.1.tar.gz
Cd httpd-2.4.1
Mkdir-p/usr/local/apache2 # create the installation directory
. /Configure -- prefix =/usr/local/apache2 -- with-apr =/usr/local/apr -- with-apr-util =/usr/local/apr-util --- ssl -- enable-module = so -- enable-rewrite -- enable-cgid -- enable-cgi # configuration
Make # compile
Make install # install
/Usr/local/apache2/bin/apachectl-k start # start
Vi/usr/local/apache2/conf/httpd. conf # Edit the configuration file
Find: # ServerName www.example.com: 80
Changed to: ServerName www.server110.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 apache service system environment variables
Add the following line at the end
Export PATH = $ PATH:/usr/local/apache2/bin
Cp/usr/local/apache2/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
Chown daemon. daemon-R/usr/local/apache2/htdocs # Change the directory owner
Chmod 700/usr/local/apache2/htdocs-R # change apache website directory permissions
Chkconfig httpd on # set startup
/Etc/init. d/httpd start
Service httpd restart
7. install php
Cd/usr/local/src
Tar-zvxf php-5.3.10.tar.gz
Cd php-5.3.10
Mkdir-p/usr/local/php5 # Create a php installation directory
. /Configure -- prefix =/usr/local/php5 -- with-config-file-path =/usr/local/php5/etc -- with-apxs2 =/usr/local/apache2/bin/ apxs -- with-mysql =/usr/local/mysql -- with-mysqli =/usr/local/mysql/bin/mysql_config -- with-mysql-sock =/tmp/mysql. sock -- with-gd -- with-iconv -- with-freetype -- with-jpeg -- with-png -- with-zlib -- with-libxml -- enable-xml -- enable-discard-path -- enable-magic-quotes -- enable-safe-mode -- enable-bcmath -- enable-shmop -- enable-sysvsem -- enable-inline-optimization -- with-curlwrappers -- enable-mbregex -- enable- fastcgi -- enable-force-cgi-redirect -- enable-mbstring -- enable-ftp -- enable-gd-native-ttf -- with-openssl -- enable-pcntl -- enable-sockets --- xmlrpc -- enable-zip -- enable-soap -- without-pear -- with-gettext -- with-mime-magic -- enable-suhosin -- enable-session -- with-mcrypt # configuration
Make # compile
Make install # install
Mkdir/usr/local/php5/etc
Cp php. ini-production/usr/local/php5/etc/php. ini # Copy the php configuration file to the installation directory
Rm-rf/etc/php. ini # Delete the built-in configuration file
Ln-s/usr/local/php5/etc/php. ini/etc/php. ini # Create a soft link to the configuration file
Vi/usr/local/php5/etc/php. ini # Edit
Find:; open_basedir =
Modify it 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
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