Install FastCGI with PHP in Apache on CentOS 6
Step 1: Install Packages
First step is make sure we have the required packages installed. Assuming you already have the PHP module installed, we’ll just need to install a couple of extra packages:
Step 2: Create Execution Environment
Create a fastcgi-bin directory, copy php-cgi and ensure file permissions are correct.
Step 3: Configure Apache
By following the following steps, we’re not globally setting PHP to be handled php FastCGI. We’ll only be configure a single virtual host to use FastCGI to handle PHP.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # AddHandler cgi-script .cgi <VirtualHost *:80> DocumentRoot /var/www/html ServerName example.com ServerAlias www.example.com ErrorLog /var/log/httpd/example.com-error_log CustomLog /var/log/httpd/example.com-access_log common Alias /fastcgi-bin/ /var/www/html/fastcgi-bin/ <Location /fastcgi-bin > AddHandler fcgid-script .php Options +ExecCGI FcgidWrapper /var/www/html/fastcgi-bin/php-cgi .php </Location> <Directory /var/www/html> Options Indexes FollowSymLinks MultiViews AllowOverride all Order allow,deny allow from all </Directory> </VirtualHost> |
Paying specific attention to the following:
Step 4: Restart Apache
Before restarting Apache we should quickly test the config for any errors:
test.cgi 작성 후 테스트 (실행권한 줘야 함) Ex, http://x.x.x.x/cgi-bin/test.cgi
#!/usr/bin/perl
print "Content-Type: text/html\n\n";
print "<HTML><HEAD><TITLE>CGI TEST</TITLE></HEAD>\n";
print "<BODY BGCOLOR=FFFFFF>\n";
print "<CENTER><H1>THIS IS A TEST PAGE</H1>\n";
print "</CENTER>";
print "</BODY></HTML>\n";
exit;
'Coding' 카테고리의 다른 글
색을 랜덤하게 뽑아서 출력합니다. (0) | 2017.01.07 |
---|---|
php predefined variables (0) | 2017.01.06 |
주민번호 생성원리 (0) | 2017.01.06 |
Vi(m) 사용시 ^M 없애기 (0) | 2017.01.06 |
쉘프로그래밍 문법 (0) | 2017.01.06 |