Saturday, February 5, 2022

How To Setup React.js App with Apache on Rocky Linux 8.5

 in This Tutorial you will learn " How To Install and Setup a React js App with Apache on Rocky Linux 8.5"

React (also known as React.js or ReactJS) is an open-source, front end, JavaScript library for building user interfaces or UI components. |
Apache is the most widely used web server software.
Homepage - https://reactjs.org/
_________________________________________________________________________________________
Server - Os:  Rocky Linux 8.5  64Bit      | IP -192.168.1.60        |Hostname - server.yourdomain.com
_________________________________________________________________________________________
cat /etc/system-release ; hostname ; hostname -I ; dnf groupinstall "Development Tools" -y
dnf module enable nodejs:14 -y ; dnf install nodejs npm httpd  -y
npm install -g create-react-app
create-react-app --version ; create-react-app myapp

nano /lib/systemd/system/react.service
[Unit]
After=network.target
[Service]
Type=simple
User=root
WorkingDirectory=/root/myapp
ExecStart=/usr/bin/npm start
Restart=on-failure
[Install]
WantedBy=multi-user.target
systemctl daemon-reload ; systemctl start react ; systemctl enable react ; systemctl status react

nano /etc/httpd/conf.d/example.conf
<VirtualHost *:80>
ServerName www.yourdomain.com
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
 AddDefaultCharset Off
 Order deny,allow
 Allow from all
</Proxy>
ProxyPass / http://127.0.0.1:3000/
ProxyPassReverse / http://127.0.0.1:3000/
</VirtualHost>

apachectl configtest ; systemctl start httpd ; systemctl enable httpd ; systemctl status httpd
firewall-cmd --permanent --add-port=80/tcp ; firewall-cmd --permanent --add-port=443/tcp ; firewall-cmd --reload ; echo "192.168.1.60 www.yourdomain.com"  >> /etc/hosts
www.yourdomain.com
_________________________________________________________________________________________

No comments:

Post a Comment