Google Cloud Platform LAMP setup Laravel 5.4 - google-cloud-platform

Looking for help on server problem. I have followed the following steps to set up LAMP on the VM
https://cloud.google.com/community/tutorials/setting-up-lamp
I put my Laravel 5.4 website onto the VM, configure the .env for the following:
APP_URL=website_external_IP
But when I access the website by inserting the website_external_IP on my browser, it returns the following image.
Sorry for being noob of server problems but please let me know what else information should I provide for you to figure out the cause of it. Thank you!
1 EDIT:
In response to John Hanley's suggested site. I further made the following edits on the apache conf:
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/laravel_project.conf
sudo vim /etc/apache2/sites-available/laravel_project.conf
and there vim the laravel_project.conf as followings
NameVirtualHost *:8080
Listen 8080
<VirtualHost *:8080>
ServerAdmin admin#example.com
ServerName laravel.dev
ServerAlias www.laravel.dev
DocumentRoot /home/user/projects/laravel_project/public
<Directory /home/user/projects/laravel_project/public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
LogLevel debug
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
then
sudo vim /etc/hosts
and add the following line:
127.0.0.1 laravel.dev
then disabled the original conf settings and enable for my site:
sudo a2dissite 000-default.conf
sudo a2ensite laravel_project.conf
Without having the full understanding of the new edits procedures, accessing the page with IP returns the following error:
You don't have permission to access / on this server.

Your Apache web server has directory browsing enabled. Also you do not have a default page present (or enabled) therefore you server is serving up the directory listing.
/etc/apache2/apache2.conf
Remove the word Indexes from this part of your configuration:
<Directory /var/www/>
Options Indexes FollowSymLinks
...
</Directory>

Related

WampServer 3 Online Forbidden

