Skip to content

Instantly share code, notes, and snippets.

@fasthold
Last active November 13, 2024 04:55
Show Gist options
  • Save fasthold/8127fee6725dad39699d5d5751dda366 to your computer and use it in GitHub Desktop.
Save fasthold/8127fee6725dad39699d5d5751dda366 to your computer and use it in GitHub Desktop.
Ubuntu 22.04 PHP MySQL
# 切换阿里云源
mv /etc/apt/sources.list /etc/apt/sources.list.bak
bash -c "cat << EOF> /etc/apt/sources.list && apt update
deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
EOF"
# 安装依赖
apt install software-properties-common apt-transport-https 7zip -y
# Import PPA Repository of PHP
add-apt-repository ppa:ondrej/php -y
apt-get install -y apache2 libapache2-mod-php8.2 php8.2 php8.2-curl php8.2-gmp php8.2-intl php8.2-mbstring php8.2-opcache php8.2-pspell php8.2-xmlrpc php8.2-cli php8.2-imap php8.2-mysql php8.2-tidy php8.2-bz2 php8.2-common php8.2-dev php8.2-gd php8.2-xml php8.2-zip php8.2-bcmath
# Install Composer
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# change to aliyun mirror
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
# update php settings
curl -sSLJO https://gitee.com/dockerpivot/php-apache/raw/master/php/php.custom.ini
mv php.custom.ini /etc/php/8.2/apache2/conf.d
# Config Apache
echo "ServerName localhost" >> /etc/apache2/apache2.conf
a2enmod rewrite
a2enmod headers
# update apache settings
curl -sSLJO https://gitee.com/dockerpivot/php-apache/raw/master/apache/000-default.conf
mv 000-default.conf /etc/apache2/sites-enabled/000-default.conf
systemctl restart apache2
# Install mysql
apt install -y mysql-server
#sudo mysql_secure_installation
# kzhfbvcw8b0024yt93
#sudo mysql
## CREATE USER 'dev'@'%' IDENTIFIED WITH mysql_native_password BY 'dev';
## GRANT ALL PRIVILEGES ON *.* TO 'dev'@'%' WITH GRANT OPTION;
## FLUSH PRIVILEGES;
## exit;
#### if in vmware workstation, enlarge the disk
## lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
## resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
#### enable mysql remote access
## vim /etc/mysql/mysql.conf.d/mysqld.cnf
## change `bind-address = 127.0.0.1` to `bind-address = 0.0.0.0`
## service mysql restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment