網(wǎng)站建設(shè)網(wǎng)頁設(shè)計案例汕頭網(wǎng)站建設(shè)開發(fā)
centos6系統(tǒng)已經(jīng)被官網(wǎng)停止維護,要安裝軟件必須用第三方的RPM包,下面使用yum安裝php7.4正式版,當(dāng)前基于WLNMP提供的一鍵安裝包來安裝
1、添加epel源
yum install epel-release
yum install epel-release
2、添加WLNMP一鍵安裝包源
rpm -ivh http://mirrors.wlnmp.com/centos/wlnmp-release-centos.noarch.rpm
rpm -ivh http://mirrors.wlnmp.com/centos/wlnmp-release-centos.noarch.rpm
3、安裝php7.4
yum clean all
yum install wphp74
yum clean all
yum install wphp74
在centos6系統(tǒng)安裝完php7.4,默認(rèn)會通過php-fpm方式自動啟動,并且已經(jīng)設(shè)置好了開機自啟,只需要配置下nginx即可。
4、配置nginx
如果使用WLNMP提供的nginx,只需要在安裝后取消include enable-php71.conf;注釋即可
WLNMP安裝nginx方法
yum install wnginx
?
如果當(dāng)前使用的是非WLNMP提供的nginx,只需要在nginx中配置以下內(nèi)容即可(fastcgi_pass unix:/tmp/php-fpm74.sock; 是關(guān)鍵AbiaoOK)
? ? ??
? ? ? ? location ~ [^/]\.php(/|$)
? ? ? ? {
? ? ? ? ? ? try_files $uri =404;
? ? ? ? ? ? fastcgi_pass ?unix:/tmp/php-fpm74.sock;
? ? ? ? ? ? fastcgi_index index.php;
? ? ? ? ? ? include fastcgi.conf;
? ? ? ? }
更多相關(guān)內(nèi)容可參考:https://www.wlnmp.com/
可以支持兩種不同版本的php(5.6版本和7.4版本):
fastcgi_pass ? 127.0.0.1:9000; ? (php56w)
fastcgi_pass ?unix:/tmp/php-fpm74.sock; ? (wphp74)
在centos6系統(tǒng)安裝完php7.4,默認(rèn)會通過php-fpm方式自動啟動,并且已經(jīng)設(shè)置好了開機自啟,只需要配置下nginx即可。
centos6安裝了wphp74后, 原先php56w-gd不能用了,安裝會提示沖突,那么后續(xù)版本智能用7.4啦? gd庫沖突,暫時無法解決,只能2選一,那么就全部用PHP7.4吧!!
支持THINKPHP6偽靜態(tài)規(guī)則,nginx配置代碼(虛擬主機路徑 /usr/local/nginx/conf/vhost):
server {listen 443 ssl;server_name testapp.com www.testapp.com;#ssl on;ssl_certificate ? ? ?/data/ssl/www.testapp.com;.pem; ? ?ssl_certificate_key ?/data/ssl/www.testapp.com.key; ?ssl_session_timeout ?5m;#ssl_protocols TLSv1 TLSv1.1 TLSv1.2;#ssl_prefer_server_ciphers ? on;?root /myweb/new/testapp.com;?? ?location / { ? ? ? ?index ?index.php index.html index.htm;if (!-e $request_filename) { ?rewrite ?^/(.*)$ ?/index.php/$1 ?last; ?break; ?} ?}location ~ \.php/?.*$ {fastcgi_pass ? 127.0.0.1:9000;fastcgi_index ?index.php; ??#fastcgi_param ?SCRIPT_FILENAME ?$document_root$fastcgi_script_name;?include ? ? ? ?fastcgi_params;set $temp_script_name $fastcgi_script_name; ?if ($fastcgi_script_name ~ "^(.+\.php)(/.+)$") { ?set $temp_script_name $1; ?set $path_info $2; ?} ?fastcgi_param ? PATH_INFO $path_info;?fastcgi_param ? SCRIPT_FILENAME ? $document_root$temp_script_name; ?fastcgi_param ? SCRIPT_NAME ? $temp_script_name; ?}location ~ /\.ht {deny ?all;?}
}server {listen?? ?80;server_name testapp.com www.testapp.com;client_max_body_size 80m;?#error_page 404 /data/ymg280/404.html;#error_page 500 502 503 504 /errors/default/50x.html;if ($host != 'www.testapp.com'){rewrite ^/(.*)$ http://www.testapp.com/$1 permanent;}root /myweb/new/qingmi.link;location / {index ?index.php index.html index.htm;if (!-e $request_filename) { ?rewrite ?^/(.*)$ ?/index.php/$1 ?last; ?break; ?} ?}location ~ \.php/?.*$ {fastcgi_pass ? 127.0.0.1:9000;fastcgi_index ?index.php; ??include ? ? ? ?fastcgi_params;? ? ? ??set $temp_script_name $fastcgi_script_name; ?if ($fastcgi_script_name ~ "^(.+\.php)(/.+)$") { ?set $temp_script_name $1; ?set $path_info $2; ?} ?fastcgi_param ? PATH_INFO $path_info;?fastcgi_param ? SCRIPT_FILENAME ? $document_root$temp_script_name; ?fastcgi_param ? SCRIPT_NAME ? $temp_script_name; ?}location ~ /\.ht {deny ?all;?}? ??
}
安裝過程可能遇到的問題,做了粗略的筆記:?
安裝redis擴展??
https://blog.csdn.net/u010227042/article/details/118766460
安裝php-redis擴展
下載redis擴展
首先和redis一樣,也需要下載php-redis的擴展。
在php官方redis擴展地址https://pecl.php.net/package/redis/找到我們所需要的擴展,下載即可。比如我們要安裝5.2.1版本的php-redis擴展,執(zhí)行命令:
#下載
wget http://pecl.php.net/get/redis-5.2.1.tgz
#解壓
tar xzf redis-5.2.1.tgz
#進入目錄
cd redis-5.2.1
編譯安裝
在剛剛下載redis擴展的源碼目錄下執(zhí)行phpize(如果不知道phpize請往下看分解)
/usr/local/php/bin/phpize
執(zhí)行? ./configure --with-php-config=/usr/local/php/bin/php-config
生成配置文件
編譯 make && make install
記得make test 看一下編譯過程的問題已經(jīng)文件的存儲路徑??
autoconf-2.6版本太低,不支持,要先安裝autoconf-2.69
linux安裝autoconf-2.69
————————————————
檢查是否有安裝autoconf其他版本:
rpm -qf /usr/bin/autoconf
如有安裝,則先卸載相應(yīng)版本,否則不用處理。執(zhí)行以下命令卸載:
rpm -e --nodeps autoconf-2.63
wget ftp://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
解壓安裝:
tar zxvf autoconf-2.69.tar.gz
編譯源文件:
cd autoconf-2.69
./configure --prefix=/usr/
make && make install
檢查版本:
/usr/bin/autoconf -V
最后再:?vim /usr/local/php/etc/php.ini??
添加擴展:?extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20190902/redis.so
重啟php-fpm74:
? ? ?service php-fpm74 restart
重啟nginx:
? ? ?service nginx restart
PHP輸出的弱發(fā)現(xiàn)狀態(tài)碼不是200,而是500,那么很可能是權(quán)限設(shè)置的問題:
vim /usr/local/php/etc/php-fpm.conf
?
[global]
pid = /usr/local/php/var/run/php-fpm74.pid
error_log = /usr/local/php/var/log/php-fpm74_error.log
log_level = notice
;alert,error,warning,notice,debug[www]
listen.owner = nginx
listen.group = nginx
listen = /tmp/php-fpm74.sock
listen.backlog = -1
listen.allowed_clients = 127.0.0.1
listen.mode = 0666
user = nginx
group = nginx
pm = dynamic
pm.start_servers = 10
pm.min_spare_servers = 10
pm.max_spare_servers = 20
pm.max_children = 20
pm.max_requests = 1000
;pm = static
request_terminate_timeout = 100
request_slowlog_timeout = 0
slowlog = /var/log/php_slow.log
設(shè)置用戶和用戶組都為nginx, 跟文件夾所屬用戶組保持一致,另外可以設(shè)置文件夾權(quán)限為:777
[root@iZuf63qiu57nxc0lmplkxbZ redis-5.2.1]# chmod 777 /myweb/qmq -R
[root@iZuf63qiu57nxc0lmplkxbZ redis-5.2.1]# chown nginx:nginx /myweb/qmq -R
重啟php-fpm74:
? ? ?service php-fpm74 restart
重啟nginx:
? ? ?service nginx restart