sh 在Ubuntu 16.04上安装Laravel 5.4,MySQL 5.7,Apache2.4和PHP7.1

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 在Ubuntu 16.04上安装Laravel 5.4,MySQL 5.7,Apache2.4和PHP7.1相关的知识,希望对你有一定的参考价值。

# CREATED BY BEN O'SULLIVAN / BIGBENO37 (GITHUB.COM/BIGBENO37)
# LICENSED UNDER CREATIVE COMMONS 'Attribution 4.0 International' LICENSE
# https://creativecommons.org/licenses/by/4.0/
# FEEL FREE TO USE AND ADAPT THIS SCRIPT IN COMMERCIAL AND NON COMMERICAL PRODUCTS
# AS LONG AS PROPER ACCREDITATION IS GIVEN

# VARIABLES
echo -e "\x1B[01;95mWhat would you like to name your Laravel project?\x1B[0m"
read LARAVEL_PROJECT_NAME

echo -e "\x1B[01;95mWhere do you want to store your Laravel project? (Use a full path such as /home/ubuntu/projects/)\x1B[0m"
read LARAVEL_PARENT_DIR

echo -e "\x1B[01;92mGreat, we'll take it from here. Don't go away just yet, we'll need you in a little bit.\x1B[0m"

LARAVEL_DIR="$LARAVEL_PARENT_DIR$LARAVEL_PROJECT_NAME";
LARAVEL_PUBLIC_DIR="$LARAVEL_DIR/public"

# INSTALL REQUIRED SOFTWARE
sudo add-apt-repository ppa:ondrej/php -y
sudo apt-get update -y
sudo apt-get upgrade -y
sudo apt-get install php7.1 php7.1-mbstring php7.1-zip php7.1-mysql unzip phpunit mysql-server -y

# CONFIGURE MYSQL
sudo mysql_secure_installation
echo -e "\x1B[01;93mGive us a sec to get MySQL initialised...\x1B[0m"
sudo mysqld --initalize
echo -e "\x1B[01;95mWe'll need that MySQL root password you set up earlier to make MySQL work with Laravel.\x1B[0m"
echo -e "CREATE USER 'homestead'@'localhost' IDENTIFIED BY 'secret'; GRANT ALL PRIVILEGES ON * . * TO 'homestead'@'localhost'; FLUSH PRIVILEGES; CREATE DATABASE homestead; USE homestead;">> setup_laravel_db.sql
mysql -u root -p < setup_laravel_db.sql

echo -e "\x1B[01;92mThat's all we need you to do. Sit back, and let us get everything going for you.\x1B[0m"

# INSTALL COMPOSER + LARAVEL
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php
php -r "unlink('composer-setup.php');"
sudo mv composer.phar /usr/local/bin/composer
composer global require "laravel/installer"

if [ ! -d $LARAVEL_DIR ]; then
    cd $LARAVEL_PARENT_DIR
    composer create-project --prefer-dist laravel/laravel $LARAVEL_PROJECT_NAME
    cd $LARAVEL_PROJECT_NAME
    php artisan key:generate
fi

# CONFIGURE APACHE2
cd ~
sudo rm /etc/apache2/sites-available/000-default.conf
echo -e "<VirtualHost *:80>\n    ServerAdmin webmaster@localhost\n    DocumentRoot /var/www/html/\n    ErrorLog ${APACHE_LOG_DIR}/error.log\n    CustomLog ${APACHE_LOG_DIR}/access.log combined\n    <Directory /var/www/html/>\n        Options Indexes FollowSymLinks\n        AllowOverride All\n        Require all granted\n    </Directory>\n</VirtualHost>">> 000-default.conf
sudo cp 000-default.conf /etc/apache2/sites-available/000-default.conf
rm 000-default.conf
sudo a2enmod php7.1
sudo a2enmod rewrite
sudo rm -rf /var/www/html/
sudo ln -s $LARAVEL_PUBLIC_DIR /var/www/html
sudo chmod 755 -R $LARAVEL_DIR
sudo chmod -R o+w $LARAVEL_DIR/storage
sudo service apache2 restart
echo -e "\x1B[01;92mThank you for your patience. Laravel has successfully been installed!\x1B[0m"

以上是关于sh 在Ubuntu 16.04上安装Laravel 5.4,MySQL 5.7,Apache2.4和PHP7.1的主要内容,如果未能解决你的问题,请参考以下文章

sh 在Ubuntu 16.04上安装Mongo 3.6

sh 在Ubuntu 16.04上安装Mongo 3.4

sh 在Ubuntu 16.04上安装Pulse Secure

sh 在Ubuntu 16.04上安装ChromeDriver和Selenium

sh 在Ubuntu 16.04上安装MariaDB服务器

sh 在Ubuntu 16.04 x64上安装Docker