Local Development Environments for Mac - apache

Ok guys.
Here's my issue. I love Valet, I think it's spectacular. All of my new and recent projects are built on Laravel in some way, most of them are Laravel Spark.
However, my old legacy applications are not built on any framework at all, and all heavily rely on the .htaccess file.
Now, as we know, Valet doesn't use apache in the same way, so cannot run my old legacy applications that I still often need to work on.
I use to run MAMP PRO happily, but this doesn't run side by side with any other environment solutions and just will not work with Laravel at all. It's just not built for it - I don't want to waste time making it work, when it's less than ideal in the first place.
So what I need is a suggestion for a modern local development environment that works great with Laravel applications, but also happily runs all of my old legacy applications. Preferably looking for something that's command based on the Mac.
Any suggestions. I'm really struggling to find something I like. I love the autonomous concept of Valet and would love something like that, or just the ability to run all of my legacy applications with Valet without having to create driver files for each app or anything like that.
Thanks in advance! Love you guys.

In my mac I've only mysql server and php installed.
So when I want to develop/test an app I use:
1) for laravel: php artisan serve
2) for non-laravel: php -S 127.0.0.1:8080 -t ./
3) sometimes virtual box with linux os
4) mostly I use my digital ocean droplet for dev purposes
5) docker (:

One way of doing it would be to use vagrant. You could use Laravel Homestead and replace Nginx with Apache as webserver which would allow you to run both laravel and legacy apps, or use a tool like PuPHPet to build your own box.
To replace Nginx with Apache in Homestead you should follow these steps:
In terminal run:
cd ~/Homestead
vagrant ssh
Next you'll have to stop Nginx, disable service autoload and install apache:
sudo service nginx stop
sudo mv /etc/init/nginx.conf ~/nginx.conf.bak
sudo apt-get update
sudo apt-get install apache2
sudp service apache2 start
Now you'll have to create virtual hosts for your apps in /etc/apache2/sites-available
You could copy the default configuration:
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example.com.conf
sudo nano /etc/apache2/sites-available/example.com.conf
Configure your vhost to something like this:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Save the file and enable the vhost by running sudo a2ensite /etc/apache2/sites-available/example.com.conf
And finally restart apache sudo service apache2 restart
You can find more information on how to setup Apache on Ubuntu here

Related

Set correct user/group to Apache server / projects

I cannot set the web projects permissions correctly on webserver Ubuntu 20.04, Nginx, Apache. It is my first web hosting administration, so forgive me if I do not use the terms correctly.
I have a sudo user 'foo'. I manage the server through it.
I use another, not sudo user 'boo' for managing the web projects (nodjs, apache, ....)
The web projects are located at: /home/boo/apps/blog, /home/boo/apps/forum, ...
I tried different tutorials on setting sudo chown -R www-data:www-data blog and readjusting the individual projects, but it doesn't look good to me.
On my old hosting, the web projects are owned by 'boo'
drwxr-xr-x 7 boo boo 4096 Sep 16 05:59 blog
Is it mean that the apache server is set to work with 'boo'? How to set it to work like that. It is the best case according to me because 'boo' can edit the projects without sudo.
I tried to set it in /etc/apache2/envvars without success.
export APACHE_RUN_USER=boo
export APACHE_RUN_GROUP=boo
I tried to add 'boo' to the 'www-data' group: sudo usermod -a -G www-data boo. Is it correct?
We can set individual group / user for each virtual host with teh help of The Apache 2 ITK MPM http://mpm-itk.sesse.net/
<VirtualHost 127.0.0.1:666>
ServerName example.com
<IfModule mpm_itk_module>
AssignUserId boo boo
</IfModule>
</VirtualHost>

How do I deploy a golang app with Apache installed on Ubuntu 16.04 on digitalocean?

I am learning Go at the moment and I have built really simple webapps following some tutorials with the net/http package. I have created a simple wishlist, where I add an item and than it does to a simple table of things I want, pretty simple.
Now I want to deploy this app to my Digital Ocean droplet, but I just don't know how. I have some php websites with different domains already with Apache behind it.
I am really a begginer on this "servers configuration" thing, usually with php is pretty easy on webhosts and I didn't need this much experience. Can you point me on the right direction to make my Go app available at a domain I own, without the ports bit? Preferably with Apache.
Thanks :)
Note: Almost everything in this answer needs to be customized to your specific circumstances. This is written with the assumption that your Go app is called "myapp" and you have made it listen at port 8001 (and many others).
You should make a systemd unit file to make your app start up automatically at boot. Put the following in /etc/systemd/system/myapp.service (adapt to your needs):
[Unit]
Description=MyApp webserver
[Service]
ExecStart=/www/myapp/bin/webserver
WorkingDirectory=/www/myapp
EnvironmentFile=-/www/myapp/config/myapp.env
StandardOutput=journal
StandardError=inherit
SyslogIdentifier=myapp
User=www-data
Group=www-data
Type=simple
Restart=on-failure
[Install]
WantedBy=multi-user.target
For documentation of these settings see: man systemd.unit, man systemd.service and man systemd.exec
Start it:
systemctl start myapp
Check that it is ok:
systemctl status myapp
Enable automatic startup:
systemctl enable myapp
Then it is time to configure Apache virtualhost for your app. Put the following in /etc/apache2/sites-available/myapp.conf:
<VirtualHost *:80>
ServerName myapp.example.com
ServerAdmin webmaster#example.com
DocumentRoot /www/myapp/public
ErrorLog ${APACHE_LOG_DIR}/myapp-error.log
CustomLog ${APACHE_LOG_DIR}/myapp-access.log combined
ProxyPass "/" "http://localhost:8001/"
</VirtualHost>
Documentation of the proxy related settings: https://httpd.apache.org/docs/2.4/mod/mod_proxy.html
Enable the configuration:
a2ensite myapp
Make sure you did not make mistake in Apache configuration:
apachectl configtest
In case the proxy modules are not previously enabled you will get an error at this point. In that case enable the proxy modules and try again:
a2enmod proxy
a2enmod proxy_http
apachectl configtest
Reload Apache configuration:
systemctl reload apache2
Remember to make the name myapp.example.com available in DNS.
That's it!
EDIT: Added pointers to documentation and instructions for enabling Apache modules if needed. Use apachectl for config test.

