CentOS Build Install LAMP (apache-2.4.7 + mysql-5.5.35 + php 5.5.8) + Redis

Source: Internet
Author: User
Tags chmod install php mcrypt openssl php redis git clone install redis



Reprint Address: http://www.cnblogs.com/whoamme/p/3530056.html



Software source code Package storage location:/USR/LOCAL/SRC



Source Package Compilation Installation location:/usr/local/software Name



To modify a source:


1. Enter the folder where the source configuration is stored.
Cd /etc/yum.repos.d

2, backup default source
Mv ./CentOS-Base.repo ./CentOS-Base.repo.bak

3, use wget to download the source of 163
Wget http://mirrors.163.com/.help/CentOS-Base-163.repo

4. Set the downloaded file CentOS-Base-163.repo as the default source.
Mv CentOS-Base-163.repo CentOS-Base.repo

Install git
Yum install git
See git commonly used commands at http://www.cnblogs.com/whoamme/p/3531387.html Yum Install git
About git common commands see  http://www.cnblogs.com/whoamme/p/3531387.html 


First, close SELinux



Vi/etc/selinux/config



#SELINUX =enforcing #Comment out





#SELINUXTYPE =targeted #Comment out





Selinux=disabled 




: Wq Save, close





Shutdown-r now #restart the system





Second, download the package



1. Download Apache



wget apache.dataguru.cn/httpd/httpd-2.4.7.tar.gz



2. Download MySQL



wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.35.tar.gz



3. Download PHP 5.5.8



wget Cn2.php.net/get/php-5.5.8.tar.gz/from/this/mirror



4. Download CMake (MySQL compilation tool)



wget http://www.cmake.org/files/v2.8/cmake-2.8.12.1.tar.gz



5. Download Libmcrypt (phplibmcrypt module)



wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz



6. Download Apr (Apache library file)



wget mirror.bit.edu.cn/apache/apr/apr-1.5.0.tar.gz



7. Download Apr-util (Apache library file)



wget mirror.bit.edu.cn/apache/apr/apr-util-1.5.3.tar.gz






Third, installation



Preparation: Compile tools and library files (install using the CentOS Yum command)



Yum install make apr* autoconf automake gcc gcc-c++ zlib-devel OpenSSL openssl-devel pcre-devel gd kernel keyutils patch P Erl kernel-headers compat* MPFR cpp glibc libgomp libstdc++-devel ppl cloog-ppl keyutils-libs-devel libcom_err-devel libse Pol-devel libselinux-devel krb5-devel zlib-devel libxpm* freetype libjpeg* libpng* php-common php-gd ncurses* libtool* Lib XML2 Libxml2-devel Patch



1, installation Libmcrypt



Cd/usr/local/src



Tar zxvf libmcrypt-2.5.7.tar.gz #unzip





CD libmcrypt-2.5.7 #Enter directory





./configure #Configuration





Make #compile





Make install #install




  2, installation 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



Uninstall the old version first



Yum Remove apr-util-devel Apr apr-util-mysql apr-docs apr-devel apr-util Apr-util-docs



Cd/usr/local/src



Tar zxvf apr-1.5.0.tar.gz



CD apr-1.5.0



  ./configure--PREFIX=/USR/LOCAL/APR



Make



Make install



  4, Installation Apr-util



Tar zxvf apr-util-1.5.3.tar.gz



CD apr-util-1.5.3



  ./configure--prefix=/usr/local/apr-util--with-apr=/usr/local/apr/bin/apr-1-config



Make



Make install






  5. Install MySQL



Go back to the CMake directory and delete the Cmakecache.txt file



Rm-f CMakeCache.txt



Groupadd MySQL #add mysql group





Useradd-g MySQL mysql-s/bin/false #Create user mysql and add to mysql group, does not allow MySQL users to log in directly to the system





Mkdir-p/data/mysql #Create a MySQL database storage directory





Chown-r Mysql: mysql/data/mysql #Set MySQL database directory permissions





Mkdir-p/usr/local/mysql #Create MySQL installation directory





Cd/usr/local/src





Tar zxvf mysql-5.5.21.tar.gz #unzip





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 configuration file (Note: the/etc directory has a my.cnf under the default, can be directly overwritten)





Vi/etc/my.cnf #Edit configuration file, added in [mysqld] section





DataDir = /data/mysql #Add MySQL database path





./scripts/mysql_install_db--user=mysql #Generate 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 execute permission





Chkconfig mysqld on #Add boot





Vi/etc/rc.d/init.d/mysqld #edit





Basedir =/usr/local/mysql #MySQL program 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 location of the system, so you can compile software like PHP without specifying the MySQL library file address.





Ln-s/usr/local/mysql/lib/mysql/usr/lib/mysql





Ln-s/usr/local/mysql/include/mysql/usr/include/mysql





Shutdown-r now #wait to the system to restart after the operation continues under the terminal command line





Mysql_secure_installation #Set Mysql password





Press Y to enter the password 2 times as prompted





Or modify the password directly/usr/local/mysql/bin/mysqladmin-u root-p password "123456" #改密码





Service mysqld Restart #restart



To this, 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 an installation directory

./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-ssl --enable- 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 configuration file

Found: #ServerName www.example.com:80

Modified as: ServerName www.osyunwei.com:80

Found: DirectoryIndex index.html

Modified to: DirectoryIndex index.html index.php

Found: Options Indexes FollowSymLinks

Modified to: Options FollowSymLinks #Do not display directory structure

Find AllowOverride None

Modified as: AllowOverride All #Open apache supports pseudo-static, there are two modifications

