ubuntu 安装php7

本文提供了一步一步的指导,帮助读者完成 PHP 7.0 的安装与配置过程,包括依赖软件包的安装、编译选项的选择、PHP-FPM 的设置及与 Nginx 的集成。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

tar jxf php-7.0.0alpha2.tar.bz2
 
安装:
sudo apt-get update
sudo apt-get install libxml2-dev

安装gcc
sudo apt-get  install  build-essential

sudo apt-get install openssl 
sudo apt-get install libssl-dev 
apt-get install make
apt-get install curl
apt-get install libcurl4-gnutls-dev

sudo apt-get install libjpeg-dev

sudo apt-get install libpng-dev

sudo apt-get install libmcrypt-dev

sudo apt-get install libreadline6 libreadline6-dev

cd php-7*

3. 编译
./configure


./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysqli --with-pdo-mysql --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --disable-fileinfo --enable-maintainer-zts  

./configure --prefix=/usr/local/php --enable-fpm --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-opcache  --with-mysql --with-mysqli --with-mysql-sock  --enable-pdo --with-pdo-mysql --with-gettext --enable-mbstring --with-iconv --with-mcrypt --with-mhash --with-openssl --enable-bcmath --enable-soap --with-libxml-dir --enable-pcntl --enable-shmop --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-sockets --with-curl --with-zlib --enable-zip --enable-bz2 --with-readline --without-sqlite3 --without-pdo-sqlite --with-pear --with-libdir=/lib/x86_64-linux-gnu --with-gd --with-jpeg-dir=/usr/lib --enable-gd-native-ttf --enable-xml

#安装 PHP
 make && make test
 make && sudo make install


下面是对php-fpm运行用户进行设置
 配置php-fpm


cd /usr/local/php/etc

cp php-fpm.conf.default php-fpm.conf

vim php-fpm.conf


修改
user = www-data
 group = www-data

如果www-data用户不存在,那么先添加www-data用户
groupadd www-data
 useradd -g www-data www-data

启动php-fpm

sudo /usr/local/php/sbin/php-fpm

加入系统变量

sudo echo "PATH=$PATH:/usr/local/php/bin">> /etc/profile
 sudo echo "export PATH">> /etc/profile

 source /etc/profile


cp 解压目录/php.ini-development  /usr/local/php/lib/php.ini

php -v


 server {
    listen       80;
    server_name  10.0.5.149;
    #charset koi8-r;
    #access_log  /var/log/nginx/log/host.access.log  main;
    root   /home/sss/www;
    location / {
        index  index.html index.htm index.php;
    }
    #error_page  404              /404.html;
    # redirect server error pages to the static page /50x.html
    #
    #error_page   500 502 503 504  /50x.html;
    #location = /50x.html {
        #root   /etc/nginx/html;
    #}
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        fastcgi_param  SCRIPT_FILENAME  $Document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}


/etc/init.d/nginx restart

/etc/nginx/conf.d/default.conf

killall php-fpm

usr/local/php/sbin/php-fpm


netstat -tunpl

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值