Home >Operation and Maintenance >CentOS >How to install php under centos
# Recommended: "How to install php under centos: first install the software required by php; then download php and unzip and install it; then enter the directory and compile and configure; finally compile and install the php source code through the command "make & make install" .
centos tutorial 》
Install the software required for phpyum install -y gcc gcc-c++ libxml2 libxml2-devel autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel curl curl-devel libxslt-devel openssl-devel
Compile (installation) configuration
./configure --prefix=/usr/local/php --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysql --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-xmlrpc --with-xsl --with-zlib --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-sockets --enable-sysvsem --enable-xml --enable-zip
1. 复制php.ini命令: cp php.ini-development /usr/local/php/lib/php.ini 2. 复制php-fmp配置命令: cp ./sapi/fpm/php-fpm.conf /usr/local/php/etc/php-fpm.conf 3. 查看php是否安装成功: /usr/local/php/bin/php --version
useradd -g www www #Add user and set user group
Configure php-fmp: vi /usr/local/php/etc/php-fpm.conf
Modify
user = nobody
group = nobody
Changed to
user = www
group = www
cp /usr/local/src/php-7.1.4/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
Set permissions and add services
chmod x /etc/init.d/php-fpm
chkconfig –add php-fpm
You can use the following commands to manage php-fpm in the future
service php-fpm start
service php-fpm stop
service php-fpm restart
service php-fpm reload
cp www.conf.default www.conf
Amend user and group in www.conf and change nobody to www
The above is the detailed content of How to install php under centos. For more information, please follow other related articles on the PHP Chinese website!