Linux下PHP+Nginx环境搭建 (3)

对nginx服务执行停止/启动/重新读取配置文件操作

`#启动nginx服务``systemctl start nginx.service``#停止nginx服务``systemctl stop nginx.service``#重启nginx服务``systemctl restart nginx.service``#重新读取nginx配置(这个最常用, 不用停止nginx服务就能使修改的配置生效)``systemctl reload nginx.service` MySQL安装: Linux yum-rpm [root@localhost src]# rpm -qa |grep mysql [root@localhost src]# wget [root@localhost src]# rpm -ivh mysql-community-release-el7-5.noarch.rpm [root@localhost src]# yum dpdate [root@localhost src]# yum install mysql-server [root@localhost src]# chown mysql:mysql -R /var/lib/mysql 设置权限 [root@localhost src]# mysqld --initialize 初始化mysql [root@localhost src]# systemctl start mysqld 启动mysql PHP环境: 编译安装php-fpm

PHP-FPM是一个PHP FastCGI管理器,是只用于PHP的

安装依赖包

# yum -y install libmcrypt-devel mhash-devel libxslt-devel \ libjpeg libjpeg-devel libpng libpng-dvevl freetype freetype-devel libxml2 libxml2-devel \ zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel \ ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel \ krb5 krb5-devel libidn libidn-devel openssl openssl-devel # yum -y install libzip # wget # tar -zxvf libzip-1.3.2.tar.gz cd libzip-1.3.2 # ./configure # make && make install # wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.tar.gz # tar -zxvf libmcrypt-2.5.7.tar.gz # cd libmcrypt-2.5.7 # ./configure –prefix=http://www.likecs.com/usr/local # make && make install

源码安装PHP:

# cd /usr/local/src # wget # tar -zxvf php-5.6.27.tar.gz # ./configure --prefix=http://www.likecs.com/usr/local/php --enable-fpm --with-mcrypt \ --enable-mbstring --enable-pdo --with-curl --disable-debug --disable-rpath \ --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets \ --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex \ --with-mhash --enable-zip --with-pcre-regex --with-pdo-mysql --with-mysqli \ --with-gd --with-jpeg-dir --with-freetype-dir --enable-calendar\ # make && make install

我在执行configure时,发生报错:Please reinstall the libzip distribution 于是我删除了旧版的libzip“yum remove libzip”,之后下载libzip源码包进行本地执行configure+make&&make install

执行libzip的安装:

# wget https://libzip.org/download/libzip-1.5.2.tar.gz # tar -zxf libzip-1.2.0.tar.gz # cd libzip-1.2.0 # ./configure # make && make install

PHP安装新问题:安装执行configure时报错

configure: error: off_t undefined; check your library configuration

解决方法:

vim /etc/ld.so.conf #添加如下几行 /usr/local/lib64 /usr/local/lib /usr/lib /usr/lib64 #保存退出 :wq ldconfig -v # 执行命令,使之生效

报错:configure: WARNING: unrecognized options: --with-mcrypt

解决方法:PHP 7.2+不支持 --with-mcrypt ; --enable-gd-native-ttf

# ./configure --prefix=http://www.likecs.com/usr/local/php --enable-fpm \ --enable-mbstring --enable-pdo --with-curl --disable-debug --disable-rpath \ --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets \ --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex \ --with-mhash --enable-zip --with-pcre-regex --with-pdo-mysql --with-mysqli \ --with-gd --with-jpeg-dir --with-freetype-dir --enable-calendar\

其它错误可以参考百度/Google解决(常见php安装的方案)!

至此!PHP-fpm安装的基本流程结束了,下一步就需要配置文件

用户配置文件

为php提供配置文件:php.ini

# cp php.ini-production /usr/local/php/lib/php.ini

为php-fpm提供配置文件

# cd /usr/local/php # cp etc/php.fpm.conf.default etc/php-fpm.conf # vi etc/php-fpm.conf

vi打开php-fpm.conf文件:

将文件的尾部的索引;修改成实际的目录

include=http://www.likecs.com/usr/local/php/etc/php-fpm.d/*.conf

添加用户和组:

useradd mirror groupadd -g mirror mirror

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zyjxwp.html