I just started using phpliteadmin to manage a SQLite database [1].
I set up local access using the build-in webserver in php5.4, exactly as shown the documentation [2]:
php -S localhost:8000
http://localhost:8000/phpliteadmin.php
I want to:
(1) Share phpliteadmin acess with several others on my network.
(2) Set up phpliteadmin with an Apache webserver (in case I needed to migrate away from the php server).
Interested in suggestions regarding ways to do both?
[1] On Linux machine running CentOS 6
[2] http://code.google.com/p/phpliteadmin/wiki/NoWebserver
I solved both, but wanted to open up what I did (perhaps it can be improved or is useful to others).
(1) Straightforward way to host using php5.4 webserver (specify IP address):
php -S <ip_address>:8000
http://<ip_address>:8000/phpliteadmin.php
(2) Host using Apache httpd (on CentOS 6) [1]:
(a) Set hostname of the webserver: /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=<NAME_OF_CHOICE>
NTPSERVERARGS=iburst
(b) Modify hosts file: /etc/hosts
<IP_ADDRESS> <NAME_OF_CHOICE>
(c) Modify Apache config file and include phpliteadmin.php as the default index : /etc/httpd/conf/httpd.conf
## Line 262 - Set the server admin mail ##
ServerAdmin <e-mail>
## Line 276 - Set the website name ##
ServerName <IP_ADDRESS>:80
## Line 292 - Set the web pages folder ##
DocumentRoot "/var/www"
## line 402 - Sent the index or home page of the website ##
DirectoryIndex phpliteadmin.php
(d) Make sure the server has php enabled. CentOS PHP module for Apache httpd is called "libphp5" [2]. For php54w install, the file was in: /usr/lib64/httpd/modules/libphp5.so
(e) Modify Apache config file [3]: /etc/httpd/conf/httpd.conf
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php
(f) Move phpliteadmin.php to document root of the webserver.
(g) Modify $directory in phpliteadmin.php to point to the directory of the database.
(h) Modify iptables to allow webserver through firewall: /etc/sysconfig/iptables
-A INPUT -p tcp -m state --state NEW --dport 80 -j ACCEPT
-A INPUT -p tcp -m state --state NEW --dport 80 -j ACCEPT
(i) Re-boot iptables:
service iptables restart
(j) Start the webserver:
service httpd start
(h) The server IP address in browser should recognize the phpliteadmin.php file and ask for database login.
If the .php file raw text displays, then php is not loading correctly and check step (e). If php loads, but reports database not found and / or directory not writable, check permissions on the database and DocumentRoot that phpliteadmin.php sits in (e.g., /var/www required sudo to modify and I had to open permissions).
[1] http://ostechnix.wordpress.com/2013/03/05/install-apache-webserver-in-centos-6-3-scientific-linux-6-3-rhel-6-3/
[2] http://www.rackspace.com/knowledge_center/article/centos-apache-and-php-install
[3] PHP code is not being executed, instead code shows on the page
Related
I am trying to get apache running locally with php, but for some reason, my apache is running on port 8080 instead of port 80 and it is using a different document root than is defined in the httpd.conf
When I run /usr/sbin/httpd -V it tells me where my server config file is
-D SERVER_CONFIG_FILE="/private/etc/apache2/httpd.conf"
I went to that file and it has this for Listen:
<IfDefine SERVER_APP_HAS_DEFAULT_PORTS>
Listen 8080
</IfDefine>
<IfDefine !SERVER_APP_HAS_DEFAULT_PORTS>
Listen 80
</IfDefine>
And this for document root:
DocumentRoot "/Library/WebServer/Documents"
apachectl -S also says Main DocumentRoot: "/Library/WebServer/Documents"
Earlier today it was saying /usr/local/var/www but i fixed that, but apache is still using /usr/local/var/www as the document root. Any ideas on what's causing this? My apache server is also not running the php it is just showing as plain text, not sure if that is related or not
Finally figured it out, I ran /usr/local/opt/httpd/bin/httpd -V | grep SERVER_CONFIG_FILE and that gave me -D SERVER_CONFIG_FILE="/usr/local/etc/httpd/httpd.conf" which was the actual config file it was using, I fixed that one and now its working.
After days of intensive search to solve my problem, I couldn't get anything that worked, so here it is.
I‘m running a chrooted php with FastCGI and php-fpm (under Ubuntu 16.04 with php7), which works well, however I get the expected DNS resolution problem, for example when trying to file_get_content : file_get_contents(): php_network_getaddresses: getaddrinfo failed.
I looked online quite a bit and here's what i've already tried (without success) :
I used the methods described here, and also tried to adapt this tutorial in order to copy all the libraries used by php, and of course copied hosts and resolv files
I also tried to use nscd to link hosts file inside and outside the chroot by mounting it inside the chroot at /var/run/nscd
I also got some SSL issues, so I downloaded this certificate and put it where the default php-curl certificate was probably missing (found after openssl_get_cert_locations() : ["default_cert_file"]=> string(21) "/usr/lib/ssl/cert.pem)
edit: This doesn't seem to do much as phpinfo() returns no value for the certs files (see), so maybe I should tweak a bit openssl config file but I really don't know what to look for.
Using debootstrap (or other programs like this) is not an option for me, because it creates a too large chroot, and I'm willing to keep it lightweight and fast to create as I could have many chroots running on one machine.
Plus, here are my config files, however I doubt the problem to be here because most php functions work well under chroot :
Default php-fpm pool:
[${username}]
user = ${username}
group = www-data
listen = /run/php/php7.0-fpm.${username}.sock
listen.owner = ${username}
listen.group = www-data
pm = ondemand
pm.max_children = 20
pm.process_idle_timeout = 10s
pm.max_requests = 250
chroot = /var/www/${username}
chdir = /
Default apache virtualhost file :
<VirtualHost *:80>
ServerName www.${domain}
ServerAlias ${domain}
ServerAdmin webmaster#${domain}
DocumentRoot /var/www/${username}/var/www/${username}
<IfModule mod_fastcgi.c>
AddHandler php7-fcgi-${username} .php
Action php7-fcgi-${username} /php7-fcgi-${username} virtual
Alias /php7-fcgi-${username} /usr/lib/cgi-bin/php7-fcgi-${username}
FastCgiExternalServer /usr/lib/cgi-bin/php7-fcgi-${username} -socket /var/run/php/php7.0-fpm.${username}.sock -pass-header Authorization
<Directory /usr/lib/cgi-bin>
Require all granted
</Directory>
</IfModule>
</VirtualHost>
Thanks !
Under Ubuntu 16.04, you need at least these files in your chroot:
etc/resolv.conf
lib/libnss_dns.so.2
You can hardlink to prevent using extra disk space (only works when the chroot is on the same partition as /lib):
ln --logical /lib/x86_64-linux-gnu/libnss_dns.so.2 /chroot/lib
If it still fails (future Ubuntu?) you can debug the issue by running strace -e file -fp $(pgrep fpm)
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 would like to host Wordpress and Magento PHP sites on a IBM/Lotus Domino Server with plans to integrate with Lotus Notes databases.
I have installed PHP 5.3.29, MySQL 5.6.21.1, phpMyAdmin 4.2.10.1
I am NOT running IIS or Apache.
I am running IBM Domino Enterprise Server 9.01 with HTTP Server task.
I have created the URL-->Directory mapping doc in the Domino Directory:
Incoming URL String: /*.php
Target server directory: c:\php\php-cgi.exe /*.php
Access Level: Execute
I have created a directory 'php' in the Domino HTML folder (c:\domino\data\domino\html\php)
I created a info.php file that displays phpinfo():
<?php phpinfo(); ?>
I am able to bring up http://domain.com/php/info.php perfectly. !!
I am able to run phpMyAdmin and create MySQL db's.
I am able to install and configure Wordpress.
HOWEVER I must add index.php to any URLs that only include the directory.
For example /wp/wp-admin/index.php works.
But /wp/wp-admin/ or /wp/wp-admin return status 403 and error:
Unable to process request, directory browsing is not allowed
SO Here is my question:
How can I get the Domino HTTP service to look for index.php in addition to index.htm & index.html when a URL is only of the directory? If there is a file named index.html in the Domino HTML directory, you need only use the directory name. How to add index.php to the list of files to look for if only a directory is in the URL? Is there some configuration file where I can add index.php to the list?
Please note that I am not using Apache so the .htaccess file has no effect (correct me if I am wrong) in the Domino HTTP environment.
Thanks in advance.
I was able to host a Wordpress site on a Domino 9 server running the optional IBM HTTP Server (IHS). All running on Windows Server 2008 R2.
First, Domino 9 Server must be installed with the option 'IBM HTTP Server' -- you have to do a Custom installation to see the choice. This installs IBM HTTP Server (IHS) which is a version of Apache that integrates with Domino HTTP.
IHS is installed in the Domino directory 'ihs'. The ihs\conf\domino.conf file needs to be edited -- most of it is OK as is. The file domino.conf is used instead of httpd.conf which would normally be used to run IHS without the Domino HTTP connection.
Add domino\ihs\bin\ httpd.exe to your Firewall rules since it will now be receiving the HTTP requests and proxying them to the Domino server on a different port. This setup will allow the installation of TLS encryption certificates, for example.
Make edits to domino.conf:
Uncomment line:
Listen 0.0.0.0:80
Comment out SetHandler domino-handler :
<IfModule mod_domino.c>
...
#<LocationMatch /*>
#SetHandler domino-handler
#</LocationMatch>
</IfModule>
Append the following at the end of domino.conf:
LoadModule dir_module modules/mod_dir.so
DirectoryIndex index.html index.htm index.php
Win32DisableAcceptEx
LoadModule php5_module "C:\php\php5apache2_2.dll"
<IfModule php5_module>
AddType application/x-httpd-php .php
PHPIniDir c:/php/
</IfModule>
NameVirtualHost *:80
#default vhost for Domino HTTP:
<VirtualHost *:80>
ServerName "${DOMINO_SERVER_NAME}"
DocumentRoot "${DOMINO_DOCUMENT_ROOT}"
<IfModule mod_domino.c>
<LocationMatch /*>
SetHandler domino-handler
</LocationMatch>
</IfModule>
</VirtualHost>
# vhost for wordpress.domain.com
<VirtualHost *:80>
ServerName wordpress.domain.com
DocumentRoot "${DOMINO_DOCUMENT_ROOT}/wp"
</VirtualHost>
Secondly, to install PHP5 on IHS, we have to use the thread safe version -- I had previously installed the non-thread safe (nts) versions configured for 'Other CGI' which did not allow for a php module that could be loaded by the IHS (Apache) server.
PHP 5.3.29 VC9 x86 Thread Safe (2014-Aug-15 20:02:15)
Installer [38.38MB] http://windows.php.net/downloads/releases/php-5.3.29-Win32-VC9-x86.msi
I used the PHP installer program - install PHP in C:\PHP, choose Apache 2.2.x Module during web server setup.
I copied the Wordpress files into the Domino html directory domino\data\domino\html\wp .
Finally, to run IHS on Domino, edit notes.ini and add:
HTTPIHSEnabled=1
Restart the HTTP task on the Domino server. Pay attention to console to make sure there are no errors with domino.conf file.
The above configuration will send ALL HTTP requests on port 80 to the Domino HTTP task as normal with the exception of wordpress.domain.com which will continue to be handled by the IHS server instead of the Domino server.
The Virtual Host doc in the Domino directory for wordpress.domain.com is not needed, and the URL-->Directory mapping doc in the Domino Directory I originally added is now no longer needed (and now there is no c:\php\php-cgi.exe file).
Note that Domino does no logging of any IHS virtual hosts that are not handled by Domino.
According to the book "IBM HTTP Server on z/OS: Migrating from Domino-powered to Apache-powered" (p.42, bottom) there exists a Welcome directive in Domino, which should do the same as DirectoryIndex in Apache.
This should do the trick:
Welcome index.php index.html index.htm
although I do not know where to put that... but maybe you already know that.
Please do not answer until you read the full question :)
In a freshly created DigitalOcean CentOS 6.5 (64 bit) server, I tried creating two Apache virtual hosts - www.example-rose.com and www.example-tulip.com by issuing following commands:
Server Side Setup
# software installation
yum install httpd mod_fcgid php-cli
# added cgi.fix_pathinfo=1 in /etc/php.ini
echo "cgi.fix_pathinfo=1" >> /etc/php.ini
echo "PHP_Fix_Pathinfo_Enable 1" >> /etc/httpd/conf.d/fcgid.conf
# added new users and groups for the two virtual sites
groupadd rose
groupadd tulip
useradd -s /bin/false -d /var/www/rose -m -g rose rose
useradd -s /bin/false -d /var/www/tulip -m -g tulip tulip
chmod 755 /var/www/rose
chmod 755 /var/www/tulip
# create new document root and make them own by respective users
mkdir -p /var/www/rose/web
chown rose:rose /var/www/rose/web
mkdir -p /var/www/tulip/web
chown tulip:tulip /var/www/tulip/web
Now since I want to run PHP through SuEXEC, I have done following additional steps of creating a wrapper script for SuEXEC
mkdir -p /var/www/php-fcgi-scripts/rose
mkdir -p /var/www/php-fcgi-scripts/tulip
# inside the wrapper, I added a file (/var/www/php-fcgi-scripts/rose/php-fcgi-starter)
# with below content:
#!/bin/sh
PHPRC=/etc/
export PHPRC
export PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_CHILDREN=8
exec /usr/bin/php-cgi
# changed the permission
chmod 755 /var/www/php-fcgi-scripts/rose/php-fcgi-starter
chown -R rose:rose /var/www/php-fcgi-scripts/rose
# above steps are repeated for tulip as well
Then finally I added the following content in my httpd.conf file to enable the virtual hosting
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.example-rose.com
ServerAlias example-rose.com
ServerAdmin webmaster#example-rose.com
DocumentRoot /var/www/rose/web/
<IfModule mod_fcgid.c>
SuexecUserGroup rose rose
<Directory /var/www/rose/web/>
Options +ExecCGI
AllowOverride All
AddHandler fcgid-script .php
FCGIWrapper /var/www/php-fcgi-scripts/rose/php-fcgi-starter .php
Order allow,deny
Allow from all
</Directory>
</IfModule>
ErrorLog /var/www/rose/error.log
CustomLog /var/www/rose/access.log combined
ServerSignature Off
</VirtualHost>
<VirtualHost *:80>
... similar lines for the second virtual host (Tulip). Cutting short ...
</VirtualHost>
I restarted the server and put one index.php file in the web directory with following content : <?php phpinfo(); ?>.
Local Machine
In order to test the virtual hosts, I issued following commands from my local machine using curl
$> curl -v -H "www.example-rose.com" 162.*.35.155/index.php
* Trying 162.*.35.155...
* Connected to 162.*.35.155 port 80 (#0)
> GET /index.php HTTP/1.1
> User-Agent: curl/7.30.0
> Host: www.example-rose.com
> Accept: */*
>
* Empty reply from server
* Connection #0 to host 162.*.35.155 left intact
curl: (52) Empty reply from server
If I try accessing through web browser instead of curl (after creating /etc/hosts entry for the domains), I get blank page. No Apache Access log or error log is generated in the server. If I put a static file (instead of php file), I can access the static file without any issue. But .php file does not work.
However
When I try to curl from the DigitalOcean's server itself (or from some other server within DigitalOcean's network), I get to see the expected index.php with phpinfo() results without any issue. But doesn't work when I try from outside DO's network.
I have done all sorts common troubleshooting (installing, re-installing, checking permissions, checking conf files again and again etc.) and I am at my wit's end now. Next what?
Please do not answer until you read the full question :)