Home  >  Article  >  Web Front-end  >  How to use apache to deploy react

How to use apache to deploy react

藏色散人
藏色散人Original
2022-12-29 09:57:052206browse

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
Legend: (The following is successful )

How to use apache to deploy react

Start apache

net start Apache2.4

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>

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
Put the generated packaging file into the apache root directory

How to use apache to deploy react

Restart apache

net restart Apache2.4
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!

Statement:
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