nginx,官网提供了yum源
新建/etc/yum.repos.d/nginx.repo
[nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/7/$basearch/ gpgcheck=0 enabled=1
yum install nginx
systemctl start nginx
systemctl enable nginx
php
官方文档环境配置
yum install autoconf automake libtool re2c flex bison libxml2-devel
https://php.net/downloads.php
选了个新加坡源
wget http://sg2.php.net/get/php-5.6.34.tar.gz/from/this/mirror mv mirror php-5.6.34.tar.gz tar -zxvf php-5.6.34.tar.gz && cd php-5.6.34 ./configure --enable-fpm --with-mysql make && make install cp php.ini-development /usr/local/php/php.ini cp /usr/local/etc/php-fpm.conf.default /usr/local/etc/php-fpm.conf cp sapi/fpm/php-fpm /usr/local/bin #php7.2#cp /usr/local/etc/php-fpm.d/www.conf.default /usr/local/etc/php-fpm.d/www.conf vim /usr/local/php/php.ini
将;cgi.fix_pathinfo=1改为cgi.fix_pathinfo=0
#vim /usr/local/etc/php-fpm.conf
#去掉NONE/
include=etc/php-fpm.d/*.conf
#vim /usr/local/etc/php-fpm.d/www.conf
vim /usr/local/etc/php-fpm.conf
user = www-data
group = www-data
添加用户组和用户
groupadd www-data
useradd -g www-data www-data
vim /etc/systemd/system/php-fpm.service
[Unit] Description=php-fpm After=network.target [Service] Type=forking ExecStart=/usr/local/bin/php-fpm PrivateTmp=true [Install] WantedBy=multi-user.target
systemctl start php-fpm
systemctl enable php-fpm
systemctl status php-fpm
配置Nginx支持Php
vim /etc/nginx/conf.d/default.conf
location / { root /usr/share/nginx/html; index index.php index.html index.htm; } location ~* \.php$ {
root /usr/share/nginx/html; fastcgi_index index.php; fastcgi_pass 127.0.0.1:9000; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; }
systemctl restart nginx
测试
rm /usr/share/nginx/html/index.html
echo "<?php phpinfo(); ?>" >> /usr/share/nginx/html/index.php
mariadb
vim /etc/yum.repos.d/MariaDB.repo
[mariadb] name = MariaDB baseurl = https://mirrors.tuna.tsinghua.edu.cn/mariadb//mariadb-10.2.13/yum/centos74-amd64/ gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1
yum install MariaDB-server MariaDB-client
systemctl start mysql
mysql_secure_installation
[enter]
n n n n n
#php7.2#Mysql扩展安装
http://git.php.net/?p=pecl/database/mysql.git;a=summary
找到最新版本下载到本机scp传到服务器上
scp mysql-647c933.tar.gz root@wars.cat:/root
cd /root
tar -zxvf mysql-*.tar.gz && cd mysql-*
phpize
./configure --with-php-config=/usr/local/bin/php-config --with-my
sql=mysqlnd
make && make install
这里make会有报错,把报错的mysqlnd路径改成/root/php-7.2.3/ext/mysqlnd(以源码存放路径为准)
成功后在php.ini里加入extension=mysql.so
vim /usr/local/php/php.ini
extension=mysql.so
systemctl restart php-fpm
-----------------------------------
出问题没解决扩展没装上
浙公网安备 33010602011771号