程式教學,  開發與維運

CentOS 7.6 Install Httpd, PHP7.2, Laravel6.0

Update System

sudo yum –y update
sudo yum –y upgrade
sudo yum -y install yum-utils

Install Httpd

//安裝Httpd
sudo yum install httpd
//開啟伺服器
sudo systemctl start httpd
//開機會自動開啟伺服器
sudo systemctl enable httpd

Install PHP 7.2

sudo yum -y install epel-release
sudo rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum-config-manager --enable remi-php72
sudo yum update
sudo yum -y install php php-opcache

Restart Httpd

sudo systemctl restart httpd.service

Prepared Install Laravel 6

### edit memory_limit = -1
sudo vi /etc/php.ini

### swap memory
sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
sudo /sbin/mkswap /var/swap.1
sudo /sbin/swapon /var/swap.1

Install Laravel 6.0

sudo yum install composer
composer create-project --prefer-dist laravel/laravel blog

Check Firewall

firewall-cmd --state
# if running
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload

Disabled SELinux

vi /etc/sysconfig/selinux
# edit
SELINUX=enforcing
# to
SELINUX=disabled

Setting Httpd Virtual Host

sudo mkdir /etc/httpd/sites-available /etc/httpd/sites-enabled
sudo vi /etc/httpd/conf/httpd.conf
# add the end o the file
IncludeOptional sites-enabled/*.conf

sudo vi /etc/httpd/sites-available/example.com.conf

# Edit
<VirtualHost *:80>
    ServerName example.com
    DocumentRoot /var/www/laravel6/public
    <Directory /var/www/laravel6>
        AllowOverride All
    </Directory>
</VirtualHost>

<VirtualHost *:443>
    ServerName example.com
    DocumentRoot /var/www/example.com/public
    SSLEngine on
    SSLCertificateFile /etc/pki/tls/certs/example.com/support.crt
    SSLCertificateKeyFile /etc/pki/tls/certs/example.com/private.key
    <Directory /var/www/example.com>
        AllowOverride All
    </Directory>
</VirtualHost>

# symbolic link
sudo ln -s /etc/httpd/sites-available/example.com.conf /etc/httpd/sites-enabled/example.com.conf

# install mod_ssl
yum install mod_ssl

# install php mysql client
sudo yum install php-mysqlnd

# restart httpd
sudo systemctl restart httpd

Leave a Reply

Your email address will not be published.