Nginx,MySQL编译安装过程略
PHP编译安装 下载 1 wget http://cn2.php.net/distributions/php-7.2.8.tar.gz
解压 1 tar -xzf php-7.2.8.tar.gz
安装依赖 1 yum -y install bzip2-devel freetype-devel gcc gmp-devel libxml2-devel libcurl-devel libjpeg-devel libpng-devel make net-snmp-devel libmcrypt-devel openssl-devel readline-devel libxslt-devel
生成配置文件 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 cd php-7.2.8./configure --prefix=/usr/local /php \ --with-config-file-path=/usr/local /php/etc \ --with-mysqli \ --with-pdo-mysql \ --with-mysql-sock=/usr/local /mysql/mysql.sock \ --with-iconv-dir \ --with-freetype-dir \ --with-jpeg-dir \ --with-png-dir \ --with-curl \ --with-gd \ --with-gmp \ --with-zlib \ --with-xmlrpc \ --with-openssl \ --without-pear \ --with-snmp \ --with-gettext \ --with-mhash \ --with-libxml-dir=/usr \ --with-fpm-user=nginx \ --with-fpm-group=nginx \ --enable -xml \ --enable -fpm \ --enable -ftp \ --enable -bcmath \ --enable -soap \ --enable -shmop \ --enable -sysvsem \ --enable -sockets \ --enable -inline-optimization \ --enable -maintainer-zts \ --enable -mbregex \ --enable -mbstring \ --enable -pcntl \ --enable -zip \ --disable -fileinfo \ --disable -rpath \ --enable -libxml \ --enable -opcache \ --enable -mysqlnd \ --with-ldap \ --with-ldap-sasl \
异常处理 错误:configure: error: Unable to locate gmp.h
解决:yum install gmp-devel
错误:configure: error: Cannot find ldap libraries in /usr/lib.
解决:cp -frp /usr/lib64/libldap* /usr/lib/
错误:configure: error: Could not find net-snmp-config binary. Please check your net-snmp installation.
解决:yum install net-snmp-devel
编译安装
异常处理 1 2 3 4 /usr/bin/ld: ext/ldap/.libs/ldap.o: undefined reference to symbol 'ber_strdup' //usr/lib64/liblber-2.4.so.2: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status make: *** [sapi/cli/php] 错误 1
解决:vi Makefile
在以EXTRA_LIBS
开头的一行结尾添加-llber
配置php配置文件 1 2 3 4 5 cp /usr/local /php/etc/php-fpm.conf.default /usr/local /php/etc/php-fpm.conf cp /usr/local /php/etc/php-fpm.d/www.conf.default /usr/local /php/etc/php-fpm.d/www.conf cp /root/php-7.2.8/php.ini-production /usr/local /php/etc/php.ini
修改php.ini 1 vi /usr/local /php/etc/php.ini
1 2 3 post_max_size = 8M max_execution_time = 300 max_input_time = 300
php-fpm服务化 修改php-fpm.conf 1 vi /usr/local /php/etc/php-fpm.conf
找到以下内容并修改:
1 2 3 4 ; Pid file ; Note: the default prefix is /usr/local /php/var ; Default Value: none pid = run/php-fpm.pid
创建php-fpm服务文件 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 cat <<EOF> /usr/lib/systemd/system/php-fpm.service [Unit] Description=The PHP FastCGI Process Manager After=syslog.target network.target [Service] Type=forking PIDFile=/usr/local /php/var/run/php-fpm.pid ExecStart=/usr/local /php/sbin/php-fpm ExecReload=/bin/kill -USR2 $MAINPID PrivateTmp=true [Install] WantedBy=multi-user.target EOF
启动php-fpm服务
nginx配置 nginx中添加如下配置即可解析php页面
location ~ \.php$ {
root /data/www/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}