Centos 65 compile and install nginx-1513+php-5510+mysql-5537

Source: Internet
Author: User
Tags mcrypt
http://www.cnblogs.com/whoamme/
Centos 6.5 Compile and install nginx-1.5.13+php-5.5.10+mysql-5.5.37
1, configure the firewall, open 80 ports, 3306 ports
Copy Code
Vi/etc/sysconfig/iptables
Will
-A input-m state--state new-m tcp-p TCP--dport 80-j ACCEPT
-A input-m state--state new-m tcp-p TCP--dport 3306-j ACCEPT
Add to the rear of the 22 port configuration
Copy Code
2. Turn off SELinux
Vi/etc/selinux/config
#SELINUX =enforcing #注释掉
#SELINUXTYPE =targeted #注释掉
Selinux=disabled #增加
Restart CentOS reboot-n

3. System conventions
Software source code Package storage location:/USR/LOCAL/SRC
Source Package Compilation Installation location:/usr/local/software Name

4. Download software
Download Nginx (currently stable version) http://nginx.org/download/nginx-1.5.13.tar.gz
Download pcre (support Nginx pseudo-static) http://sourceforge.net/projects/pcre/files/pcre/8.35/pcre-8.35.tar.gz
Download MySQL http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.37.tar.gz
Download PHP http://ar2.php.net/get/php-5.5.10.tar.gz/from/this/mirror
Download CMake (MySQL compilation tool) http://www.cmake.org/files/v2.8/cmake-2.8.8.tar.gz
Download Libmcrypt (phplibmcrypt module)
Http://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz

