[root@7206eb08a3a0 ~]
脚本内容
[root@7206eb08a3a0 ~]
yum -y install epel-release
yum -y install gcc gcc-c++ make wget pcre-devel zlib-devel openssl-devel libxml2-devel sqlite-devel libcurl-devel libpng-devel freetype-devel openssl-devel curl-devel oniguruma-devel
useradd -r -s /sbin/nologin www
wget https://nginx.org/download/nginx-1.18.0.tar.gz
wget https://www.php.net/distributions/php-7.4.15.tar.gz
tar -xf nginx-1.18.0.tar.gz
tar -xf php-7.4.15.tar.gz
cd /root/nginx-1.18.0
./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module && make -j2 && make install
/usr/local/nginx/sbin/nginx
cd /root/php-7.4.15
./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=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-zlib --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-ftp --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --without-pear --with-gettext --disable-fileinfo --enable-maintainer-zts && make -j 2 && make install
cp /root/php-7.4.15/php.ini-development /usr/local/php/etc/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
echo 'export PATH=$PATH:/usr/local/php/bin' >> /etc/profile
source /etc/profile
/usr/local/php/sbin/php-fpm
mv /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak
cat > /usr/local/nginx/conf/nginx.conf <<"EOF"
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;
root html;
location / {
index index.html index.htm;
}
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;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}
EOF
/usr/local/nginx/sbin/nginx -s reload
cat > /usr/local/nginx/html/demo.php <<EOF
<?php
phpinfo();
?>
EOF
echo "/usr/local/nginx/sbin/nginx" >>/etc/rc.local
echo "/usr/local/php/sbin/php-fpm">>/etc/rc.local
echo "/bin/bash" >>/etc/rc.local
chmod +x /etc/rc.d/rc.local
[root@7206eb08a3a0 ~]
[root@7206eb08a3a0 ~]
[root@7206eb08a3a0 ~]
[root@k8s-master ~]
测试镜像
[root@k8s-master ~]
[root@k8s-master ~]
[root@k8s-master ~]
[root@k8s-master ~]
[root@k8s-master ~]
cat > /data/nginx/html/demo.php <<EOF
<?php
phpinfo();
?>
EOF
[root@k8s-master ~]
游览器(google访问)
http://192.168.1.201/demo.php