Last active
April 8, 2020 13:46
-
-
Save liyang85/10d220b33a9c96e9199b1903482af203 to your computer and use it in GitHub Desktop.
Compile php-5.3.27 and run as FastCGI mode with Nginx & MySQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd /home/oldboy/tools | |
# 1. Install dependencies | |
# Part 1: yum install | |
yum install -y \ | |
freetype-devel \ | |
gd-devel \ | |
libcurl-devel \ | |
libjpeg-turbo-devel \ | |
libpng-devel \ | |
libxml2-devel \ | |
libxslt-devel \ | |
readline-devel \ | |
zlib-devel | |
# Part 2: yum install from epel | |
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo | |
yum install -y libmcrypt-devel mcrypt mhash | |
# Part 3: compile libiconv | |
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz | |
tar xf libiconv-1.14.tar.gz | |
cd libiconv-1.14 | |
./configure --prefix=/usr/local/libiconv | |
make && make install | |
# 2. Download php source tarball and extract it | |
wget http://cn2.php.net/get/php-5.3.27.tar.gz/from/this/mirror | |
tar xvf php-5.3.27.tar.gz | |
cd php-5.3.27 | |
# 3. Config | |
./configure \ | |
--prefix=/application/php-5.3.27 \ | |
--disable-rpath \ | |
--enable-bcmath \ | |
--enable-fpm \ | |
--enable-ftp \ | |
--enable-gd-native-ttf \ | |
--enable-inline-optimization \ | |
--enable-mbregex \ | |
--enable-mbstring \ | |
--enable-pcntl \ | |
--enable-safe-mode \ | |
--enable-shmop \ | |
--enable-short-tags \ | |
--enable-soap \ | |
--enable-sockets \ | |
--enable-static \ | |
--enable-sysvsem \ | |
--enable-xml \ | |
--enable-zend-multibyte \ | |
--enable-zip \ | |
--with-curl \ | |
--with-curlwrappers \ | |
--with-fpm-group=nginx \ | |
--with-fpm-user=nginx \ | |
--with-freetype-dir \ | |
--with-gd \ | |
--with-iconv-dir=/usr/local/libiconv \ | |
--with-jpeg-dir \ | |
--with-libxml-dir=/usr \ | |
--with-mcrypt \ | |
--with-mhash \ | |
--with-mysql=/application/mysql \ | |
--with-openssl \ | |
--with-png-dir \ | |
--with-readline \ | |
--with-xmlrpc \ | |
--with-xsl \ | |
--with-zlib | |
# 4. Compile php | |
ln -s /application/mysql/lib/libmysqlclient.so.18 /usr/lib64/ | |
touch ext/phar/phar.phar | |
make | |
make install | |
ln -s /application/php-5.3.27 /application/php | |
# 5. Config php.ini | |
cp php.ini-production /application/php/lib/php.ini | |
vim /application/php/lib/php.ini | |
safe_mode=On # line 338 | |
expose_php=Off # line 435 | |
display_errors=Off # line 538 | |
log_errors=On # line 559 | |
error_log=/application/logs/php_errors.log # line 643 | |
register_globals=Off # line 703 | |
magic_quotes_gpc=On # line 756 | |
cgi.fix_pathinfo=0 # line 854 | |
allow_url_fopen=Off # line 902 | |
# 6. Config php-fpm.conf | |
cd /application/php/etc | |
cp php-fpm.conf.default php-fpm.conf | |
# 7. Start php into fastcgi mode | |
/application/php/sbin/php-fpm | |
# Check its status | |
ps aux | grep php-fpm | |
lsof -i :9000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment