php与nginx安装
1、安装libzip-1.2.0
wget https://libzip.org/download/libzip-1.2.0.tar.gz --no-check-certificate tar -zxvf libzip-1.2.0.tar.gz cd libzip-1.2.0/ ./configure make && make install export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/"
2、安装PHP
./configure \ --prefix=/usr/share/php \ --with-config-file-path=/usr/share/php/conf \ --with-curl \ --with-freetype \ --enable-gd \ --with-jpeg \ --with-gettext \ --with-kerberos \ --with-libdir=lib64 \ --with-libxml \ --with-mysqli \ --with-openssl \ --with-pdo-mysql \ --with-pdo-sqlite \ --with-pear \ --enable-sockets \ --with-mhash \ --with-ldap-sasl \ --with-xsl \ --with-zlib \ --with-zip \ --with-bz2 \ --with-iconv \ --enable-fpm \ --enable-pdo \ --enable-bcmath \ --enable-mbregex \ --enable-mbstring \ --enable-opcache \ --enable-pcntl \ --enable-shmop \ --enable-soap \ --enable-sockets \ --enable-sysvsem \ --enable-xml \ --enable-sysvsem \ --enable-cli \ --enable-opcache \ --enable-intl \ --enable-calendar \ --enable-static \ --enable-mysqlnd
make && make install
3、管理配置文件
#解压的目录下,复制文件到安装路径下 cp php.ini-production /usr/share/php/etc/php.ini
#到安装路径下生成www配置文件 cd /usr/share/php/etc/php-fpm.d/ cp www.conf.default www.conf #增加html htm vi /usr/share/php/etc/php-fpm.d/www.conf security.limit_extensions = .php .php3 .php4 .php5 .php7 .html .htm
#到安装路径下生成php-fpm配置文件 cd /usr/share/php/etc cp php-fpm.conf.default php-fpm.conf
#配置环境变量 export PATH=$PATH:/usr/share/php/sbin:/usr/share/php/bin
4、启动PHP
/usr/share/php/bin/php-frm
5、配置nginx
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm info.php;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index info.php;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
}增加https授权访问
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm info.php;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index info.php;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
server {
listen 443 ssl;
server_name localhost yw.jasolar.com;
ssl_certificate /usr/share/nginx/ssl/7243397__jasolar.com.pem;
ssl_certificate_key /usr/share/nginx/ssl/7243397__jasolar.com.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
root html;
fastcgi_pass 127.0.0.1:9000;
include fastcgi.conf;
index index.html index.htm info.php;
}
}
}