사용환경 :  Ubunut 20.0.4 LTS, Apache2.x, Node.js, Javascript

 

Apache설정 변경

# /etc/apache2/sites-available/000-default.conf  내용 추가

<VirtualHost  *:80>
ServerName example.com

           ProxyRequests Off
           ProxyPreserveHost On
           ProxyVia Full
           <Proxy *>
              Require all granted
           </Proxy>

           <Location /nodejs>
              ProxyPass http://localhost:3000
              ProxyPassReverse http://localhost:3000
           </Location>

            <Directory "/var/www/example.com/html">
                    AllowOverride All
            </Directory>
</VirtualHost>

3000포트로 허용함을 설정

$ sudo service apache2 restart

아파치 서버 재구동 

 

# /var/www/html/nodejs/hello.js

var http = require('http');
http.createServer(function (request, response) {
   response.writeHead(200, {'Content-Type': 'text/plain'});
   response.end('Hello World! Node.js is working correctly.\n');
}).listen(3000);
console.log('Server running at http://127.0.0.1:3000/');
console.log('It is running now...');

마찬가지로 3000포트 연결 설정

 

hello.js 파일 실행

$ node /var/www/html/nodejs/hello.js 

console.log 했던 내용 출력

 

 

http://example.com:8080/node.js/
접속

접속완료

 

 

일단 서버 내에서 8080포트로 접속하여 3000포트의 Websocket communication 로그 출력이 완료되었다.

 

 

 

 

Apache + Node.js + socket.io

코드 이그나이터에서 웹소켓을 돌리는데 드디어 성공! 꽤나 뿌듯하다. 스택 오버플로우와 국내 블로그의 도움을 많이 받았다. 순서대로 오늘 한 일에 대해서 나열해보자면 1. 공유기 포트포워딩

blog.rgbplace.com

 

Set Up a Node.js App for a Website With Apache on Ubuntu 16.04

This tutorial will explain how to set up a Cloud Server running Ubuntu 16.04 so that Node.js scripts run as a service, and configure the Apache server to make the script accessible from the web.

www.ionos.com

 

Behind a reverse proxy | Socket.IO

You will find below the configuration needed for deploying a Socket.IO server behind a reverse-proxy solution, such as:

socket.io

 

반응형

 

사용환경 : Ubunutu 20.0.4 LTS, Apache

 

 

$ systemctl start apache2

 

를 통해 서버를 시작시켰는데 비밀번호를 잘 작성하였지만 해당 오류가 반환되었다. 


오류의 원인은 apache2.conf 에서 추가적인 옵션을 작성하고
아파치 서버를 재구동하였는데 에러가 발생한것이다.

 

그랬기 때문에 작성해주었던 내용을 다시 주석 처리하고 재구동 시켜보니 정상적으로 구동되었다.

ProxyPass /node http://localhost:8000 을 작성하고 집어넣은건데 왜 안된걸까,,
(WebSocket 어떡함...)

 

 

반응형

리눅스에서 Apache의 설정 파일 httpd.conf 혹은 apache2.conf의 위치는

 

CentOS : /etc/httpd/conf/httpd.conf

Ubuntu  : /etc/apache2/apache2.conf

 

이다. 

 

 

 

 

 

 

아파치 설정파일 httpd.conf, apache2.conf 위치 확인 - 제타위키

다음 문자열 포함...

zetawiki.com

 

반응형

REST API를 적용하고,
Vue.js 혹은 React.js에서 Axios를 사용할 때에 초보자는 도대체 backend 를 담당하는 파일을 어디에다가 놓아야할지 모를 경우가 생깁니다.

네 그게 바로 접니다.

환경 및 사용 : Linux (Ubuntu) , Apache , vue - cli project , php , axios

 

예시)

        axios
          .get('http://urlExample:8080/phpFileName')
          .then(function(response) {
          console.log(response);
          })
          .catch(function(error) {
          console.log(error.response.data);
          })

get 방식으로 axios를 사용해보겠습니다.

 

apache 서버는 8080포트를 기본으로 사용하고 있습니다. 이를 통해 axios를 port 8080에서 값을 요청하고 받아옵니다.

