My First Post      My Facebook Profile      My MeOnShow Profile      W3LC Facebook Page      Learners Consortium Group      Job Portal      Shopping @Yeyhi.com

Pages










Showing posts with label server. Show all posts
Showing posts with label server. Show all posts

Sunday, February 15, 2026

how to check apache server and php installed or not on mac

 macOS comes with Apache pre-installed, though it may not be enabled by default. You can check its installation and status using the Terminal with the following commands:

  • Check the Apache version: Running the apachectl -v command will display the installed Apache version and build date, which confirms the software is present.
    bash
    apachectl -v
    
  • Check if the Apache service is running: Use sudo apachectl status to see the current status of the Apache service. You can also use the ps aux | grep httpd command to list all running processes related to Apache's executable (httpd).
    bash
    sudo apachectl status
    # or
    ps aux | grep httpd
    
  • Verify the installation via web browser: If the service is running, open a web browser and navigate to http://localhost. If you see the message "It works!", then Apache is installed and serving web pages correctly.
  • Locate the Apache binary: The which command can show the location of the Apache executable in your system's PATH, which is typically /usr/sbin/httpd for the default macOS installation.
    bash
    which httpd
    # or
    whereis httpd
    
If these commands do not work, Apache may not be correctly configured or installed on your system. In such cases, you might consider installing it via a package manager like Homebrew.

Friday, August 16, 2024

Enable CORS on a resource using the AWS API Gateway console

 Sometimes while hitting an API gateway you get error suggesting No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.


In such a case, sometimes people suggest to set the request mode to 'no-cors' like so:

fetch(url, {

    mode: "no-cors",

    ...

})

But if you're getting CORS issues this is not the solution. If the API endpoint is something that you control, then you have to fix those CORS issue there. If the API endpoint is not something that you control, then you have to proxy your request through a server that does have CORS enabled.

You need to remove the mode: 'no-cors' setting from your request. Setting no-cors mode is exactly the cause of the problem you’re having. A no-cors request makes the response type opaque. The log snippet in the question shows that. Opaque means your frontend JavaScript code can’t see the response body or headers.

With no-cors — JavaScript may not access any properties of the resulting Response

So the effect of setting no-cors mode is essentially to tell browsers, “Don’t let frontend JavaScript code access the response body or headers under any circumstances.”

People sometimes try setting no-cors mode when a response doesn’t include the Access-Control-Allow-Origin response header or else because the request is one that triggers a CORS preflight, and so your browser does an OPTIONS preflight. But using no-cors mode isn’t a solution to those problems. The solution is either to:

  1. configure the server to which you’re making the request such that it sends the Access-Control-Allow-Origin response header, and such that it handles OPTIONS requests
  2. or set up a CORS proxy using code from https://github.com/Rob--W/cors-anywhere/ or such; see the How to use a CORS proxy to get around “No Access-Control-Allow-Origin header” problems section of the answer at No 'Access-Control-Allow-Origin' header is present on the requested resource—when trying to get data from a REST API 
  3. Temporarily you can also use Chrome extension of Enabling CORS. But it is for debugging phase only.

However, it is evident that sometimes you clearly need to Enable CORS on a resource. You can do this using the API Gateway console.


To enable CORS support on a REST API resource
  1. Sign in to the API Gateway console at https://console.aws.amazon.com/apigateway

  2. Choose an API.

  3. Choose a resource under Resources.

  4. In the Resource details section, choose Enable CORS.



Next Steps/settings In the Enable CORS box:
  • (Optional) If you created a custom gateway response and want to enable CORS support for a response, select a gateway response.
  • Select each method to enable CORS support. The OPTION method must have CORS enabled.
  • If you enable CORS support for an ANY method, CORS is enabled for all methods.
  • In the Access-Control-Allow-Headers input field, enter a static string of a comma-separated list of headers that the client must submit in the actual request of the resource. Use the console-provided header list of 'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token' or specify your own headers.
  • Use the console-provided value of '*' as the Access-Control-Allow-Origin header value to allow access requests from all origins, or specify origins to be permitted to access the resource.
  • Choose Save.



After this, deploy the API again and see the fun in next call!


Friday, March 6, 2020

First Hello World using Hack & HHVM from Facebook

1. Install HHVM on MacOS via Homebrew:
brew tap hhvm/hhvm
brew install hhvm

The out-of-the-box HHVM configuration won't need tweaking by most new users. Notably, the JIT compiler that gives HHVM its speed is on by default. If you want to take a look at the configuration used, it's at /usr/local/etc/hhvm/php.ini in MacOS.



2. Test: After installing HHVM, change to the directory where your code lives, and start up HHVM:

hhvm -m server -p 8080
-m represents the mode and here indicates that HHVM is running in HTTP server mode.
-p configures the TCP port that HHVM uses to listen to HTTP requests. The default port is 80, the standard HTTP port. However, that port requires root access, so for this example, we will use port 8080.

This will start the server as follows and then you can test on browser.


3. Write a simple "Hello World" program named hello.hack:

<<__entrypoint>> function main(): noreturn{ echo "Hello World in Hack Language! \nThis is Anwar Jamal Faiz"; exit(0); }

