Centos6.4 (64-bit) installation nginx1.7.1 + php-5.5.13 + mysql-5.5.25_MySQL

Source: Internet
Author: User
Tags imagemagick mcrypt zts openldap
Centos6.4 (64-bit) installation nginx1.7.1 + php-5.5.13 + mysql-5.5.25 centos6centosngs6

Download all installation packages used in this article: http://pan.baidu.com/s/1zWTDc

Step 1: install the required dependency package

yum -y install gcc gcc-c++ autoconf cmake libjpeg libjpeg-devel libpng /libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel /glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel /curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel /openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients /openldap-servers gd gd2 gd-devel gd2-devel perl-CPAN

Step 2: install mysql-5.5.25

Create mysql Users and Groups

groupadd mysqluseradd -g mysql -s /usr/sbin/nologin mysqlmkdir -p /data/mysql/datamkdir /data/logschown -R mysql:mysql /usr/local/mysqlchown -R mysql:mysql /data/mysql

Compile and install mysql

tar zxvf mysql-5.5.25.tar.gzcd mysql-5.5.25cmake  -DCMAKE_INSTALL_PREFIX=/usr/local/mysql  -DMYSQL_DATADIR=/data/mysql/data  -DDEFAULT_CHARSET=utf8  -DDEFAULT_COLLATION=utf8_unicode_ci  -DWITH_READLINE=1  -DWITH_SSL=system  -DWITH_EMBEDDED_SERVER=1  -DENABLED_LOCAL_INFILE=1  -DDEFAULT_COLLATION=utf8_general_ci  -DWITH_MYISAM_STORAGE_ENGINE=1  -DWITH_INNOBASE_STORAGE_ENGINE=1  -DWITH_DEBUG=0make && make install

Configure auto-start upon startup

cp ./support-files/mysql.server /etc/init.d/mysqldchmod +x /etc/init.d/mysqldchkconfig --add mysqldchkconfig mysqld on

Add a MySQL soft link to adapt to the init script

ln -sv /usr/local/mysql/bin/mysql  /usr/sbin/mysqlln -sv /usr/local/mysql/bin/mysqladmin  /usr/sbin/mysqladminln -sv /usr/local/mysql/bin/mysqldump  /usr/sbin/mysqldump

Modify configuration file

Cp. /support-files/my-medium.cnf/etc/my. cnfvi/etc/my. cnf # enter the following content (you can clear the default content first): [mysqld] datadir =/data/mysql/datasocket =/tmp/mysql. sockuser = mysqlsymbolic-links = 0 [mysqld_safe] log-error =/data/mysql/logs/mysqld. logpid-file =/data/mysql/mysqld. piduser = mysqltmpdir =/tmp

Initialize database

/usr/local/mysql/scripts/mysql_install_db  --user=mysql  --basedir=/usr/local/mysql  --datadir=/data/mysql/data

Start mysql

Service mysqld start # or/etc/init. d/mysqld start

Enter mysql (press enter to enter mysql)

/usr/local/mysql/bin/mysql

Enter the following SQL statement to create a user with root permissions (admin) and password (12345678)

Grant all privileges on *. * TO 'admin' @ 'localhost' identified by '000000'; grant all privileges on *. * TO 'admin' @ '127. 0.0.1 'identified BY '123'; delete from user WHERE User! = 'Admin'; # Delete the default user. only the new admin user is retained.

Step 3: install nginx1.7.1

Add www users and groups and create Web site virtual directories

groupadd wwwuseradd -g www -s /usr/sbin/nologin wwwmkdir -p /data/htdocs/wwwchmod +w /data/htdocs/wwwchown -R www:www /data/htdocs/www

Install the pcre library required by Nginx

tar zxvf pcre-8.33.tar.gzcd pcre-8.33./configuremake && make installln -s /usr/local/lib/libpcre.so.1 /usr/lib64/libpcre.so.1cd ../

Install nginx1.7.1

tar zxvf nginx-1.7.1.tar.gzcd nginx-1.7.1./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-http_image_filter_modulemake && make installcd ../

Create nginx log Directory

mkdir -p /data/logschmod +w /data/logschown -R www:www /data/logs

Create the Nginx configuration file and create the nginx. conf file in the/usr/local/nginx/conf/directory:

rm -f /usr/local/nginx/conf/nginx.confvi /usr/local/nginx/conf/nginx.conf

Enter the following content:

