How to open HTML file in browser in centos? - php

I am accessing one system with ipaddress 192.168.1.41 as a server. In this system has one HTML file which is located at path opt/openerp/apache/htdocs/index.html. Now how can I access the html file in my local system browser ?
I tried with 192.168.1.41/index.html but it does not work.
Can anyone help me how to access the file in my local browser

Put index.html in /var/www/ and try opening with the browser 192.168.1.41/index.html. First check apache2 is installed
Steps -
1. sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/site_name
2. Change the default document root and directory directive in the new file to new location.
3. sudo a2dissite default && sudo a2ensite mysite [deactivate old site and activate new site]
4. sudo service apache2 restart

Related

php application fails to detect the right temp directory

In my Laravel 9 application running on AWS EC2, I'm trying to upload a file.
The action fails with this message: File could not be uploaded: missing temporary directory.
Inside my loaded php.ini, I have it set as upload_tmp_dir = /tmp
But when I do a phpinfo, I see the value for upload_tmp_dir is empty. Looks like whatever value I add for upload_tmp_dir is not read/recognized by php.
I used echo sys_get_temp_dir(); to get the path that the app is using, and it returns as:
/var/www/html/tmp
What's the reason the app is failing to detect the right path to the tmp directory?
If it matters, here are also the directory permissions:
/tmp is owned by root/root and is drwxrwxrwt+
everything under /var/www/html (where the app is) is owned by ec2-user/apache
Here is how I resolved this issue:
Edit /usr/lib/systemd/system/php-fpm.service. Set PrivateTmp=false
Edit /usr/lib/systemd/system/httpd.service. Set PrivateTmp=false
Reload parameters: sudo systemctl daemon-reload
Restart service: sudo systemctl restart php-fpm and sudo systemctl restart httpd

"localhost" always shows "welcome to Nginx" Ubuntu?

I am running Ubuntu 16. I am fairly new to web design but I have set up a LAMP server on my Ubuntu machine and installed WordPress site. I wanted to try to mess around with PHP so I tried to install myphp.
I managed to do this and I realized that I had to install nginx also.
I did this, but my local host always diverts to a message "welcome to Nginx"
I tried to edit the configuration files but could not get it to work?
Is there a guide for installing Nginx and myphp to see phpMyAdmin, after you have already set up a WordPress site?
Like I said I am running Ubuntu 16.04.
You may need to delete the index.html file from the web root. The index.php file should remain.
On Ubuntu+nginx go to html directory using following command
cd /var/www/html/
then find out following index.nginx-debian.html and delete it or edit it as you want
To edit these file open into you editor or use Ubuntu default editor nano.
sudo nano /var/www/html/index.nginx-debian.html
To delete these file run following command.
sudo rm -rf /var/www/html/index.nginx-debian.html
these is the defautl nginx welcome page that why it appear after install, for more information check nginx default configuration file using following command.
sudo nano /etc/nginx/sites-available/default
Thanks

Mac OS X Apache install not working 403 Forbidden

I'm trying to setup an apache server with php and mysql on my Mac OS X.
For this I'm using this tutorial.
After folowing the directions I still get a 403 forbidden error when I load the page.
These are the steps that I've done:
apachectl start
Edited /etc/apache2/httpd.conf (here is my full config file) I uncommented the line LoadModule php5_module libexec/apache2/libphp5.so and the line Include /private/etc/apache2/extra/httpd-vhosts.conf
After this I restarted apache with this command apachectl restart
I installed MySQL with mysql-5.6.25-osx10.9-x86_64.dmg
I clicked on preferences and started MySQL server
I did export PATH=/usr/local/mysql/bin:$PATH because it said so in the tutorial
Ran these command because they were in the tutorial:
cd /var
mkdir mysql
cd mysql
ln -s /tmp/mysql.sock mysql.sock
I edited /etc/apache2/extra/httpd-vhosts.conf to make a new virtual host (here is my full config file)
Restarted apache again with apachectl restart
Added a line to my hosts file: 127.0.0.1 roy.local
Flushed dns: dscacheutil -flushcache
Started a browser and typed in: http//roy.local and I get a 403 forbidden page
I' ve already tried to give my /user/roy/websites folder a chmod of 775 by doing these commands:
cd /user/roy
chmod 775 Websites
And then restarted apache again, this didn't do the trick. Please help me out. If you need more information I'm happy to do that. I can't figure this out myself. Thanks in advance!
Change your setting to this. you are using the old apache syntax.
<Directory "/Users/Roy/Websites">
Require all granted
</Directory>
Just for testing purpose, change permission of the directory and files to 777.

Apache - The requested URL /erp was not found on this server

I am using apache as my web server running on ubuntu 14.04 and I have some web apps inside /var/www/html. Problem is, the default index.html page, which is in the same directory, gets displayed OK if I hit the server. However, when I try to access the applications in the same directory, I get the error - The requested URL /erp/ was not found on this server.
Try run:
sudo a2enmod rewrite
sudo service apache2 restart
Have you tried to set correct permissions on the directories of your web apps?
like so
chmod 755 erp -R

How to start with PHP on Ubuntu

I am newbie in PHP. I have successfully installed PHP on Ubuntu, now I want start my first program. I am using gPHPEdit as IDE.
Where should I save .php files that I create? And how to run/test them?
Make sure you have LAMP installed. Do a sudo tasksel and select lamp then hit enter, its gotta be the most simple *amp install ever made. Its a good idea to install phpmyadmin: sudo apt-get install phpmyadmin. After that just copy the files to /var/www/ and then they will show up on http://localhost. I recommended using Eclipse PDT or the Netbeans build for PHP.
You should pick up a book or start following some good tutorials on the web.
If you are just scripting using php, you can save them anywhere and run the php on the terminal using the php command line interpreter.
If you are trying write web scripts (and I think you are), you need to install and configure a web server (typically apache) and save your scripts in the server's document root (typically /var/www). Also, I highly recommend you to read up a little about servers and HTTP and figure out how all this works on the inside before learning to building websites in php.
If you cannot save or copy to var/www/html, to run your php scripts on your browser. If you are using Ubuntu 14.04.
I followed these steps and it worked for me.
Execute sudo su on the terminal.
Enter your password
Execute sudo subl /etc/apache2/sites-available/000-default.conf on your terminal to open this file. Note you can change the subl to any text editor to open the file e.g sudo nano /etc/apache2/sites-available/000-default.conf.
Change DocumentRoot /var/www/html to /home/user/yoursubdir
Save the file and close it.
Execute sudo subl /etc/apache2/apache2.conf on your terminal to open this file.
Add the following to end of the file
<Directory /home/user/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
Save and Close the file.
Execute sudo service apache2 restart
Go to your browser, type the URL of your script e.g 127.0.1.1/directory/document.php.
I hope this helps.
remove the index.html file from /var/www/
$ sudo rm index.html
create a new php file there:
$ sudo gedit /var/www/index.php
write in it:
<?php
print_r(phpinfo());
?>
Restart your Apache2 Server :
$ sudo service apache2 restart
OR
$ sudo /etc/init.d/apace2 restart
and point to yout localhost and /index.php
if err arises visit : http://www.allaboutlinux.eu/how-to-run-php-on-ubuntu/
https://www.php.net/manual/en/features.commandline.webserver.php
this is an easy way to test your files in php.
$ cd ~/public_html
$ php -S localhost:8000
then you can go to your browser and enter localhost:8000/myfile.php.

Categories