I have installed 64-Bit WAMP Server on my local computer. I have a sample php program placed under c:/Users/Admin/Documents/First.php. I have checked the phpmyadmin.conf and it looks as below:
Alias /phpmyadmin "c:/wamp64/apps/phpmyadmin4.6.4/"
<Directory "c:/wamp64/apps/phpmyadmin4.6.4/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
<ifDefine APACHE24>
Require all granted
</ifDefine>
<ifDefine !APACHE24>
Order Deny,Allow
Allow from all
Allow from localhost ::1 127.0.0.1
</ifDefine>
# To import big file you can increase values
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>
I have made sure the WAMP server is running and all services are good.
When I try to run the following on IE: http://localhost/c:/Users/Admin/Documents/First.php
I get the following error:
You don't have permission to access /c:/Users/Admin/Documents/First.php on this server.
Can someone guide me through the steps, to run my program successfully?
WAMP should have created its own folders. If you have installed WAMP on C: the folder to place your script in, should be s.th. like C:\WAMP\www. Place your script First.php in that directory and then call http://localhost/First.php via browser. That should run...
your php file should be inside the xampp->htdocs->yourfile.. you cannot simply put the php file at any directory. wamp->htdocs for wampserve if im not mistaken
If you want to open your script in the browser you want to put the file inside the web root of your WAMP.
If this is a script which does not require web interface you can always use CLI and run the file using the CLI.
Related
I want to import a big sql file to mysql database locally .
I try to import it with command line but i execute the command and i waited more than two hours without any results for an 170 Mo sql file .
I tried also to change php.ini but wampserver don't start .
memory_limit = 900M
post_max_size = 500M
upload_max_filesize = 500M
How can i import my file please ?
With the following command
mysql -u username -p password dbname < dump.sql
you do not have to modify your php.ini, you are not using PHP.
You can use this command to display what is going:
mysql -u username -p password dbname --verbose < dump.sql
Your file is big, it can take a while to load on your local database, it depends of your own computer and for example if the datas loaded have a lot of indexes.
Wampserver controls the limits applied to phpMyAdmin from the alias definition for phpMyAdmin
So edit \wamp\alias\phpmyadmin.conf it should look like this initially in WAMPserver 2.5
Alias /phpmyadmin "d:/wamp/apps/phpmyadmin4.1.14/"
# to give access to phpmyadmin from outside
# replace the lines
#
# Require local
#
# by
#
# Require all granted
#
<Directory "d:/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>
So amend these parameter to increase the limits
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
Alternatively you can use the mysql console launched from the wampmanager menus like so :-
left click wampmanager -> MySQL -> MySQL console
If you have not chnaged the MySQL root password, just hit enter when asked for the password, alternatively is you have chnaged the root password enter the actual password at the prompt.
Then enter this command at he mysql> prompt to run you restore of you backup file
source C:/path/to/your/backup.sql
This has not limits on execution time or file size.
Im trying to backup a wordpress website from host and move it back on my local host and keep it as a sample for rebuilding. If have any workaround or maybe other methods I`m all ears
I backedup my website and database also, but when I`m trying to "Import" my sql database I always get the fallowing error Fatal error:
Maximum execution time of 360 seconds exceeded in
C:\wamp\apps\phpmyadmin4.1.14\libraries\import.lib.php on line 345
The database is kind of big 203MB and I archived it aiesecbu_achieve.sql.zip 55.8 MB
I can say that I`ve already tried this: Fatal error: Maximum execution exceeded
and modifying my php.ini
post_max_size = 400M
upload_max_filesize = 250M
memory_limit = 128M
I have uploaded my database for you to test it if you want(maybe it`s something wrong with it) and a screenshot
https://www.dropbox.com/s/cx9wava7sptf4km/mysql.jpg?dl=0
You can try to use mysql console.
Run cmd command
Type c: or d: on command prompt. This will be based on your WAMP server installations.
Assuming you have installed wamp on D: drive.
D:\>cd wamp
D:\wamp>cd bin
D:\wamp\bin>cd mysql
D:\wamp\bin\mysql>cd mysql15.1.36
D:\wamp\bin\mysql\mysql15.1.36>cd bin
D:\wamp\bin\mysql\mysql15.1.36\bin>mysql.exe -u root
use database
source source.sql
Bassicaly you login into mysql, use database determines which database you want to use, source /source/to/source.sql determines which sql you want to run. Pretty easy and efficient.
As you have phpMyAdmin4.1.14 installed I assume you are using WAMPServer 2.5
In WAMPServer 2.5 the PHP resources used by phpMyAdmin are controlled from the phpMyAdmin alias config file. It was changed for exactly these situations, so you dont have to change the php.ini to add a ridiculously large values to parameters that effect your whole PHP environment.
So to increase the relevant paameters you would do this :-
Edit \wamp\alias\phpmyadmin.conf which should look like this by default
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>
Now change the parameters here, so they only effect what happens when you are running phpMyAdmin.
These are the parameters you should amend
php_admin_value upload_max_filesize 500M <-- and probably this
php_admin_value post_max_size 128M
php_admin_value max_execution_time 620 <-- this for a start
php_admin_value max_input_time 360
But basically try a modification and see if it works, if not depending on the error amend the relevant parameter.
Dont forget to restart Apache after each change you make to this file
Oh and dont forget to undo the changes you made to php.ini
For the latest version of wamp server:
Wampserver 2.5.17 32bits
Apache 2.4.17/2.2.31
PHP 5.6.14/7.0.0rc5/5.5.30/5.4.45/5.3.29
MySQL 5.6.27/5.7.9/5.5.46/5.1.73/5.0.83
PhPMyAdmin 4.5.0
MysqlDumper 1.24.4 (W7 Pro 64bits)
try this out:
In wamp\alias\phpmyadmin.conf file, just before the last statement </Directory> add four statements to obtain:
php_admin_value upload_max_filesize 512M
php_admin_value post_max_size 512M
php_admin_value max_execution_time 900
php_admin_value max_input_time 900
</Directory>
I have a php script to upload files in a directory.
This works fine in apache's DocumentRoot.
When I copy the code in my /home/$USER/public_html , instead of the right output I just when a printout of the php file. I presume it does not get executed.
I was looking into the userDir module and found this
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
includesNoExec looked promising but it is related to cgi only.
So how can I enable php scripts to be executed for every user?
Try setting this configuration:
<IfModule mod_userdir.c>
<Directory /home/*/public_html>
php_admin_value engine On
</Directory>
</IfModule>
Don't forget to restart Apache.
service apache2 restart
It turns out the important bit of code that Claudix provided is already present in the configuration files under /etc/apache2/mods-available/php5.conf
the clause there contains php_admin_value engine Off , so by setting the Claudix solution anywhere will conflict with this setting. What is more, the comment above suggests NOT to set php_admin_value engine On as it renders .htaccess files unable to disable php.
As such the correct way to run php in user www directories is by commenting out the relevant text in /etc/apache2/mods-available/php5.conf
I assume you are using apache2 on debian like I do and I think the solution
for you is to add Alias dir and set that alias dir config like below
1 edit the apache2 configuration from terminal run this command
sudo gedit /etc/apache2/sites-enabled/000-default
2 edit the path you will to execute PHP files and save
Alias /testdir /home/user/testdir
<Directory /home/user/testdir>
Options FollowSymLinks
DirectoryIndex index.php
AllowOverride All
</Directory>
3 restart apache2
sudo service apache2 restart
check If you can access the folder from browser if not probably you will have to chmod/chown the folder
yourhost/testdir
According to Apache 2.2 documentation this can be done by uncommenting this configuration line:
#Include conf/extra/httpd-userdir.conf
and modifying httpd-userdir.conf to suit your server. Based on your qustion text, this should resolve your issue.
I'm working with an existing PHP web application. It's running fine on the remote Linux server but I can't run it on WAMP server, Windows 7 on my local computer. The problem is the previous developer's used absolute path all over the code. for example one of them is:
require '/disk2/html/src/web_tool/db_connect.php';
my localhost folder is F:\wamp\www and I have the same structure:
F:\wamp\www\myProject\disk2\html\src\web_tool\db_connect.php
But it can't find the db_connect.php. I can't change the path because it's a big project and if I want to, I have to find and change more than 400 line of code. I'm not sure what the problem is and how to make it work. Any suggestion is highly appreciated.
EDIT: I ran a simple test on my WAMP Server. I created this file structure:
F:\wamp\www\test\myfolder\index.php with this code:
require '/myinc.php';
and F:\wamp\www\test\myinc.php with this code:
echo 'It works!';
I get this warning:
Warning: require(/myinc.php): failed to open stream: No such file or directory in F:\wamp\www\test\myfolder\index.php on line 2
and this error:
Fatal error: require(): Failed opening required '/myinc.php' (include_path='.;C:\php\pear') in F:\wamp\www\test\myfolder\index.php on line 2
I don't have such a folder as C:\php\pear on my disk.
The WAMP server is just installed, haven't touched anything in the php.ini or other config files. the version is:
WAMP SERVER 64bit version 2.5 including:
Apache : 2.4.9 MySQL : 5.6.17 PHP : 5.5.12 PHPMyAdmin : 4.1.14 SqlBuddy : 1.3.3 XDebug : 2.2.5
I think your best solution would be to move the site source and create a Virtual Host, then the absolute paths would work and you can address the site properly as well.
First move the disk2 folder and all its subfolders to the root of your F: drive.
F:\disk2.....
Then create a Virtual Host to describe its new location.
Edit \wamp\bin\apache\apache2.x.y\conf\extra\httpd-vhosts.conf
If this is your first Virtual Host definition, remove the existing contents of this file.
I have assumed that F:\disk2\html is the correct folder to become your DocumentRoot.
Add this to the file
<IfDefine !APACHE24>
NameVirtualHost *:80
</IfDefine>
## so the the wamp menu page loads
<VirtualHost *:80>
DocumentRoot "F:/wamp/www"
ServerName localhost
ServerAlias localhost
<Directory "F:/wamp/www">
AllowOverride All
<IfDefine APACHE24>
Require local
</IfDefine>
<IfDefine !APACHE24>
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 localhost ::1
</IfDefine>
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "F:/disk2/html"
ServerName example.dev
ServerAlias www.example.dev
<Directory "F:/disk2/html">
AllowOverride All
<IfDefine APACHE24>
Require local
</IfDefine>
<IfDefine !APACHE24>
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 localhost ::1
</IfDefine>
</Directory>
</VirtualHost>
Save this file.
Edit httpd.conf and remove the comment from this line
#Include conf/extra/httpd-vhosts.conf
remove the # in col 1 and save that file.
Now edit the hosts file C:\windows\system32\drivers\etc\hosts and add these lines.
127.0.0.1 example.dev
::1 example.dev
This is a windows protected file so you will have to open your editor using the "Run as Administrator" or you wont be allowed to save your changes.
Now start a command windows also using the "Run as Administrator" and execute these 2 statements to refresh the DNS cache with your changes to the hosts file.
net stop dnscache
net start dnscache
Now restart Apache so that it picks up your configuration changes, and you should be able to use this address in the browsers address bar.
example.dev
The DocumentRoot should be as it was on the live server and the absolute paths used in the PHP code should also now work as they do on the live server.
Change example.dev to whatever makes sense as related to your live sites domain name.
If you have the same folder strcture a simple set_include_path() should solve the problem in the root directory.
I gues in F:\wamp\www\myProject there should be an index file, just add there:
set_include_path('');
But if you can't find the file you're looking for, I guess that it is missing / you did not copy over everything you needed (something like that). Than the problem is not really the relative path.
This isn't much of a technical answer and it's five years later, but FWIW I had the same issue after upgrading my WAMP version after a couple of years that some of by requires were no longer working on the localhost while they were working just fine when published on the active webapp.
For me, I found a setting called 'allow_url_include' and activating that setting and restarting services everything appears to be in working order now. Hope this helps somebody.
XAMPP makes configuring a local LAMP stack for windows a breeze. So it's quite disappointing that enabling .htaccess files is such a nightmare.
My problem:
I've got a PHP application that requires apache/php to search for an /includes/ directory contained within the application. To do this, .htaccess files must be allowed in Apache and the .htaccess file must specify exactly where the includes directory is.
Problem is, I can't get my Apache config to view these .htaccess files. I had major hassles installing this app at uni and getting the admins there to help with the setup. This shouldn't be so hard but for some reason I just can't get Apache to play nice.
This is my setup:
c:\xampp
c:\xampp\htdocs
c:\xampp\apache\conf\httpd.conf - where I've made the changes listed below
c:\xampp\apache\bin\php.ini - where changes to this file affect the PHP installation
It is interesting to note that c:\xampp\php\php.ini changes mean nothing - this is NOT the ini that affects the PHP installation.
The following lines are additions I've made to the httpd.conf file
#AccessFileName .htaccess
AccessFileName htaccess.txt
#
# The following lines prevent .htaccess and .htpasswd
# files from being viewed by Web clients.
#
#<Files ~ "^\.ht">
<Files ~ "^htaccess\.">
Order allow,deny
Deny from all
</Files>
<Directory "c:/xampp/htdocs">
#
# AllowOverride controls what directives may be placed in
# .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
</Directory>
The following is the entire .htaccess file contained in:
c:\xampp\htdocs\application\htaccess.txt
<Files ~ "\.inc$">
Order deny,allow
Deny from all
</Files>
php_value default_charset "UTF-8"
php_value include_path ".;c:\xampp\htdocs\application\includes"
php_value register_globals 0
php_value magic_quotes_gpc 0
php_value magic_quotes_runtime 0
php_value magic_quotes_sybase 0
php_value session.use_cookies 1
php_value session.use_only_cookies 0
php_value session.use_trans_sid 1
php_value session.gc_maxlifetime 3600
php_value arg_separator.output "&"
php_value url_rewriter.tags "a=href,area=href,frame=src,input=src,fieldset="
The includes directory exists at the location specified.
When I try to access the application I receive the following error:
Warning: require(include.general.inc) [function.require]: failed to open stream: No such file or directory in C:\xampp\htdocs\application\menu\logon.php on line 21
Fatal error: require() [function.require]: Failed opening required include.general.inc (include_path='.;C:\xampp\php\pear\random') in C:\xampp\htdocs\application\menu\logon.php on line 21
The include path c..\random\ is specified in the php.ini file listed above. The XAMPP install fails to allow another include path as specified in the htaccess.txt file.
I'm guessing there's probably an error with the httpd.conf OR the htaccess.txt file.. but it doesn't seem to be reading the .htaccess file. I've tried to be as thorough as possible so forgive the verbosity of the post.
Now I know a workaround could be to simply add the include_path to the PHP file, but I'm not going to have access to the php.ini file on the location I plan to deploy my app. I will, however, be able to request the server admin allows .htaccess files.
renamed htacces.txt to .htaccess and ammended the appropriate directives in the httpd.conf file and all seems to work. The application suggested the naming of htaccess.txt and the ammended directives in the httpd. These are obviously wrong (at least for a XAMPP stack).
By the way, using ini_set() is a much friendlier way if the app needs to be deployed to multiple locations so thanks especially for that pointer.
Why do you need to rename .htaccess to htaccess.txt
Try setting the include_path using set_include_path() and see if that helps (as an intermediate fix)
Verify which php.ini to use through a phpinfo()
You can alter the include_path on each request using ini_set(). This would avoid having to use htaccess at all.
My htaccess works under XAMPP fine - though some modules are disabled by default - are you sure that the modules you want are enabled?
I think the searchprase you are looking for is:
AllowOverride All
My guess is that within xampp you need to enable AllowOverride (through an .htaccess) in httpd.conf. It's a simple security measure that prevents newbies from installing a hackable platform :P
You need to enable AllowOverride All in main http.conf file. Look inside XAMPP_DIR/apache/conf/http.conf)
Simply Do this:
open file ...\xampp\apache\conf\httpd.conf
find line "LoadModule rewrite_module modules/mod_rewrite.so"
if here is a # before this line remove it.(remove comment)
its working