그럴 때 php 파일의 위치는 

/var/www/html/ 에 작성해야합니다.

 

추가적으로 api 폴더를 생성하여 그곳에 넣는 방법도 있습니다. ㅎㅎ

 

 

만약 이렇게 했을 때 아래와 같은 에러가 발생하면 해당 포스트를 확인해주시길 바랍니다.

 

[ PHP, Vue.js ] 에러 해결 Access to XMLHttpRequest at blocked by CORS policy: No 'Access-Control-Allow-Origin' header is pr

Access to XMLHttpRequest at 'http://url/fileName' from origin 'http://url:port-number' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource...

code-hoon.tistory.com

 

감사합니다.

 

반응형

sudo service apache2 start / restart 에러

systemctl status apache2.service
● apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Wed 2021-10-27 14:16:45 KST; 16min ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 475439 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)

10월 27 14:16:45 server systemd[1]: Starting The Apache HTTP Server...
10월 27 14:16:45 server apachectl[475447]: apache2: Syntax error on line 231 of /etc/apache2/apache2.conf: Could not open configuration file /etc/phpmyadmin/apache.conf: No such file or directory
10월 27 14:16:45 server apachectl[475439]: Action 'start' failed.
10월 27 14:16:45 server apachectl[475439]: The Apache error log may have more information.
10월 27 14:16:45 server systemd[1]: apache2.service: Control process exited, code=exited, status=1/FAILURE
10월 27 14:16:45 server systemd[1]: apache2.service: Failed with result 'exit-code'.
10월 27 14:16:45 server systemd[1]: Failed to start The Apache HTTP Server.

환경: Linux Ubuntu 20.0.4LTS, PHP8, Apache 사용

사전 작업 : php7.4 -> php 8.0으로 업그레이드 (완료)

 

이에 해당하는 에러를 어떤 사람이 /etc/apache2/apache2.conf  파일의 수정을 통해 해결했다는 내용이 있었다.

 

이에 맞춰 apache2.conf 를 자세히 보던 와중 에러 문구가 눈에 띄었다.

phpmyadmin 부분에서 문제라는 것을 확인하였다. 

 

그래서 과감하게 (사실은 소심하게 주석까지 해주면서ㅋㅋ)  phpmyadmin을 사용하지 않으니 해당 부분을 주석처리하여 서버(server)를 구동할 때 해당 부분을 읽지 않게 하였더니 성공.

=> 하지만 이것은 phpmyadmin을 사용하시는 분들은 하면 안된다는 것을 확인해주세요.

 

아무래도 php 버전 업그레이드(7.4->8.0 upgrade)를 하면서
phpmyadmin 고유의 데이터베이스(database)를 놓고,

해당 부분을 추가적으로 손보지 않았기 때문에 이러한 에러가 발생한 것 같았다.

 

그리고 이제 다시 restart를 해보니 성공.

 

 

이상입니다.

 

apache2 error Could not open configuration file /etc/apache2/conf.d/: No such file or directory

I have just upgraded my Ubuntu 13.10 and apache2 is not working. When I try to start the apache2 server it is printing following errors: * Starting web server apache2 * The apache2 configtest fa...

askubuntu.com

 

How can I start apache2 from error code=exited status=1 | DigitalOcean

Im a web developer and im new in Ubuntu, I have days trying to install apache2 to work with php. But I always get this error starting Apache2: ``` Job for apache2.service failed because the control process exited with error code. See 'systemctl status

www.digitalocean.com

 

apache restart 오류 질문입니다

우분투 서버이구요 index죽이기 하려고 했는데 mod_write 가 설치 안되어있는 것같아 구글링해서 설치하던 중  service apache2 restart를 했는데 아래와 같이 나옵니다..   Job for apache2.service f

www.cikorea.net

 

How to Upgrade from PHP 7.x to PHP 8 on Ubuntu (Apache) - DevAnswers.co

How-to guide on upgrading PHP 7.x to PHP 8 on Ubuntu (Apache). Remove PHP 7.x and Install PHP 8 on Ubuntu (Apache)

devanswers.co

 

반응형

+ Recent posts