Build a nginx+php environment on AWS ' EC2 servers

Source: Internet
Author: User
Tags install php mcrypt install perl


    • Installing the GCC compiler
yum -y install gcc
yum -y install gcc-c++
yum -y install make automake
    • Create user
Useradd www
    • Installing Nginx


Installing a dependent Library


Yum-y Install Pcre-devel OpenSSL openssl-devel


Download Nginx


wget http://nginx.org/download/nginx-1.0.6.tar.gz
tar -xvf nginx-1.0.6.tar.gz
./configure --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-http_perl_module
make && make install


Note: If make appears the following error:
Can ' t locate extutils/embed.pm in @INC (@INC contains:/usr/lib/perl5/5.10.0/i386-linux-thread-multi/usr/lib/perl5/ 5.10.0/usr/local/lib/perl5/site_perl/5.10.0/i386-linux-thread-multi/usr/local/lib/perl5/site_perl/5.10.0/usr/ Lib/perl5/vendor_perl/5.10.0/i386-linux-thread-multi/usr/lib/perl5/vendor_perl/5.10.0/usr/lib/perl5/vendor_ Perl/usr/local/lib/perl5/site_perl.)


Yum-y Install Perl-devel perl-extutils-embed
    • Install MySQL




wget http://mysql.mirrors.hoobly.com/Downloads/MySQL-5.5/mysql-5.5.15-linux2.6-i686.tar.gz


See the MySQL Installation Guide for specific installation configurations.


    • Install PHP


Installing a dependent Library


yum -y install libxml2-devel
yum -y install libcurl libcurl-devel
yum -y install libxslt libxslt-devel
yum -y install libjpeg-6b libjpeg-devel-6b
yum -y install libpng libpng-devel
yum -y install freetype freetype-devel


Note: Libjpeg may change the name of the CentOS version later, you can use the Yum search libjpeg query
Manual installation of Libmcrypt


wget http://ncu.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
tar -xvf libmcrypt-2.5.8.tar.gz
./configure && make && make install


Download PHP source files



wget http://www.php.net/distributions/php-5.3.8.tar.gz



Compiling and installing PHP


./configure --enable-fpm --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-config-file-path=/etc --with-openssl=/usr --with-curl --with-libxml-dir --enable-soap --with-xsl --with-gd --with-jpeg-dir --with-zlib-dir --with-freetype-dir --with-png-dir --enable-mbstring --with-iconv --enable-magic-quotes --enable-inline-optimization --enable-ftp --enable-fastcgi -with-mcrypt --enable-force-cgi-redirect --enable-short-tags --disable-debug --with-mysqli=/usr/local/mysql/bin/mysql_config

make && make install


Note: If it is a 64-bit system, the "Cannot find OpenSSL libraries" may appear, the solution is to do a soft link: ln-s/usr/lib64/libssl.so/usr/lib/



Post-install copy php.ini-production to/ect/php.ini



Configuration file for PHP-FPM


Cp/usr/local/php/etc/php-fpm.conf.default   /usr/local/php/etc/php-fpm.conf


Modify the FPM Master profile to change the running users and groups to WWW, removing the preceding;


vi /usr/local/php/etc/php-fpm.conf
user = www
group = www

pm.start_servers = 20
pm.min_spare_servers
pm.max_spare_servers


Start PHP-FPM


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


Modify the configuration of nginx.conf, modify Fastcgi_param script_filename/scripts$fastcgi_script_name;
In the/scripts for their own PHP root directory, such as Fastcgi_param script_filename/usr/local/nginx/html/$fastcgi _script_name;



Start Nginx


/usr/local/nginx/sbin/nginx


or restart Nginx.


Kill-hup ' cat/usr/local/nginx/logs/nginx.pid ' or/usr/local/nginx/sbin/nginx-s reload

 


Build a nginx+php environment on AWS ' EC2 servers


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.