i have basic Vagrant box with following configuration
Static IP: 192.168.55.155
Ubuntu 14.04
PHP 5.5.16
Apache 2.4.10
Port forward: 8081 on host to 80 on the guest system
My host system is "Windows 7" and the "hosts" file in Windows 7 contain following line "192.168.55.155 phpinfo".
I set up a basic vhost like this.
<VirtualHost *:80>
ServerName phpinfo
DocumentRoot "/var/www/info"
<Directory "/var/www/info">
</Directory>
</VirtualHost>
I created this vhost file on my guest system "/etc/apache/sites-availble" and create a symbolic link in "/etc/apache2/sites-enabled" to my new file. After creating this vhost i restart my apache server "/etc/init.d/apache2 restart".
If i write in my browser on my host machine the url "phpinfo", the content of my php file do not parse from the browser. It display following:
<?php
echo "hello world";
?>
But if i write as url "localhost:8081" the port forwarding to 80 on my guest systems work and the default host content from "/var/www/default" like "hello world" parsed from my browser.
Now i do not know the problem, because the guest system parse php on the default vhost, but not for my custom vhost.
Can anybody help me?
You need to do this.
sudo apt-get install libapache2-mod-php5
sudo /etc/init.d/apache2 restart
Related
I want to run my laravel 9 app without 'php artisan serve'
i know how to do it in older version but laravel 9 don't have the server.php file in root directory
so how to do it now
and i don't want to use 'localhost/project/public/' url
I am currently on
laravel: version 9.19
OS: Ubuntu 22.04.1 LTS
php: 8.1.2
Server: Apache/2.4.52 (Ubuntu)
First step is to add your project to list of virtual hosts in XAMPP that is located in \apache\conf\extra > httpd-vhosts.conf
It can be something like:
<VirtualHost *:80>
DocumentRoot "{pathToProject}\public"
ServerName projectname.localhost
<Directory "{pathToProject}">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Second step is to add host in your hosts file that is located in same disk as your OS then \Windows\System32\drivers\etc > hosts
It should probably be something like
127.0.0.1 projectname.localhost
If you've changed default address settings, you will have to change address in hosts as well.
Restart XAMPP and you're good to go.
I have a project developed on symfony 2.4 that run on correctly on my main computer using WAMP.
However, I need to move it to my laptop MacOS Mojave (v 10.14.5). To do that I install MAMP and try to set the virtual host.
Here the steps I did:
1. Installed MAMP 5.4 and set the port as default:
Apache port : 80
MySQL Port: 3306
Updated the hosts file located at /private/etc/by adding the following code:
127.0.0.1 mysite.fr
::1 mysite.fr
Updated the file httpd.conf located at /MAMP/conf/apache by removing the # before Virtual hosts line:
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
4.Updated the file httpd-vhosts.conflocated at /MAMP/conf/apache/extra/ by adding the following code:
<VirtualHost *:80>
DocumentRoot "/Applications/MAMP/htdocs/mysiteSymfony2.4/web"
ServerName mysite.fr
</VirtualHost>
Restart MAMP
Open my browser and move to the url mysite.fr
My Virtualhost setting on my Mac and my Windows are exactly identical. However, it's works on my Windows only, here the error message I get on my Mac at mysite.fr
Not Found
The requested URL / was not found on this server.
First time got a new MBP 2016. Trying to setup PHP,MySQL & Apache. Started Apache by using command
sudo apachectl restart
Then installed PHP by
brew install php71 --with-httpd24
Also did following changes...
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
DirectoryIndex index.html index.php
SetHandler application/x-httpd-php
ServerName dev-server
Also, updated the same in host file /etc/hosts/
But, whenever I'm trying to Stop/Restart my apache by using command sudo apachectl restart or sudo apachectl stop I'm getting following errors.
AH00557: httpd: apr_sockaddr_info_get() failed for Sureshs-MacBook-Pro.local
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
httpd not running, trying to start
But, strangely when I'm executing any PHP file from my browser http://localhost/index.php it's working fine. As in my index.php file I'm using code <?php phpinfo(); ?> It's showing PHP version PHP Version 7.1.4 loaded.
Tried a lot but no clude what's going wrong at where.
---UPDATE---
After updating 127.0.0.1 Sureshs-MacBook-Pro.local in my /private/etc/hosts file, one error solved. Now I'm getting only one below error.
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using Sureshs-MacBook-Pro.local. Set the 'ServerName' directive globally to suppress this message
Finally, I solved this by updating ServerName localhost:8080 on file /usr/local/etc/apache2/2.4/httpd.conf. It was a differnt httpd.conf file which I didn't knew about it.
Also, for Apache start/restart/stop following command sudo /usr/sbin/apachectl start works for me.
As per message:
Set the 'ServerName' directive globally to suppress this message.
You need to identify httpd.conf Apache configuration file by:
apachectl -t -D DUMP_INCLUDES
then edit it and uncomment the line with ServerName (make sure it has the valid server name). E.g.
ServerName localhost
open file httpd.conf
vi /etc/httpd/conf/httpd.conf
add to first line
ServerName localhost
systemctl restart httpd
I resolved this issue changing the port address in the httpd.conf file in windows.
This problem arises due to the port already listening, which we use in the conf file.
To view the port listening, use the command "netview /a"
if the port used in the conf file already listening, change to different one(e.g, 8080)
set servername to "localhost" or 127.0.0.1
Now start the apache server "httpd.exe -k start"
it will work fine.
On macOS Catalina...
Edit the Apache config file
sudo vi /etc/apache2/httpd.conf
Find the ServerName entry by typing a / followed by ServerName and hit enter
Press n to go to the next occurrence until you are on #ServerName www.example.com:80 (keep pressing n if you go past it)
Add a newline by typing an o
Type the following: ServerName localhost
Save and exit by typing !wq then hit enter (or type ZZ which is capital Z twice)
Restart Apache
sudo apachectl restart
I am setting up a virtual host on my linux machine, I followed all the steps and guides, but I do not go to my site for some reason. I have LAMP installed and apache, mysql, php is all working. I have a database setup on phpmyadmin and imported a database, but for some reason I cannot get my IP directed to my site! Its literally the last step I need so I can start working on my project.
127.0.0.1 localhost
127.0.0.1 cbirc.com
<VirtualHost *:80>
ServerAdmin admin#cbirc.com
ServerName cbirc.com
ServerAlias www.cbirc.com
DocumentRoot /var/www/cbirc
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
What am I missing here???
You have to check bunch of stuff:
Is apache running
sudo service apache2 status
Afterwards, test it with
netstat -na | grep 80
ping cbirc.com
Was website enabled by issuing following command?
sudo a2ensite cbirc
file /etc/apache2/sites-enabled/cbirc.conf (or some similar name it that folder)
Does www-data group and user (apache) has read-execute access on web content folder
ln -l /var/www/cbirc
If not, change it like this
sudo chown -R www-data:www-data /var/www/cbirc
sudo chmod -R ug+rx /var/www/cbirc
Before issuing request in browser (to eliminate browser cache or security issues), do it with curl or wget
wget http://cbirc.com/
curl -v http://cbirc.com/
And look for errors in logifile
tail -f /var/log/apache2/error.log
Please refer to my debian cheetsheat for further help
Firstly, run 'dig' or 'host' on cbirc.com
Although it is in your /etc/hosts , resolv.conf may prioritise nameservers above your hosts file.
If it is pointing to your localhost, then check the you have enabled the site - a2ensite [name of vhost conf file without the .conf extention] - check by looking in /etc/apache2/sites-enabled for a symbolic link to the sites-available directory.
I'm following through the getting started skeleton app tutorial on the Zend homepage:
http://framework.zend.com/manual/2.2/en/user-guide/skeleton-application.html
I've got as far as being able to enter into the browser address bar "zf2-tutorial.localhost/" and my Zend welcome page should appear. It doesn't, the apache web folder (/var/www) directory appears instead. If I enter "http://zf2-tutorial.localhost/1234" to test whether the Zend 404 page appears, it doesn't. The default apache Not Found page appears.
I created my app by running in terminal:
php composer.phar create-project --repository-url="http://packages.zendframework.com" zendframework/skeleton-application:dev-master /var/www/zf2-tutorial
.. this created all the files in the desired folder (/var/www/zf2-tutorial).
I then created the file /etc/apache2/sites-enabled/zf2-tutorial with the following:
<VirtualHost *:80>
ServerName zf2-tutorial.localhost
DocumentRoot /var/www/zf2-tutorial/public
SetEnv APPLICATION_ENV "development"
<Directory /var/www/zf2-tutorial/public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I updated my /etc/hosts file with:
127.0.0.1 zf2-tutorial.localhost localhost
I restarted apache
sudo service apache2 restart
.. and by this point I should be able to see the Zend welcome page so I can proceed with the rest of the tutorial but nothing.
By the way, I'm using Ubuntu 12.04, Apache/2.4.9 (Ubuntu) and PHP 5.5.14.
Is there anything obvious that I've missed out? I've got a feeling that it has something to do with the mod_rewrites but I'm a little confused which I should be updated and how. Any help would be much appreciated.
Add the
<VirtualHost *:80>
[... same code ....]
</VirtualHost>
in the /etc/apache2/sites-enabled/000-default file and restart the apache2
Update -
If it still doesn't work then try the below command and check -
sudo a2enmod rewrite
sudo service apache2 restart
This will enable the rewrite module if not already is.
After entering the URL in the browser, if the required page is not displayed then check the apache error log file located at /var/log/apache2/error.log
By this, you could get some idea as where its going wrong.
Your problem was in config file name. In directory sites-enabled files should have .conf in the end of name.
Good: zf2-tutorial.conf
Bad: zf2-tutorial