When I try to access my local website from another device (connected with LAN), I get Forbidden error.
I tried to edit Apache's httpd.conf (as what google told me), repair vcredist packages, uninstalling wamp completely and installing (re-downloaded the latest version), deactivating Antivirus software (I am using BitDefender btw).
About 1 month ago, I was using windows 7 and wamp was working perfectly. After I upgraded to windows 10, I cleaned my pc and installed wamp. At first, I didn't need it's Online mode, but right now, I need it. So, I am open to all new ideas.
Note
-I can reach localhost with my pc (with LAN IP, Router IP and http://localhost)
-I am using Windows 10 Professional x64
-I looked at all of the similar questions and relevant pages on Google, and none of them worked for me
About 3 weeks ago, I started using a new router. Can it cause this problem? or maybe I couldn't install drivers correctly?
don't edit http.config instead edit httpd-vhosts.config
<VirtualHost *:80>
ServerName localhost
DocumentRoot c:/wamp/www
<Directory "c:/wamp/www/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
change Require local to Require all granted. when it is Require local it can be accessed only through localhost request from other hosts are denied. Finally it looks like below
<VirtualHost *:80>
ServerName localhost
DocumentRoot c:/wamp/www
<Directory "c:/wamp/www/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

WAMP icon colors

I'm running Wamp 3.0.0 64bit on Windows 10. In past versions the icon was either red, orange or green depending on status. Now the green version has a red dot in it, and the background color is pale yellow rather than clear as it is on the red and orange versions.
Does anyone know the significance of the background color or the red dot?
It seems I gave you some wrong advice above in my comments.
The icon you speak about is in fact a new Icon I had forgotten about.
This image indicates that you have set WAMPServer Online i.e. you have used the Online/Offline menu and set Apache to be Online.
NOTE: It is not necessary to have set Apache Online for normal development activity. Online only means that Apache can be accessed by any IP Address in the universe.
In other words when Online the httpd.conf file contains this parameter in the
<Directory "D:/wamp/www/">
section on httpd.conf
# onlineoffline tag - don't remove
Require all granted
when normally it has
# onlineoffline tag - don't remove
Require local
Unless you are actually trying to access your site from the internet it is not required to be Online.
Additional info after clarification
Ok, so if you are just trying to open up to connections from your local network then you have to do this. WAMPServer3 added the use of localhost as a Virtual Host by default. So now you should leave the httpd.conf files as
# onlineoffline tag - don't remove
Require local
Now edit \wamp\bin\apache\apache{version}\conf\extra\httpd-vhost.conf and add your access requirements to that like this
The default is this
<VirtualHost *:80>
ServerName localhost
DocumentRoot c:/wamp/www
<Directory "c:/wamp/www/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
So just add requirements like this
<VirtualHost *:80>
ServerName localhost
DocumentRoot c:/wamp/www
<Directory "c:/wamp/www/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require local
Require ip 192.168.0.1
Require ip 192.168.0.2
</Directory>
</VirtualHost>
Or add this for any ip in your local network
<VirtualHost *:80>
ServerName localhost
DocumentRoot c:/wamp/www
<Directory "c:/wamp/www/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require local
Require ip 192.168.0
</Directory>
</VirtualHost>

Deploying Django on Apache and WSGI

Although I have found a bunch of tech support to deploy Django over Apache using WSGI but infact they all have confused me unfortunately, and I couldn't get the Django running. I hope this to be real easy job but being a new comer I am facing difficulties.
I have two Django projects namely website1 and website2 inside my /home/zia/Documents/Codes/Django/website1 and ..../website2 dir, respectively. The folder containing settings.py file is root/ inside the /website1 and /website2 dir.
Apache, mod_wsgi everything is installed as required. How to edit apache2.conf and wsgi.py file to keep these two projects running over port 8080 and 8081?
I am struggling with this issue for past few days and have tried all the following websites.
link1,link2,link3,link4
UPDATE1:
I have followed the following approach right from the beginning to make things going well but found myself in some new issues. Kindly guide me where I am wrong.
Installing mod-wsgi and apache2:
sudo apt-get install libapache2-mod-wsgi && sudo apt-get update && sudo apt-get install apache2
Edit the apache2 port to 8083, instead of 80 by altering file "/etc/apache2/ports.conf": Listen 8083
Add the following line into "/etc/hosts" file: 160.75.133.175 160.75.133.175
Edit the following code in the "/etc/apache2/apache2.conf" file:
<Directory />
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
Create a file inside "/etc/apache2/sites-available/" dir with name "sql_api.conf":
<VirtualHost *:8083>
ServerAdmin zia#gmail.com
ServerName 160.75.133.175
ServerAlias http://160.75.133.175
<Directory /home/zia/Documents/Codes/Django/sql_api/ >
Order deny,allow
Allow from all
</Directory>
WSGIScriptAlias / /home/zia/Documents/Codes/Django/sql_api/root/wsgi.py
WSGIDaemonProcess 160.75.133.175 user=www-data group=www-data threads=25 python-path=/home/zia/Documents/Codes/Django/sql_api/root/:/usr
WSGIProcessGroup 160.75.133.175
ErrorLog /home/zia/Documents/Codes/Django/sql_api/root/error.log
</VirtualHost>
Run the following commands being in "/etc/apache2/sites-available" dir: sudo a2enmod wsgi && sudo a2ensite sql_api.conf && sudo service apache2 restart
Open http://160.75.133.175:8083/ but getting the following error:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at zia#gmail.com to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Apache/2.4.7 (Ubuntu) Server at 160.75.133.175 Port 8082
NOTE: When I am making a Django project in /var/www/ dir and then doing the same approach then working just fine! I think because I am trying to access /home/zia/.... dir, there is this issue. Anyways, this is just a guess. I would appreciate your help.
Thanks to everyone. Finally found a working procedure. Follow the following steps in order:
Installing mod-wsgi and apache2:
sudo apt-get install libapache2-mod-wsgi && sudo apt-get update && sudo apt-get install apache2
Edit the apache2 port to 8083, instead of 80 by altering file "/etc/apache2/ports.conf": Listen 8083
Add the following line into "/etc/hosts" file: 160.75.133.175 160.75.133.175
Edit the following code in the "/etc/apache2/apache2.conf" file:
<Directory />
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
Create a file inside "/etc/apache2/sites-available/" dir with name "sql_api.conf" (make as many .conf files you want with different names, each serving different website):
<VirtualHost *:8083>
ServerAdmin zia#gmail.com
ServerName 160.75.133.175
ServerAlias http://160.75.133.175
<Directory /home/zia/Documents/Codes/Django/sql_api/ >
Order deny,allow
Allow from all
</Directory>
WSGIScriptAlias / /home/zia/Documents/Codes/Django/sql_api/root/wsgi.py
WSGIDaemonProcess 160.75.133.175 user=www-data group=www-data threads=25 python-path=/home/zia/Documents/Codes/Django/sql_api/root/:/usr
WSGIProcessGroup 160.75.133.175
ErrorLog /home/zia/Documents/Codes/Django/sql_api/root/error.log
</VirtualHost>
Add the following lines in the wsgi.py file inside "/home/zia/Documents/Codes/Django/sql_api/root/": sys.path.append('/home/zia/Documents/Codes/Django/sql_api/root')
sys.path.append('/home/zia/Documents/Codes/Django/sql_api')
Run the following commands being in "/etc/apache2/sites-available" dir: sudo a2enmod wsgi && sudo a2ensite sql_api.conf && sudo service apache2 restart
Open http://160.75.133.175:8083/
you should probably just start over if you made a bunch of changes to your Apache config. I'm most familiar with setups under Ubuntu.
What you need to look to do is setup both sites under apache as a virtual host. After installing apache there is a folder called sites-available and sites-enabled they should contain the virtual host files with the names of your website projects. Each virtual host will point to whereever your .wsgi file is located. these virtual hosts typically listen under the same port number (as Daniel mentioned above) but serve whichever app is requested based on the domain name. noobmovies.com google.com ect...
how to setup a virtual host with apache is pretty well explained here. this assumes you're using ubuntu though.
https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts
your virtual host (the file should be named after your domain exp... noobmovies.com) and will look something like this...
**<VirtualHost *:8080>
ServerAdmin your_admin_email#gmail.com
ServerName www.yourdomain.com
ServerAlias yourdomain.com
<Directory /home/path/your/project/ >
Order deny,allow
Allow from all
</Directory>
WSGIScriptAlias / /home/path/your/project/app/wsgi.py
WSGIDaemonProcess yourdomain.com user=www-data group=www-data threads=25 python-path=/path/to/your/project/app/:/path/to/python/virtual/host/site-packages
WSGIProcessGroup yourdomain.com
ErrorLog /path/to/your/app/error.log
</VirtualHost>**
keep in mind the WSGIDaemonProcess is only if you're running your app using virtualenv (which you should). this tells apache where python is that should be used to read the wsgi app/run django app.
So if you're using ubuntu or linux you may just want to uninstall apache and reinstall then just follow the digital ocean instructions to get setup.

you don't have permission to access [custom alias] on this server

can anyone help with a following issue:
I am using wamp to run projects in my chrome browser.
after adding a newAlias which points to my project directory c:/dev/myProject
I am getting Forbidden message: you don't have permission to access /newAlias on this server.
I can access default Aliases such as phpmyadmin, webgrind...
but i cannot access my own.
I am using WampServer Version 2.5 64bit on Win 8.1 64bit located in c:/wamp.
I tried basic stuff from the net but with no luck.
Any suggestions?
Edit: content of newAlias:
Alias /bs1/ "c:/_DEV_/git/NewProject/www/"
<Directory "c:/_DEV_/git/NewProject/www/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
Allow from all
</Directory>
Dont change that section of your httpd.conf. Those few lines control access to the root folder of the drive that Apache is installed on. So you just gave full access to anybody with a handy hack.
The process of securing the access via Apache is to deny all access to everything from the root folder and below, and then selectively allow access for specific sites to specific areas/folders of the drive.
A better solution would be to change httpd.conf back to how it was and make the change in your Alias definition. Like this :-
Alias /bs1 "c:/_DEV_/git/NewProject/www/"
<Directory "c:/_DEV_/git/NewProject/www/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Require local <-- to develop on this PC
Require ip 192.168.1 <-- to access the server from another PC on your network
Require all granted <-- to allow the world to see the beauty of your site
</Directory>
It is actually a better idea to use Virtual Hosts to control each site and not Alias's.
Here is a why and Howto :- WAMPServer 2.5 The Homepage, Your Projects Menu and the need for Virtual Hosts
I've updated WAMP from 2.2.22 to 2.4.9 and found that new aliases didn't work (same error message as yours).
Checking the default aliases like phpmyadmin, I've found this:
Alias /phpmyadmin "c:/wamp/apps/phpmyadmin4.1.14/"
# to give access to phpmyadmin from outside
# replace the lines
#
# Require local
#
# by
#
# Require all granted
#
<Directory "c:/wamp/apps/phpmyadmin4.1.14/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
<IfDefine APACHE24>
Require local
</IfDefine>
<IfDefine !APACHE24>
Order Deny,Allow
Deny from all
Allow from localhost ::1 127.0.0.1
</IfDefine>
php_admin_value upload_max_filesize 128M
php_admin_value post_max_size 128M
php_admin_value max_execution_time 360
php_admin_value max_input_time 360
</Directory>
If you see the contents of the file you'll notice the <IfDefine APACHE24> and <IfDefine !APACHE24> conditionals. So I've changed my alias .conf file from:
Alias /svn "c:/work/website-svn/"
<Directory "c:/work/website-svn/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
Allow from all
</Directory>
to:
Alias /svn "c:/work/website-svn/"
<Directory "c:/work/website-svn/">
Options Indexes FollowSymLinks MultiViews
Require local
</Directory>
That solved my problem, I hope it solves yours.
I am no expert on this but the answer above seemed like I was granting access to my entire computer...So tried modifying the above answer to only giving access to where my alias folder is...
So instead...Go to the httpd.conf file...and do a search for...
<Directory />
AllowOverride none
Require all denied
</Directory>
and below that add the following
<Directory "c:/path-to-your-alias-folder...">
AllowOverride none
Require all granted
</Directory>
This worked to me and I think it might be a bit safer...Again I am no expert here...Just trying to make it work...
for allow permission for your server & wamp you require 3 steps please ensure these 3 things after that you can access your site from other network with ip address e.g http://192.168.1.1/yoursitefoldername
(192.168.1.1 is you computer or vps ip address "yoursitefoldername" is folder name of your site which should be in your wamp->www folder)
1.
first of all
Port 80 and 443 must be allow for both TCP and UDP packets. To do this, create 2 inbound rules for TPC and UDP on Windows Firewall for port 80 and 443.
(or you can disable your whole firewall for testing but permanent solution if allow inbound rule)
2.
If you are using WAMPServer 3 See bottom of answer
For WAMPServer versions <= 2.5
You need to change the security setting on Apache to allow access from anywhere else, so edit your httpd.conf file.
Change this section from :
# onlineoffline tag - don't remove
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from ::1
Allow from localhost
To :
# onlineoffline tag - don't remove
Order Allow,Deny
Allow from all
if "Allow from all" line not work for your then use "Require all granted"
then it will work for you.
WAMPServer 3 has a different method
In version 3 and > of WAMPServer there is a Virtual Hosts pre defined for localhost so dont amend the httpd.conf file at all, leave it as you found it.
Using the menus, edit the httpd-vhosts.conf file.
It should look like this :
<VirtualHost *:80>
ServerName localhost
DocumentRoot D:/wamp/www
<Directory "D:/wamp/www/">
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
Amend it to
<VirtualHost *:80>
ServerName localhost
DocumentRoot D:/wamp/www
<Directory "D:/wamp/www/">
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Hopefully you will have created a Virtual Host for your project and not be using the wamp\www folder for your site. In that case leave the localhost definition alone and make the change only to your Virtual Host.
3.
Dont forget to restart All Services of Wamp or Apache after making this change
I found a solution which worked for me.
In httpd.conf i changed:
<Directory />
AllowOverride none
Require all denied
</Directory>
to
<Directory />
AllowOverride none
Require all granted
</Directory>
Which solved the issue and allowed me to access my custom aliases.
I would suggest that you consider setting up virtual hosts instead. It takes a few more minutes, but it's more bulletproof. RiggsFolly's answer to a similar question is excellent in its detail, rigor, and utility:
Project Links do not work on Wamp Server

how to config apache2 and fastCGI to run my c++ application

I have written a program with c++ and compiled it with gcc ( like the sample in the fastcgi.com) but i dont know how to run it on localhost.
everywhere i searched , i found the php configuration for mod_fcgi which wont work
for c++.
does any body configured apache and mod_fcgi to run a c++ web application ???
mod_fcgi? I have found only mod_fastcgi and mod_fcgid. Apache configuration looks pretty simple for both. Lets compile FastCGI example and create a minimalistic Apache instance to serve it:
Install libfcgi-dev
Create temporary directory somewhere and compile the example from https://opensource.apple.com/source/FastCGI/FastCGI-4/fcgi/doc/fcgi-devel-kit.htm#S3.1
When you simply run it, it already has some output:
$ ./tiny-cgi
Content-type: text/html
<title>FastCGI Hello!</title><h1>FastCGI Hello!</h1>Request number 1 running on host <i>(null)</i>
Install apache2 and libapache2-mod-fcgid; create configuration file apache.conf:
User www-data
Listen 8080
PidFile apache.pid
DocumentRoot .
LoadModule fcgid_module /usr/lib/apache2/modules/mod_fcgid.so
SetHandler fcgid-script
Options +ExecCGI
ErrorLog error.log
User www-data is important, because it has access to /var/lib/apache2/fcgid/sock/, which is pretty important for fcgid (I am running on Debian, maybe somewhere else it will be different). Having DocumentRoot in the same directory with the rest is not very good, but this is just a quick example.
Run sudo /usr/sbin/apache2 -d . -f apache.conf -X
That -X is for debug mode, when the server does not daemonize (does not detach), which is pretty handy for such playing.
Go to http://localhost:8080/tiny-cgi, where you will see output from your FastCGI program. If not, see error.log.
Stop Apache, install libapache2-mod-fastcgi, replace the two lines in configuration with:
LoadModule fastcgi_module /usr/lib/apache2/modules/mod_fastcgi.so
SetHandler fastcgi-script
Visit http://localhost:8080/tiny-cgi again.
Here's an example from my dev PC at home. It's a C++ web service running on 127.0.0.1:90 that I'm testing/debugging. The "FcgidIOTimeout" is set to 3600 so mod_fcgid won't timeout waiting for a response while I step through the fcgi process with gdb (the debugger). If it times out while debugging, the fcgi app will be killed. A little further down there is a ScriptAlias and a Directory telling Apache where the cgi folder is..."/home/dgnorton/prj/dfi/build/src/"...which is the build output folder for my project. You'll also need to check the permissions of that directory.
I only use this on my home system for debugging. Read the Apache and mod_fcgid docs before using any of this in the wild.
Listen 90
NameVirtualHost 127.0.0.1:90
<VirtualHost 127.0.0.1:90>
ServerName www.example1.com
DocumentRoot /var/www/dfi
<IfModule fcgid_module>
FcgidIOTimeout 3600
</IfModule>
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi/ /home/dgnorton/prj/dfi/build/src/
<Directory "/home/dgnorton/src/dfi/build/src">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>