user  www www;worker_processes 8;error_log  /data/logs/nginx_error.log  crit;pid        /usr/local/nginx/nginx.pid;#Specifies the value for maximum file descriptors that can be opened by this process.worker_rlimit_nofile 65535;events{    use epoll;    worker_connections 65535;}http{    include       mime.types;    default_type  application/octet-stream;    #charset  gb2312;          server_names_hash_bucket_size 128;    client_header_buffer_size 32k;    large_client_header_buffers 4 32k;    client_max_body_size 8m;          sendfile on;    tcp_nopush     on;    keepalive_timeout 60;    tcp_nodelay on;    fastcgi_connect_timeout 300;    fastcgi_send_timeout 300;    fastcgi_read_timeout 300;    fastcgi_buffer_size 64k;    fastcgi_buffers 4 64k;    fastcgi_busy_buffers_size 128k;    fastcgi_temp_file_write_size 128k;    gzip on;    gzip_min_length  1k;    gzip_buffers     4 16k;    gzip_http_version 1.0;    gzip_comp_level 2;    gzip_types       text/plain application/x-javascript text/css application/xml;    gzip_vary on;    #limit_zone  crawler  $binary_remote_addr  10m;    server    {        listen       80;        server_name  localhost;        index index.html index.htm index.php;        root  /data/htdocs/www;        #limit_conn   crawler  20;                                            location ~ .*/.(php|php5)?$        {                  #fastcgi_pass  unix:/tmp/php-cgi.sock;            fastcgi_pass  127.0.0.1:9000;            fastcgi_index index.php;            include fcgi.conf;        }        location ~ .*/.(gif|jpg|jpeg|png|bmp|swf)$        {            expires      30d;        }        location ~ .*/.(js|css)?$        {            expires      1h;        }        }}

Create the fcgi. conf file in the/usr/local/nginx/conf/directory:

vi /usr/local/nginx/conf/fcgi.conf

Enter the following content:

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;fastcgi_param  SERVER_SOFTWARE    nginx;fastcgi_param  QUERY_STRING       $query_string;fastcgi_param  REQUEST_METHOD     $request_method;fastcgi_param  CONTENT_TYPE       $content_type;fastcgi_param  CONTENT_LENGTH     $content_length;fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;fastcgi_param  REQUEST_URI        $request_uri;fastcgi_param  DOCUMENT_URI       $document_uri;fastcgi_param  DOCUMENT_ROOT      $document_root;fastcgi_param  SERVER_PROTOCOL    $server_protocol;fastcgi_param  REMOTE_ADDR        $remote_addr;fastcgi_param  REMOTE_PORT        $remote_port;fastcgi_param  SERVER_ADDR        $server_addr;fastcgi_param  SERVER_PORT        $server_port;fastcgi_param  SERVER_NAME        $server_name;# PHP only, required if PHP was built with --enable-force-cgi-redirectfastcgi_param  REDIRECT_STATUS    200;

Start nginx:

ulimit -SHn 65535/usr/local/nginx/sbin/nginx

Step 3: install php5.5.13

Install the required dependency package for PHP:

Tar zxvf libiconv-1.14.tar.gzcd libiconv-1.14. /configure -- prefix =/usr/localmakemake installcd .. /tar zxvf libmcrypt-2.5.8.tar.gzcd /. /configuremakemake install/sbin/ldconfigcd libltdl /. /configure -- enable-ltdl-installmakemake installcd .. /.. /tar zxvf mhash-0.9.9.9.tar.gzcd /. /configuremakemake installcd .. /# symbolic link ln-s/usr/local/lib/libmcrypt to the shared library. la/usr/lib64/libmcrypt. la1-s/usr/local/lib/libmcrypt. so/usr/lib64/libmcrypt. soln-s/usr/local/lib/libmcrypt. so.4/usr/lib64/libmcrypt. so.4ln-s/usr/local/lib/libmcrypt. so.4.4.8/usr/lib64/libmcrypt. so.4.4.8ln-s/usr/local/lib/libmhash. a/usr/lib64/libmhash. a1-s/usr/local/lib/libmhash. la/usr/lib64/libmhash. la1-s/usr/local/lib/libmhash. so/usr/lib64/libmhash. soln-s/usr/local/lib/libmhash. so.2/usr/lib64/libmhash. so.2ln-s/usr/local/lib/libmhash. so.2.0.1/usr/lib64/libmhash. so.2.0.1ln-s/usr/local/bin/libmcrypt-config/usr/bin/libmcrypt-configln-s/usr/local/mysql/lib/libmysqlclient. so.18/usr/lib64/libmysqlclient. so.18tar zxvf mcrypt-2.6.8.tar.gzcd mcrypt-2.6.8 // sbin/ldconfig. /configuremakemake installcd ../

Install php:

Tar zxvf php-5.5.13.tar.gzcd php-5.5.13. /configure -- prefix =/usr/local/php -- with-config-file-path =/usr/local/php/etc/-- with-mysql =/usr/local/mysql -- with-mysqli =/usr/local/mysql/bin/mysql_config/-- with-iconv-dir -- with-freetype-dir -- with-jpeg-dir -- with-png-dir -- with-zlib -- with-libxml-dir =/usr/-- enable-xml -- disable-rpath -- enable-bcmath -- enable-shmop -- enable-sysvsem -- enable-inline-optimization /-- with-curl -- enable-mbregex -- enable-fpm -- enable-mbstring -- with-mcrypt -- with-gd -- enable-gd-native-ttf/-- with-openssl -- -mhash -- enable-pcntl -- enable-sockets -- with-xmlrpc -- enable-zip -- enable-soap/-- enable-opcache = no -- without-pear -- disable-fileinfo # note: if the memory size is large, remove -- disable-fileinfomake ZEND_EXTRA_LIBS = '-liconv' make installcp php. ini-development/usr/local/php/etc/php. inicd .. /cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.confvi/usr/local/php/etc/php-fpm.conf

Modify

user = nobodygroup = nobody

Is

user = wwwgroup = www

# Yes; pid = run/php-fpm.pid; remove and change to pid =/usr/local/php/var/run/php-fpm.pid

Start php-fpm

/usr/local/php/sbin/php-fpm

Add Nginx and fpm to auto-start

Vi/etc/rc. local # enter the ulimit-SHn 65535/usr/local/php/sbin/php-fpm/usr/local/nginx/sbin/nginx

Compile the PHP extension modules memcache, pdo_mysql, and imagick.

tar zxvf memcache-3.0.8.tgzcd memcache-3.0.8/usr/local/php/bin/phpize./configure --with-php-config=/usr/local/php/bin/php-configmakemake installcd ../tar zxvf PDO_MYSQL-1.0.2.tgzcd PDO_MYSQL-1.0.2//usr/local/php/bin/phpize./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysqlln -s /usr/local/mysql/include/* /usr/local/include/makemake installcd ../tar zxvf ImageMagick.tar.gzcd ImageMagick-6.5.1-2/./configuremakemake installcd ../tar zxvf imagick-3.2.0RC1.tgzcd imagick-3.2.0RC1/usr/local/php/bin/phpizeexport PKG_CONFIG_PATH=/usr/local/lib/pkgconfig./configure --with-php-config=/usr/local/php/bin/php-configmakemake installcd ../

Modify the php. ini configuration file

Vi/usr/local/php/etc/php. ini # Search; extension_dir = "/" replace the previous one; remove and modify to extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/" # and add extension = memcache. soextension = pdo_mysql.soextension = imagick. so

Run the following command to make the configuration file take effect immediately:

kill -USR2 `cat /usr/local/php/var/run/php-fpm.pid`

Others (optional ):

Optimize Linux kernel parameters

vi /etc/sysctl.conf

Add the following content at the end:

# Addnet.ipv4.tcp_max_syn_backlog = 65536net.core.netdev_max_backlog =  32768net.core.somaxconn = 32768net.core.wmem_default = 8388608net.core.rmem_default = 8388608net.core.rmem_max = 16777216net.core.wmem_max = 16777216net.ipv4.tcp_timestamps = 0net.ipv4.tcp_synack_retries = 2net.ipv4.tcp_syn_retries = 2net.ipv4.tcp_tw_recycle = 1#net.ipv4.tcp_tw_len = 1net.ipv4.tcp_tw_reuse = 1net.ipv4.tcp_mem = 94500000 915000000 927000000net.ipv4.tcp_max_orphans = 3276800#net.ipv4.tcp_fin_timeout = 30#net.ipv4.tcp_keepalive_time = 120net.ipv4.ip_local_port_range = 1024  65535

Make the configuration take effect immediately:

/sbin/sysctl -p

Install opcache (because PHP 5.5 has already integrated Zend Opcache, it can replace eaccelerator)

tar zxvf zendopcache-7.0.3.tgzcd zendopcache-7.0.3/usr/local/php/bin/phpize./configure --with-php-config=/usr/local/php/bin/php-configmakemake installcd ../

Add the following configuration to php. ini:

[opcache]zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/opcache.so"opcache.memory_consumption=128opcache.interned_strings_buffer=8opcache.max_accelerated_files=4000opcache.revalidate_freq=60opcache.fast_shutdown=1opcache.enable_cli=1

# Make the php. ini configuration file take effect immediately kill-USR2 'cat/usr/local/php/var/run/php-fpm.pid'

Common commands:

# Modify php. run: kill-USR2 'cat/usr/local/php/var/run/php-fpm.pid '# After modifying nginx. run/usr/local/nginx/sbin/nginx-s reload after conf # restart mysql service execution: service mysqld (start | stop | restart)

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.