Compile and install Nginx + PHP + Mysql in CentOS 6

Source: Internet
Author: User

[1]. Install Nginx
 
1. Add a user who cannot log on and does not have a home directory:
 
1 # useradd www-M-s/sbin/nologin
 
2. Necessary components
 
# Wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.13.zip
# Unzip pcre-8.13.zip
# Cd pcre-8.13
#./Configure
# Make & make install
 
3. Compile and install nginx
# Tar-zxvf nginx-1.1.2.tar.gz
# Cd nginx-1.1.2
#./Configure -- prefix =/usr/local/nginx -- user = www -- group = www -- with-http_stub_status_module -- with-http_ssl_module
# Make & make install
 
[2]. install PHP
 
1. install necessary components
 
# Yum-y install libjpeg-devel libpng-devel
# Wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz
# Tar-zxvf libmcrypt-2.5.7.tar.gz
# Cd libmcrypt-2.5.7
#./Configure
# Make & make install
 
= 64-bit system =
 
1 # ln-s/usr/lib64/mysql // usr/lib/mysql
 
= 64-bit system =
 
2. Compile and install php
 
# Cd php-5.3.8
#. /Configure -- prefix =/usr/local/php -- with-iconv -- with-zlib -- enable-xml -- disable-rpath -- enable-safe-mode -- enable-bcmath -- enable- shmop -- enable-sysvsem -- enable-inline-optimization -- with-curl -- with-curlwrappers -- enable-mbregex -- enable-mbstring -- with-mcrypt -- with-gd -- enable-gd- native-ttf -- with-openssl -- with-mhash -- enable-pcntl -- enable-sockets -- with-xmlrpc -- enable-zip -- enable-soap -- without-pear -- with-mysql -- with-mysqli -- enable-sqlite-utf8 -- with-pdo-mysql -- enable-ftp -- with-jpeg-dir -- with-freetype-dir -- with-png-dir -- enable-fpm --- fpm-user = www -- with-fpm-group = www
# Make & make install
 
3. Copy and modify the php configuration file
 
# Cp php. ini-production/usr/local/php/lib/php. ini or/usr/local/lib/php. ini
# Cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf
#/Usr/local/php/bin/php -- ini // test whether the ini file is loaded
 
Modify php. ini
 
[PHP]
Safe_mode = On
Register_globals = Off
Magic_quotes_gpc = Off
Allow_url_fopen = Off
Allow_url_include = Off
Expose_php = Off
Disable_functions = shell_exec, system, exec, passthru, show_source, curl_exec, curl_multi_exec, get_assist_var
[Date]
Date. timezone = "Asia/Shanghai"
 
Modify php-fpm.conf
 
[Global]
Pid = run/php-fpm.pid
Error_log = log/php-fpm.log
Log_level = notice
Emergency_restart_threshold = 0
Emergency_restart_interval = 0
[Www]
Pm. start_servers = 20
Pm. min_spare_servers = 5
Pm. max_spare_servers = 35
Pm. max_requests = 500
 
4. Add a Service Startup Script
# Cp nginx/etc/init. d/nginx
# Cp php-fpm/etc/init. d/php-fpm
# Chmod 755/etc/init. d/nginx
# Chmod 755/etc/init. d/php-fpm
# Chkconfig -- add nginx
# Chkconfig -- add php-fpm
# Chkconfig nginx on
# Chkconfig php-fpm on
 
[3]. Install Mysql
 
3.1. Create the mysql installation directory
 
1 # mkdir-p/usr/local/mysql/
 
3.2. Create a data storage directory
 
1 # mkdir-p/data/mysql/
 
3.3 create users and user groups and grant data storage directory permissions
 
# Useradd mysql-M-s/sbin/nologin
# Chown mysql. mysql-R/data/mysql/
 
3.4 install necessary components
 
# Yum-y install cmake
# Yum-y install ncurses-devel
 
3.5. Compile and install Mysql
 
-DMYSQL_UNIX_ADDR =/data/mysql. sock-DDEFAULT_CHARSET = utf8-DDEFAULT_COLLATION = utf8_general_ci-DWITH_EXTRA_CHARSETS: STRING = utf8, gbk-cores = 1-cores = 1-cores = 1-DWITH_READLINE = 1-DENABLED_LOCAL_INFILE = 1-DMYSQL_DATADIR =/data/mysql-DMYSQL_USER = mysql-DMYSQL_TCP_PORT = 3306
# Make & make install
 
3.6 initialize the database
 
# Cd/usr/local/mysql
# Scripts/mysql_install_db -- user = mysql -- basedir =/usr/local/mysql -- datadir =/data/mysql/
 
3.7. Configure the environment
 
# Cp support-files/my-medium.cnf/etc/my. cnf
# Cp support-files/mysql. server/etc/init. d/mysql
# Chmod 755/etc/init. d/mysql
# Chkconfig mysql on
# Export PATH =/usr/local/mysql/bin: $ PATH
 
3.8. Start and set the initial password
 
#/Etc/init. d/mysql start
# Mysqladmin-uroot password '123'
 
Statement for modifying the password
1: UPDATE mysql. user SET Password = PASSWORD ('newpwd') WHERE User = 'root'; (new Password)
2: flush privileges; (refresh permission)
 

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.