LoadModule rewrite_module modules/mod_rewrite.so #Cancel the previous comment, 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 to start

Vi /etc/init.d/httpd #edit file

Add the following two lines below #!/bin/sh

#chkconfig:2345 10 90

#descrption:Activates/Deactivates Apache Web Server

Chown daemon.daemon -R /usr/local/apache2/htdocs #change directory owner

Chmod 700 /usr/local/apache2/htdocs -R #change apache website directory permissions

Chkconfig httpd on #Set boot

/etc/init.d/httpd start

Service httpd restart

 

7, install PHP5

    Cd /usr/local/src

Tar -zvxf php-5.3.10.tar.gz

Cd php-5.3.10

Mkdir -p /usr/local/php5 #Create 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 --with-xmlrpc --enable-zip --enable-soap --with-pear --with-gettext --with-mime-magic --enable-suhosin --enable-session --with-mcrypt --with-jpeg --enable-fpm #config

Make #compile

Make install #install

Mkdir /usr/local/php5/etc

Cp php.ini-production /usr/local/php5/etc/php.ini #copy php configuration file to the installation directory

Rm -rf /etc/php.ini # Delete the configuration file that comes with the system

Ln -s /usr/local/php5/etc/php.ini /etc/php.ini #Create a configuration file soft link

Vi /usr/local/php5/etc/php.ini #edit

Found:;open_basedir =

Modified as: open_basedir = .:/tmp/ # Prevent php Trojans from crossing, important!!

Found: disable_functions =

Modified as: disable_functions = passthru, exec, system, chroot, scandir, chgrp, chown, shell_exec, proc_open, proc_get_status, ini_alter, ini_alter,
Ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,
Disk_free_space, checkdnsrr, checkdnsrr, getservbyname, getservbyport, disk_total_space, posix_ctermid,
Posix_get_last_error, posix_getcwd, posix_getegid, posix_geteuid, posix_getgid,
posix_getgrgid, posix_getgrnam, posix_getgroups, posix_getlogin, posix_getpgid, posix_getpgrp, posix_getpid, posix_getppid, posix_getpwnam, posix_getpwuid, posix_getrlimit, posix_getsid, posix_getuid, posix_isatty, posix_kill, posix_mkfifo, posix_setegid, posix_seteuid, posix_setgid, posix_setpgid, posix_setsid, posix_setuid, posix_strerror, posix_times, posix_ttyname, Posix_uname

#List the functions that PHP can disable. If some programs need to use this function, you can delete them and cancel them.

Found:;date.timezone =

Modified to: date.timezone = PRC

Found: expose_php = On

Modified to: expose_php = OFF # Disable display of php version information

Found: display_errors = On

Modified to: display_errors = OFF #Close error message

 

Configure apache support php

Vi /usr/local/apache2/conf/httpd.conf #Edit apache configuration file

Add under the line LoadModule php5_module modules/libphp5.so,

AddType application/x-httpd-php .php (Note: there is a space in front of this point in php .php)

Service httpd restart #restart apache

Service mysqld restart #restart mysql

    

At this point, the basic LAMP environment is compiled and you can write a test file to test it.

   

Fourth, install redis service and php redis extension

1, install tcl

Wget -c http://prdownloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz
Tar -zxvf tcl8.6.1-src.tar.gz
Cd tcl8.6.1/unix
./configure
Make && make install
2, install redis service

Wget -c http://download.redis.io/releases/redis-2.6.16.tar.gz
Tar -zxvf redis-2.6.16.tar.gz
Cd redis-2.6.16
Make (if linux32 bit, use make CFLAGS="-march=i686")
Make test
Make install
3. Start the redis service:



Vim /usr/local/src/redis-2.6.16/redis.conf //set daemonize to yes
/usr/local/bin/redis-server /usr/local/src/redis-2.6.16/redis.conf
Ps aux|grep redis view process

4, use redis-cli connection, of course you can also use telnet
Test:
 

[root@localhost redis-2.6.16]# redis-cli
Redis 127.0.0.1:6379> set name silenceper
OK
Redis 127.0.0.1:6379> get name
"silenceper"
Redis 127.0.0.1:6379>


Shutdown You can use the command redis-cli shutdown
Redis-cli –help See more options

About the redis 2.4 configuration file Chinese description:

Https://github.com/silenceper/my/blob/master/config/redis2.4.chinese

Redis command manual:

Http://redis.readthedocs.
Org/en/latest/



5, use phpRedisAdmin to manage redis

Git clone https://github.com/ErikDubbelboer/phpRedisAdmin.git
 
Put the program in the source code directory of apache, configure vhost, and find it is a white screen after access, test vhost can be accessed normally.
Check out the sources of includes/common.inc.php:
Require dirname(__FILE__) . ‘/../vendor/autoload.php‘;
One less vendor directory, asked about the three gold pot, three gold pot said that this program relies on predis instead of redis php extension, you need to download predis to the vendor directory. . .


Cd phpRedisAdmin
Git clone https://github.com/nrk/predis.git vendor

 
6, install php redis extension


Git clone git://github.com/nicolasff/phpredis.git
Cd phpredis
/usr/local/php5/bin/phpize
./configure --with-php-config=/usr/local/php5/bin/php-config --enable-redis
 Make
Make install
 
 
 Configure php.ini
Vim /usr/local/php5/etc/php.ini

Modify extension_dir = "/usr/local/php5/lib/php/extensions/no-debug-zts-20121212/"
Add extension=redis.so //turn on redis extension
 
Restart the apache server, /usr/local/php5/bin/php -m
          Can see that there is a redis extension





Related Article

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.