I've wrongly removed /etc/apache2

I'm wondering whether it's possible to install apache2 from scratch, I tried to install it and many times I was informed that a configuration file was removed, and everytime I chose to install the package responsible version. When starting apache service I have this apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName and the localhost url shows Page Web inaccessible.
How can I fix this?
Thanks in advance.
Just add to apache2.conf
Servername localhost
into last line.
(PATH)
sudo nano /etc/apache2/apache2.conf

apache2 same with httpd

I've installed apache2 using apt-get into /etc/apache2.
Later I manually compiled and installed httpd2.4 into /usr/local/apache2/.
I've seen post like: My httpd.conf is empty which says that basically apache2.conf is in current use while httpd.conf is preserved for historic reason.
And before installing httpd, the apache2 works fine.
So my question:
Are Apache2 and httpd the same thing?

To deploy Play! 2 application on a path with its name at Apache or Tomcat

How can I have my application made in Play! 2.0.4 (latest "production ready" package) exported to run on either Apache 2.2 or Tomcat 6.0.18 at a path like e.g. tomcatserver:8080/myApp/?
The application always runs at / under localhost:9000 on either Dev or Prod environment.
I tried the war command but it seems unavailable for this version.
Tried stage command, but it failed since it needs chmod and I'm using Windows XP (although my Apache is in a FreeBSD machine and Tomcat is in a Linux one).
Then I tried dist command. It made the myApp-1.0-SNAPSHOT.zip, but... I can't use it anywhere, its contents are structured in an unfamiliar way to the web servers.
Please, can someone share a light here on how to get it deployed on one of those?
You should take a look at the HTTP Fronted documentation, especially the Apache integration.
It should be something like:
LoadModule proxy_module modules/mod_proxy.so
…
<VirtualHost *:80>
ProxyPreserveHost On
ServerName www.loadbalancedapp.com
ProxyPass /excluded !
ProxyPass /myApp http://127.0.0.1:9000/
ProxyPassReverse /myApp http://127.0.0.1:9000/
</VirtualHost>
You'll need to deploy the Play application in standalone mode, ie without any Java EE container (Tomcat & co). Play 2 core does not provide a way to generate a .war file.
If you want to absolutely use a Java EE container, take a look at the play2-war-plugin.