我正在AWS App Runner上安装Project。项目使用php imagick,所以我试图安装它。我从github源代码(Laravel 10 + php 8.1)导入项目,并通过配置文件(apprunner.yaml)自动运行。我试图在www.example.com文件中添加几行build.sh,但项目仍然无法获得imagick。如何在aws app runner php runtime上启用此imagick?
我附上了我的当前代码。
#!/usr/bin/env bash
echo "build"
sudo yum list installed | grep php
sudo yum remove php*
sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum-config-manager --enable remi-php81
sudo yum install php81
ln -s /usr/bin/php81 /usr/bin/php
# Install Composer & necessary packages
EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]
then
>&2 echo 'ERROR: Invalid installer checksum'
rm composer-setup.php
exit 1
fi
php composer-setup.php
rm composer-setup.php
sudo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo yum -y install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
sudo yum -y update
sudo yum-config-manager --enable remi-php81
sudo yum -y install --enablerepo=remi-php81 php81 php81-php php81-php-common php81-php-mbstring php81-php-mysqlnd php81-php-xml php81-php-bcmath php81-php-gd php81-php-intl php81-php-pecl-mcrypt
sudo yum -y install --enablerepo=remi-php81 --disablerepo=amzn2-core php81-php-pecl-zip
sudo yum -y install --enablerepo=remi-php81 php81-php-pecl-imagick-im7
sudo yum -y install --enablerepo=remi-php81 php81-php-fpm php81-php-pecl-apcu php81-php-opcache
yum install nginx -y
# Install dependencies
php composer.phar install
cp -p .env.staging .env
php artisan key:generate
php artisan config:cache
php artisan config:clear
sudo chmod -R 755 ./storage
# Install PHP Imagick
echo "Installing imagick packages--------------------------------------------------------------------->>>>>"
yum install -y libpng-devel libjpeg-devel openjpeg2-devel libtiff-devel libwebp-devel giflib-devel
yum install -y gcc gcc-c++ autoconf automake
pecl install Xdebug
sudo service httpd restart
yum groupinstall "Development Tools" -y
yum install build-essential -y
yum install -y tar
curl -OL https://www.imagemagick.org/download/ImageMagick.tar.gz
tar -vxf ImageMagick.tar.gz
cd ImageMagick*
./configure --prefix=/ \
--with-bzlib=yes \
--with-fontconfig=yes --with-freetype=yes \
--with-gslib=yes --with-gvc=yes \
--with-jpeg=yes --with-openjp2=yes \
--with-png=yes \
--with-tiff=yes \
--disable-dependency-tracking
make && sudo yum install -y ImageMagick-devel & sudo make install
sudo service nginx stop
sudo service php-fpm stop
yum -y install yum-utils
yum-config-manager --disable 'remi-php*'
yum-config-manager --enable remi-php81
yum repolist
echo 'php devel install----------------------------->'
yum install -y php-cli
yum install -y php-pear
yum install -y php-dev php81-php-devel php-devel pcre-devel make
ln -s /usr/bin/phpize81 /usr/bin/phpize
ln -s /usr/bin/pecl81 /usr/bin/pecl
sudo /usr/bin/pecl install imagick
sudo echo "extension=imagick.so" > /etc/php.d/imagick.ini
sudo /etc/init.d/httpd restart
sudo service php-fpm start
sudo service nginx start
echo 'Check imagick installed status'
php -m|grep imagick
echo "Finish imagick packages--------------------------------------------------------------------->>>>>"
# Nginx And PHP-FPM Configuration
cp -p /app/scripts/resources/nginx.conf /etc/nginx/nginx.conf
cp -p /app/scripts/resources/www.conf /etc/php-fpm.d/www.conf
# Directory Permission
chown -R :nginx /app/storage
chown -R :nginx /app/bootstrap/cache
chown -R :nginx /app/public
find /app/storage -type d -exec chmod 775 {} \;
find /app/storage -type f -exec chmod 664 {} \;
find /app/bootstrap/cache -type d -exec chmod 775 {} \;
find /app/bootstrap/cache -type f -exec chmod 664 {} \;
find /app/storage -type d -exec chmod g+s {} \;
find /app/bootstrap/cache -type d -exec chmod g+s {} \;
setfacl -R -d -m g::rwx /app/storage
setfacl -R -d -m g::rwx /app/bootstrap/cache
# Log Configuration
ln -s /dev/stdout /var/log/nginx/error.log
ln -s /dev/stdout /var/log/nginx/access.log
ln -s /dev/stdout /var/log/php-fpm/error.log
ln -s /dev/stdout /var/log/php-fpm/www-access.log
ln -s /dev/stdout /var/log/php-fpm/www-error.log
# NPM Build
echo "node js, npm install"
curl -fsSL https://rpm.nodesource.com/setup_16.x | bash - && yum -y install nodejs
yum install gcc-c++ make -y
echo "npm install"
npm install
echo "npm build"
npm run build
1条答案
按热度按时间z31licg01#
您的安装看起来很混乱,您混合了php-* 和php 81-php-* 包,请参阅FAQ
在你的过去,有EL-7和EL-8指令的混合
要正确配置和使用存储库,请遵循wizard说明
总之,在EL-7上
但请注意,EL-7将在约1年内接近其EOL。
总之,在EL-8或EL-9上
然后呢
不需要构建任何东西,也不需要修改任何配置文件。