5. Install the compilation tools and library files (install using the CentOS Yum command)
Yum install make apr* autoconf automake curl-devel gcc gcc-c++ zlib-devel OpenSSL openssl-devel pcre-devel gd kernel Keyut Ils patch perl kernel-headers compat* MPFR cpp glibc libgomp libstdc++-devel ppl cloog-ppl keyutils-libs-devel libcom_err- Devel libsepol-devel libselinux-devel krb5-devel zlib-devel libxpm* freetype libjpeg* libpng* php-common php-gd ncurses* L ibtool* libxml2 libxml2-devel Patch Mhash
6, installation CMake
Tar zxvf cmake-2.8.8.tar.gz
CD cmake-2.8.8
./configure
Gmake
Gmake Install
7. Install MySQL
Copy Code
Groupadd MySQL #添加mysql组
useradd-g MySQL mysql-s/bin/false #创建用户mysql并加入到mysql组, does not allow MySQL users to log in directly to the system
Mkdir-p/data/mysql #创建MySQL数据库存放目录
Chown-r Mysql:mysql/data/mysql #设置权限
Mkdir-p/usr/local/mysql #创建安装目录
Tar zxvf mysql-5.5.37.tar.gz
CD mysql-5.5.37
CMake. -DCMAKE_INSTALL_PREFIX=/USR/LOCAL/MYSQL-DMYSQL_DATADIR=/DATA/MYSQL-DSYSC #配置
Make #编译
Make install #安装
Cd/usr/local/mysql
CP./SUPPORT-FILES/MY-HUGE.CNF/ETC/MY.CNF #拷贝配置文件 (Note: the/etc directory has a my.cnf under the default, can be directly overwritten)
Vi/etc/my.cnf #编辑配置文件, added in [mysqld] section
DataDir =/data/mysql #添加MySQL数据库路径
./scripts/mysql_install_db--user=mysql #生成mysql系统数据库
CP./SUPPORT-FILES/MYSQL.SERVER/ETC/RC.D/INIT.D/MYSQLD #把Mysql加入系统启动
chmod 755/etc/init.d/mysqld #增加执行权限
Chkconfig mysqld on #加入开机启动
Vi/etc/rc.d/init.d/mysqld #编辑
Basedir =/usr/local/mysql #MySQL程序安装路径
DataDir =/data/mysql #MySQl数据库存放目录
Service mysqld Start #启动
Vi/etc/profile #把mysql服务加入系统环境变量: 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 for the system to restart after the operation continues under the terminal command line
Mysql_secure_installation #设置Mysql密码
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 #重启
Copy Code
8, installation Pcre
Copy Code
Cd/usr/local/src
Mkdir/usr/local/pcre
Tar zxvf pcre-8.35.tar.gz
CD pcre-8.35
./configure--prefix=/usr/local/pcre
Make
Make install
Copy Code
9. Installing Nginx
Copy Code
Cd/usr/local/src
Groupadd www
Useradd-g www www-s/bin/false
Tar zxvf nginx-1.5.13.tar.gz
CD nginx-1.5.13
./configure--prefix=/usr/local/nginx--without-http_memcached_module--user=www--group=www--with-http_stub_ Status_module--with-openssl=/usr/--with-pcre=/usr/local/src/pcre-8.35
Make
Make install
#设置nginx自启动, add the following script
Vi/etc/init.d/nginx
#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
# It is v.0.0.2 version.
# Chkconfig:-85 15
# Description:nginx is a high-performance Web and proxy server.
# It has a lot of features, but it's not for everyone.
# Processname:nginx
# Pidfile:/var/run/nginx.pid
# config:/usr/local/nginx/conf/nginx.conf
Nginxd=/usr/local/nginx/sbin/nginx
Nginx_c/local/nginx/conf/nginx.conf
Nginx_pid=/var/run/nginx.pid
Retval=0
Prog= "Nginx"
# Source function library.
. /etc/rc.d/init.d/functions
# Source Networking configuration.
. /etc/sysconfig/network
# Check that networking are up.
[${networking} = "No"] && exit 0
[-X $nginxd] | | Exit 0
# Start Nginx daemons functions.
Start () {
If [-e $nginx _pid];then
echo "Nginx already running ..."
Exit 1
Fi
Echo-n $ "Starting $prog:"
Daemon $nginxd-C ${nginx_config}
Retval=$?
Echo
[$RETVAL = 0] && Touch/var/lock/subsys/nginx
Return $RETVAL
}
# Stop Nginx daemons functions.
Stop () {
Echo-n $ "Stopping $prog:"
Killproc $nginxd
Retval=$?
Echo
[$RETVAL = 0] && rm-f/var/lock/subsys/nginx/var/run/nginx.pid
}
# Reload Nginx service functions.
Reload () {
Echo-n $ "Reloading $prog:"
#kill-hup ' Cat ${nginx_pid} '
Killproc $nginxd-hup
Retval=$?
Echo
}
# See how we were called.
Case "$" in
Start
Start
;;
Stop
Stop
;;
Reload
Reload
;;
Restart
Stop
Start
;;
Status
Status $prog
Retval=$?
;;
*)
echo $ "Usage: $prog {start|stop|restart|reload|status|help}"
Exit 1
Esac
Exit $RETVAL
chmod 775/etc/rc.d/init.d/nginx
Chkconfig Nginx on
/etc/rc.d/init.d/nginx restart
Service Nginx Restart
Copy Code
10, installation Libmcrypt
Cd/usr/local/src
Tar zxvf libmcrypt-2.5.8.tar.gz
CD libmcrypt-2.5.8
./configure
Make
Nake Install
11. Install PHP
Copy Code
Cd/usr/local/src
TAR-ZVXF php-5.5.10.tar.gz
CD php-5.5.10
Mkdir-p/USR/LOCAL/PHP5
./configure--PREFIX=/USR/LOCAL/PHP5--with-config-file-path=/usr/local/php5/etc--with-mysql=/usr/local/mysql-- With-mysqli=/usr/local/mysql/bin/mysql_config--with-mysql-sock=/tmp/mysql.sock--with-gd--with-iconv--with-zlib --enable-xml--enable-bcmath--enable-shmop--enable-sysvsem--enable-inline-optimization--with-curlwrappers-- Enable-mbregex--enable-fpm--enable-mbstring--enable-ftp--enable-gd-native-ttf--with-openssl--enable-pcntl-- Enable-sockets--with-xmlrpc--enable-zip--enable-soap--with-pear--with-gettext--enable-session--with-mcrypt-- With-curl
Make---------------------------------------------------------------------------------------------------------
Make install
CP Php.ini-production/usr/local/php5/etc/php.ini
Rm-rf/etc/php.ini
Ln-s/usr/local/php5/etc/php.ini/etc/php.ini
Cp/usr/local/php5/etc/php-fpm.conf.default/usr/local/php5/etc/php-fpm.conf
Vi/usr/local/php5/etc/php-fpm.conf
user = www #设置php-fpm run account is www
Group = www #设置php-fpm run Group is www
PID = Run/php-fpm.pid #取消前面的分号
cp/usr/local/src/php-5.5.10/sapi/fpm/init.d.php-fpm/etc/rc.d/init.d/php-fpm# copy php-fpm to startup directory
chmod +x/etc/rc.d/init.d/php-fpm #添加执行权限
Chkconfig PHP-FPM on #设置开机启动
Vi/usr/local/php5/etc/php.ini #编辑配置文件
Modified to: Date.timezone = PRC #设置时区
Copy Code
12, configuration Nginx support PHP
Copy Code
Vi/usr/local/nginx/conf/nginx.conf #编辑配置文件, you need to make the following changes
User www www; #首行user去掉注释, modify the Nginx run group to www,www; must be the same as the User,group configuration in/usr/local/php5/etc/php-fpm.conf, or PHP will run in error
Index index.php index.html index.htm; #添加index. php
# Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
Location ~ \.php$ {
root HTML;
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Fastcgi_param script_filename $document _root$fastcgi_script_name;
Include Fastcgi_params;
}
#取消FastCGI the comment for the server section location, and note the parameters of the Fastcgi_param row, instead
$document _root$fastcgi_script_name, or use an absolute path
/etc/init.d/nginx Restart #重启nginx
Copy Code
13. Testing
Copy Code
cd/usr/local/nginx/html/#进入nginx默认网站根目录
rm-rf/usr/local/nginx/html/* #删除默认测试页
VI index.php #编辑
Phpinfo ();
Chown www.www/usr/local/nginx/html/-R #设置目录所有者
chmod 700/usr/local/nginx/html/-R #设置目录权限
Shutdown-r now #重启系统
Copy Code
14. Related Commands
Service Nginx Restart #重启nginx
Service mysqld Restart #重启mysql
/USR/LOCAL/PHP5/SBIN/PHP-FPM #启动php-FPM
/ETC/RC.D/INIT.D/PHP-FPM Restart #重启php-fpm
/ETC/RC.D/INIT.D/PHP-FPM Stop #停止php-FPM
Problem:
During the installation of PHP under Linux, Configure:error:libjpeg appears at compile time. (A|SO) not found error resolution
After the inspection found that Libjpeg has been installed, but in the/usr/lib directory is not libjpeg.so this file, under the/usr/lib64, although the use of –with-jpeg-dir=/usr/lib64 is still invalid, and finally used
[root@ www.linuxidc.com ~] #ln-S/usr/lib64/libjpeg.so/usr/lib/libjpeg.so
Problem solving, libpng the same as the error resolution method

The above describes the CentOS 65 compilation installation nginx-1513+php-5510+mysql-5537, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • 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.