How to use apache to deploy react

藏色散人
Release: 2022-12-29 09:57:05
Original
2239 people have browsed it

How to deploy react using apache: 1. Download Apache and unzip it; 2. Modify "heetd.conf" in the conf folder; 3. Use the statement "httpd.exe -k install" to install and start apache; 4. Change the address of the requested data to the address of the server; 5. Put the generated packaging file into the apache root directory and restart apache.

How to use apache to deploy react

The operating environment of this tutorial: Windows 10 system, react18.0.0 version, Dell G3 computer.

Apache deploys react projects (from installation to deployment)

1. Installation

1.1 Download Apache

Portal: Apache Haus Downloads

How to use apache to deploy react

#After decompression, I put it into the E drive

How to use apache to deploy react

## 1.2 Modify conf Folder heetd.conf(

39 lines) Key points

How to use apache to deploy react

changed to

How to use apache to deploy react

The port can be changed to what you need (if you don’t change it, the port may be occupied and cannot be started) (

67 line )

How to use apache to deploy react

1.3 Use the statement httpd.exe -k install to install

Next step, enter the bin file, enter cmd as administrator, execute the statement

httpd.exe -k install
Copy after login
Legend: (The following is successful )

How to use apache to deploy react

Start apache

net start Apache2.4
Copy after login

Note: Stop available net stop Apache2.4

The first step is completed.

2. Configuration file (solve routing failure, that is, click does not jump)

2.1 Modify the httpd.conf

167 line in the conf folder and delete the first

How to use apache to deploy react

Change None to All (you can use the characters in the file to search, there are three places in total)

How to use apache to deploy react

2.2 Add. htaccess file

Create a new .htaccess, add the following code, and put it into the apache root directory

<ifmodule>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.html$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.html [L]
</ifmodule>
Copy after login

How to use apache to deploy react

2.3 Configuration package.json

Add

How to use apache to deploy react

3. Packaging project

3.1 Change the address

Change the address of the requested data to the address of the server

3.2webpack packaging

Execution

npm run build
Copy after login
Put the generated packaging file into the apache root directory

How to use apache to deploy react

Restart apache

net restart Apache2.4
Copy after login
Finally enter the server address xxx.xxx.xxx.xxx: port number in the address bar to access the web page.

Recommended learning: "

react video tutorial"

The above is the detailed content of How to use apache to deploy react. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template