Nginx + php + FastCGI Configuration

Source: Internet
Author: User
Recently, I was working on PHP, so I had to take a note of the configuration process to avoid forgetting. PHP installation, configuration I install through source code compilation, the basic steps are as follows: unzip tarxfphp-5.5.12.tar.bz2 $ cdphp-5.5.12 $. configure -- prefixoptmyphp -- with-mysql -- enable-safe-mode -- enabl

Recently, I was working on PHP, so I had to take a note of the configuration process to avoid forgetting. PHP installation, configuration I install through source code compilation, the basic steps are as follows: $ tar xf php-5.5.12.tar.bz2 $ cd php-5.5.12 $ '. /configure ''-- prefix =/opt/myphp'' -- with-mysql'' -- enable-safe-mode ''-- enabl

Recently, I was working on PHP, so I had to take a note of the configuration process to avoid forgetting.

PHP installation and configuration

I install the SDK through source code compilation. The basic steps are as follows:

$ tar xf php-5.5.12.tar.bz2$ cd php-5.5.12$ './configure'  '--prefix=/opt/myphp' '--with-mysql' '--enable-safe-mode' '--enable-ftp' '--enable-zip' '--with-jpeg-dir' '--with-bz2' '--with-png-dir' '--with-freetype-dir' '--with-iconv' '--with-libxml-dir' '--with-xmlrpc' '--with-zlib-dir' '--with-gd' '--enable-gd-native-ttf' '--with-curl' '--with-gettext' '--with-pear' '--enable-fpm' '--enable-fastcgi' '--with-ncurses' '--with-mcrypt' '--with-mhash' '--with-openssl' '--with-pcre-dir' '--enable-pdo' '--enable-phar' '--enable-json' '--enable-mbstring' '--with-pdo-mysql' '--with-pdo-sqlite' '--with-readline' '--enable-bcmath'$ make$ sudo make install

After the installation is complete, go to the installation directory and modify the configuration file lib/php. ini (if not, create it) and add the time zone settings:

date.timezone=Asia/Shanghai

Then run the FastCGI service of PHP:

./bin/php-cgi -b 9000
Nginx Configuration

Nginx can be installed directly from the Repository:

sudo pacman -S nginx

Or:

sudo apt-get install nginx

After the installation is complete, modify the configuration and add a new Virtual Host:

server {    listen 8000;    server_name localhost;    root /var/www;    location / {        index index.php;    }    location ~ \.php$ {        fastcgi_pass   127.0.0.1:9000;        fastcgi_index  index.php;        fastcgi_split_path_info ^(.+\.php)(/.*)$;        include        fastcgi_params;        fastcgi_param  SCRIPT_FILENAME  /var/www/$fastcgi_script_name;    }}

Then create the file/var/www/index. php.

 

Now you can access http: // 127.0.0.1: 8000/in a browser.

Original article address: nginx + php + FastCGI configuration. Thank you for sharing it with me.

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.