Save this hello.hack in the same directory that you ran the hhvm command from above. Then, load http://localhost:8080/hello.hack in your browser and verify you see "Hello World!" appear.


See in browser:
You may also write the program as:
<<__entrypoint>>
function main(): noreturn{
  echo "Hello World in Hack Language! \nThis is Anwar Jamal Faiz";
  exit(0);
}




4.  You can directly run file using hhvm itself.

$ hhvm hello.hack




Note: You can configure HHVM too. Running HHVM automatically at boot as a service (instead of just on the command line as above) unfortunately does require some configuration. See the proxygen documentation for details. However, default settings are okay for any average usecase.


My First look of Hack Language over HHVM by Facebook

Hack is a great language in terms of the advantages it has over PHP. The hack language introduce a level of type safety and related concepts. Undoubtedly, with HHVM it becomes a faster processing language. It is more expressive, more economic, it is faster to write and catch more bugs. The key features as explained by Facebook itself are:

Fast Development
Hack reconciles the fast development cycle of a dynamically typed language with the discipline provided by static typing, while adding many features commonly found in other modern programming languages.


Type Checking
Hack provides instantaneous type checking by incrementally checking your files as you edit them. It typically runs in less than 200 milliseconds, making it easy to integrate into your development workflow without introducing a noticeable delay.


Built for HHVM
Hack is built specifically for HHVM, a high performance 


Type Annotations
Type annotations allow for code to be explicitly typed on parameters, class member variables and return values.


Generics
Generics allow classes and methods to be parameterized (i.e., a type associated when a class is instantiated or a method is called) in the same vein as statically typed languages like C# and Java).

Lambdas
Lambdas succinctly allow definition of first-class functions.


HHVM is an open-source virtual machine designed for executing programs written in Hack. HHVM uses a just-in-time (JIT) compilation approach to achieve superior performance while maintaining amazing development flexibility. HHVM should be used together with a webserver like the built in, easy to deploy Proxygen, or a FastCGI-based webserver on top of nginx or Apache.

Released in 2014, Hack is still not so much popular and I see following as the reasons.
  1. I cannot find any big hosting provider to support HHVM hosting and support for Hack language. You need to maintain your own server. This is one of the big issues that I see with Hack.
  2. Vast majority of php programmers do not build using TDD approach or do lots of whitebox testing. Hence, the benefit of type checking does not attract them much. For many hhvm is just a slightly faster incompatible php, no surprise they aren’t going to invest much there.
  3. Installing Hack on different systems require more technical knowledge. Novice programmers usually lack the skills of core OS. Also, on some systems you need to build HHVM from scratch using the source code repo.
  4. Backwards compatibility with PHP is not 100%. Almost all PHP code works in Hack but there are certain features of PHOP which is not supported in Hack. Hack may have some incompatibility with existing PHP codebases, which increases the cost of switching.
  5. Not everyone needs the amount of scalebilty the companies like Facebook need.
  6. Other bigger eCom and web companies are trying with new RAD tools like React and doing pretty well in their NodeJS world. Webservices are already build using Java or C# and they do not want to come to PHP of Hack.
  7. Hack doesn't allow templating of HTML and Hack code together, which is a popular feature of PHP. You need an engine in between.
  8. Last, but not the least, no one knows how far facebook itself will support the developemnt and Bug fixes in Hack or HHVM.

However, we should also understand that in the world of PHP, the language Hack becomes very useful. It will help developers catch some errors while writing the code itself. Further, the dev tools by Facebook and other contributors are also very exciting. So, I will be experimenting more with the language. Will keep you all posted about new features.

Tuesday, November 19, 2019

How to install Redis and run its instance


First, step first. You can simply install it using homebrew
$ brew install redis

After installation you can check that it creates a configutration file at:
/usr/local/etc/redis.conf

Then, you can verify the install as follows:
$ brew info redis

You can start an instance i.e Start Redis server using the configuration file.
$ redis-server /usr/local/etc/redis.conf

By default, it Runs in standalone mode on Port: 6379


Test if Redis server is running.
$ redis-cli ping
It will replu=y you pong!

To Uninstall Redis and its files.
$ brew uninstall redis


What more do you want. So cheers.
:)

Tuesday, April 17, 2018

Free Website Hosting - Make Free website. Start and launch websites for free

Free Website Hosting - Make Free website
Web hosting


This is a unique way to launch your own website. Click on the given link and start with the world of websites. Free website with zero money. Get domain and hosting space for free. Awesome way to start new journey of entrepreneurship.

  Web hosting


Free cPanel Web Hosting with PHP5/Mysql - no advertising!
Register now: https://www.000webhost.com/708718.html

We can offer you a free web hosting package packed with advanced features for hosting & building professional dynamic websites. We provide secure free web space with all the web hosting tools you could possibly ever need.

Our package includes:
- 1500 MB of Disk Space, 100 GB Bandwidth 
- Host your own domain (https://www.yourdomain.com)
- cPanel Powered Hosting (you will love it)
- Over 500 website templates ready to download
- Easy to use website builder
- Free POP3 Email Box with Webmail access
- FTP and Web based File Manager 
- PHP, MySQL, Perl, CGI, Ruby.
- And many more..

Click here to visit us: https://www.000webhost.com/708718.html