Set of commands for a quick Laravel install on RedHat 7.3
If you want to install Laravel on a RedHat 7.3 OS, you will have to use PHP 7.0.* as this is a Laravel minimum requirement, so this is the set of commands that I used in order to configure the needed software for Laravel. ( you can also download the set of commands as a text file below).
Also, I would like to mention that I generally prefer Nginx over Apache, and HTTPS obviously, but this is just a quick setup.
Commands:
#--- AutoStart network interface
nmtui
#--- Open FireWall 80
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload
#--- Check the updated rules with:(optional)
firewall-cmd --list-all
#--- Delete PHP 5.4
yum list php
yum remove php.x86_64
#--- Delete HTTPD
yum list httpd
yum remove httpd.x86_64
#--- Repo List(optional)
subscription-manager repos --list
#--- Enable RHSCL
subscription-manager repos --enable rhel-server-rhscl-7-eus-rpms
#--- Verify RHSCL Channels(optional)
rhn-channel --list
#--- Search for Apache 24(optional)
yum list available httpd24\*
#--- Install Apache24
yum install httpd24.x86_64
systemctl enable httpd24-httpd
systemctl start httpd24-httpd
#--- Search for PHP(optional)
yum list available rh-php\*
#--- Install PHP
yum install rh-php70.x86_64
yum install rh-php70-php-mbstring.x86_64
yum install rh-php70-php-bcmath.x86_64
yum install rh-php70-php-mysqlnd.x86_64
yum install rh-php70-php-fpm.x86_64
systemctl enable rh-php70-php-fpm
systemctl start rh-php70-php-fpm
#--- Set Apache24 with php7-fpm
Config file:
For app directory ADD:
AllowOverride All
# php-fpm
<FilesMatch "\.php#--- AutoStart network interface
nmtui
#--- Open FireWall 80
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload
#--- Check the updated rules with:(optional)
firewall-cmd --list-all
#--- Delete PHP 5.4
yum list php
yum remove php.x86_64
#--- Delete HTTPD
yum list httpd
yum remove httpd.x86_64
#--- Repo List(optional)
subscription-manager repos --list
#--- Enable RHSCL
subscription-manager repos --enable rhel-server-rhscl-7-eus-rpms
#--- Verify RHSCL Channels(optional)
rhn-channel --list
#--- Search for Apache 24(optional)
yum list available httpd24\*
#--- Install Apache24
yum install httpd24.x86_64
systemctl enable httpd24-httpd
systemctl start httpd24-httpd
#--- Search for PHP(optional)
yum list available rh-php\*
#--- Install PHP
yum install rh-php70.x86_64
yum install rh-php70-php-mbstring.x86_64
yum install rh-php70-php-bcmath.x86_64
yum install rh-php70-php-mysqlnd.x86_64
yum install rh-php70-php-fpm.x86_64
systemctl enable rh-php70-php-fpm
systemctl start rh-php70-php-fpm
#--- Set Apache24 with php7-fpm
Config file:
For app directory ADD:
AllowOverride All
# php-fpm
<FilesMatch "\.php$">
<If "-f %{REQUEST_FILENAME}">
# Pick one of the following approaches
# Use the standard TCP socket
SetHandler "proxy:fcgi://127.0.0.1:9000"
# If your version of httpd is 2.4.9 or newer (or has the back-ported feature), you can use the unix domain socket
#SetHandler "proxy:unix:/path/to/app.sock|fcgi://localhost/:9000"
</If>
</FilesMatch>
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
#--- Restart httpd24 server and test PHP
systemctl start httpd24-httpd
go to http://serverIP/test.php (<?php echo phpinfo() ?>)
#--- Search for MYSQL (optional)
yum list available rh-my\*
#--- Install MYSQL5.7
yum install rh-mysql57.x86_64
#--- AutoStart and start MYSQL57 service
systemctl enable rh-mysql57-mysqld
systemctl start rh-mysql57-mysqld
#--- Search for temporary Password in log(optional)
Logfile: /var/opt/rh/rh-mysql57/log/mysql/mysqld.log
#--- Upload PHPMyAdmin47 to DocumentRoot/phpmyadmin47
rename file from /phpmyadmin47/config.sample.inc.php to config.inc.php
config.inc.php edit file change var to $cfg['Servers'][$i]['AllowNoPassword'] = true;
#--- Add password to Mysql root user if it doesn't have one
Login to PHPMyAdmin47 using http://(ip||dns)/phpmyadmin47
Run SQL query:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'exampleApp11150!';
#--- Upload/Extract/config yourlaravelproject.tar
cd /opt/rh/httpd24/root/var/www/
tar -xf yourlaravelproject.tar
#--- Change DocumentRoot to "/opt/rh/httpd24/root/var/www/yourlaravelproject/public/"
#--- Upload PHPMyAdmin47 to DocumentRoot/phpmyadmin47
#--- restart httpd
systemctl restart httpd24-httpd
#--- Create and upload DB
#--- set configuration in env file in /opt/rh/httpd24/root/var/www/yourlaravelproject
#--- chmod 777 on brdeval
#--- set permisiion on storage chmod -R ug+rwx storage bootstrap/cache
chcon -R -t httpd_sys_rw_content_t storage
chcon -R -t httpd_sys_rw_content_t bootstrap/cache
List semanage port -l | grep http_port_t
#--- Enable connection form httpd to db selinux
setsebool httpd_can_network_connect 1
setsebool httpd_can_network_connect_db 1
systemctl restart httpd24-httpd
#--- Test application with http://(ip||dns)
quot;>
<If "-f %{REQUEST_FILENAME}">
# Pick one of the following approaches
# Use the standard TCP socket
SetHandler "proxy:fcgi://127.0.0.1:9000"
# If your version of httpd is 2.4.9 or newer (or has the back-ported feature), you can use the unix domain socket
#SetHandler "proxy:unix:/path/to/app.sock|fcgi://localhost/:9000"
</If>
</FilesMatch>
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
#--- Restart httpd24 server and test PHP
systemctl start httpd24-httpd
go to http://serverIP/test.php (<?php echo phpinfo() ?>)
#--- Search for MYSQL (optional)
yum list available rh-my\*
#--- Install MYSQL5.7
yum install rh-mysql57.x86_64
#--- AutoStart and start MYSQL57 service
systemctl enable rh-mysql57-mysqld
systemctl start rh-mysql57-mysqld
#--- Search for temporary Password in log(optional)
Logfile: /var/opt/rh/rh-mysql57/log/mysql/mysqld.log
#--- Upload PHPMyAdmin47 to DocumentRoot/phpmyadmin47
rename file from /phpmyadmin47/config.sample.inc.php to config.inc.php
config.inc.php edit file change var to $cfg['Servers'][$i]['AllowNoPassword'] = true;
#--- Add password to Mysql root user if it doesn't have one
Login to PHPMyAdmin47 using http://(ip||dns)/phpmyadmin47
Run SQL query:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'exampleApp11150!';
#--- Upload/Extract/config yourlaravelproject.tar
cd /opt/rh/httpd24/root/var/www/
tar -xf yourlaravelproject.tar
#--- Change DocumentRoot to "/opt/rh/httpd24/root/var/www/yourlaravelproject/public/"
#--- Upload PHPMyAdmin47 to DocumentRoot/phpmyadmin47
#--- restart httpd
systemctl restart httpd24-httpd
#--- Create and upload DB
#--- set configuration in env file in /opt/rh/httpd24/root/var/www/yourlaravelproject
#--- chmod 777 on brdeval
#--- set permisiion on storage chmod -R ug+rwx storage bootstrap/cache
chcon -R -t httpd_sys_rw_content_t storage
chcon -R -t httpd_sys_rw_content_t bootstrap/cache
List semanage port -l | grep http_port_t
#--- Enable connection form httpd to db selinux
setsebool httpd_can_network_connect 1
setsebool httpd_can_network_connect_db 1
systemctl restart httpd24-httpd
#--- Test application with http://(ip||dns)