PHP install does not work

Hi, I am new to FreeBSD and I am trying to set[ ]up Wordpress on a FreeBSD virtual machine.

When I tried to open a PHP page to test if PHP is working but my web browser tries to download the file. I had already modified the httpd.conf file and restarted the apache server. I am using FreeBSD 9.2.

Code:
===> The following configuration options are available for php5-5.4.17:
     CLI=on: Build CLI version
     CGI=on: Build CGI version
     FPM=off: Build FPM version
     APACHE=on: Build Apache module
     AP2FILTER=off: Use Apache 2.x filter interface (experimental)
     EMBED=on: Build embedded library
     DEBUG=on: Enable debug
     DTRACE=off: Enable DTrace support
     IPV6=on: Enable ipv6 support
     MAILHEAD=off: Enable mail header patch
     LINKTHR=on: Link thread lib (for threaded extensions)
     ZTS=off: Force Zend Thread Safety (ZTS) build

What am I missing?

Thanks in advance.
 
Edit: Decided to change to a more direct question.

What did you add to httpd.conf? And can you confirm that it includes the line shown below (or very similar), which is usually done automatically by the port install?

Code:
LoadModule php5_module        libexec/apache22/libphp5.so
 
What do you have for PHP in your httpd.conf?

Make sure you have the following lines:

Code:
LoadModule php5_module        libexec/apache/libphp5.so
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

Also add index.php to DirectoryIndex.
 
I added

Code:
<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>
and
Code:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

This is NOT in the file
Code:
LoadModule php5_module        libexec/apache/libphp5.so
 
There's the problem then. If that line definitely isn't in there, the PHP module isn't being loaded so .php files will just be served raw with an application/x-httpd-php mime type. Your browser doesn't know what to do with this mime type so asks you to save it.

Usually PHP would take over and output whatever mime type your script tells it to (or will output text/html by default).

I would first check that the module exists by looking in the Apache modules directory - /usr/local/libexec/apache or /usr/local/libexec/apache22. If it's there, just add the LoadModule line into httpd.conf in the same place as all the other LoadModule declarations.
 
usdmatt said:
There's the problem then. If that line definitely isn't in there, the PHP module isn't being loaded so .php files will just be served raw with an application/x-httpd-php mime type. Your browser doesn't know what to do with this mime type so asks you to save it.

Usually PHP would take over and output whatever mime type your script tells it to (or will output text/html by default).

I would first check that the module exists by looking in the Apache modules directory - /usr/local/libexec/apache or /usr/local/libexec/apache22. If it's there, just add the LoadModule line into httpd.conf in the same place as all the other LoadModule declarations.

The file is not in the directory /usr/local/libexec/apache22.

Do I have install something to get the missing file? What do I need to do go get the missing file?

Thanks.
 
Hmm, did you definitely build *and* install the PHP port, after enabling the APACHE=on option with make config?
If told to build the Apache module, the PHP port should install the libphp5.so file into the Apache modules directory automatically when you run make install.

I assume you actually have a /usr/local/libexec/apache22 directory containing all the other Apache modules? If you installed a different version of Apache this directory may have a slightly different name.
 
usdmatt said:
Hmm, did you definitely build *and* install the PHP port, after enabling the APACHE=on option with make config?
If told to build the Apache module, the PHP port should install the libphp5.so file into the Apache modules directory automatically when you run make install.

I assume you actually have a /usr/local/libexec/apache22 directory containing all the other Apache modules? If you installed a different version of Apache this directory may have a slightly different name.

I first did a pkg_add then later the make install clean

Below are the list of files in the /usr/local/libexec/apache22 directory

Code:
httpd.exp               mod_cache.so            mod_log_config.so
mod_actions.so          mod_cern_meta.so        mod_logio.so
mod_alias.so            mod_cgi.so              mod_mime.so
mod_asis.so             mod_charset_lite.so     mod_mime_magic.so
mod_auth_basic.so       mod_dav.so              mod_negotiation.so
mod_auth_digest.so      mod_dav_fs.so           mod_reqtimeout.so
mod_authn_alias.so      mod_deflate.so          mod_rewrite.so
mod_authn_anon.so       mod_dir.so              mod_setenvif.so
mod_authn_dbm.so        mod_disk_cache.so       mod_speling.so
mod_authn_default.so    mod_dumpio.so           mod_ssl.so
mod_authn_file.so       mod_env.so              mod_status.so
mod_authz_dbm.so        mod_expires.so          mod_suphp.so
mod_authz_default.so    mod_file_cache.so       mod_unique_id.so
mod_authz_groupfile.so  mod_filter.so           mod_userdir.so
mod_authz_host.so       mod_headers.so          mod_usertrack.so
mod_authz_owner.so      mod_imagemap.so         mod_version.so
mod_authz_user.so       mod_include.so          mod_vhost_alias.so
mod_autoindex.so        mod_info.so
 
Where did those PHP install options come from?

Last time I checked the PHP package did not include the Apache module, you have to build the port from source.
 
I rebuilt and it kind of works. The PHP file is no longer being downloaded. It's just blank.
 
You might want to check your Apache error log (/var/log/httpd-error.log) for clues.
 
Misspelling in .php file. It works now. Thanks.

How do you guys memorize all these locations and commands? I have to write down everything I do.

Now to try to get Wordpress working.

Thanks again.
 
usdmatt said:
Where did those PHP install options come from?

Last time I checked the PHP package did not include the Apache module, you have to build the port from source.


I did not rebuild when I selected the Apache option.

Thanks
 
Falen said:
How do you guys memorize all these locations and commands? I have to write down everything I do.
Just use it a lot. Then it'll come naturally. First time I installed Apache, many many years ago, I had to look up everything too. Took me forever to get it working. Now, after hundreds of installs, I can do it in a couple of minutes without having to look up anything. It's what most people would call experience ;)
 
Falen said:
How do you guys memorize all these locations and commands? I have to write down everything I do.
Manual pages.

If you want to get around on a Unix environment then forget about notes; learn how to use the manual pages instead. The man and apropos command are your friends.

For example; you're wondering what build options you can use on a port. You wish to contact a port maintainer, you know it can be done using a make command but what options do you need again?

Code:
smtp2:/home/peter $ apropos ports
exports(5)               - define remote mount points for NFS mount requests
ipfstat(8)               - reports on packet filter statistics and filter list
portindex(5), INDEX(5)   - File containing information about the state of the ports tree
ports(7)                 - contributed applications
portsnap(8)              - fetch and extract compressed snapshots of the ports tree
portsnap.conf(5)         - configuration file for portsnap(8)
Well, ports(7) looks like an interesting read for this. And what do you know, if you check that manual page out then you'll come across this:

Code:
smtp2:/home/peter $ man ports

PORTS(7)           FreeBSD Miscellaneous Information Manual           PORTS(7)

NAME
     ports -- contributed applications

... CUT ...

     maintainer       Display the port maintainer's email address.
In many cases those commands can be a life saver when it comes to finding information.

Adding a (pre-build) package to your system?

Code:
smtp2:/home/peter $ apropos package
csup(1)                  - network distribution package for CVS repositories
groff_trace(7)           - groff macro package trace.tmac
ncurses(3)               - CRT screen handling and optimization package
pkg_add(1)               - a utility for installing software package distributions
pkg_create(1)            - a utility for creating software package distributions
pkg_delete(1)            - a utility for deleting previously installed software package distributions
Obviously you'll want to look into pkg_add for that one.

Just two simple examples of course, but using this approach you can find out a lot about your system right from the commandline. Many programs as well as their configuration files have manualpages which you can look through.
 
Please don't contact maintainers for ordinary support. Web searches, forums, and mailing lists are better. If there is a bug, enter a PR. PRs have a history, and other people can search through them.

On the other hand, I do sometimes think about all the hard work maintainers do on the ports I use, and send them a simple thanks. They are usually surprised, but seem to like it. :)
 
Falen said:
How do you guys memorize all these locations and commands? I have to write down everything I do.

For programs like Apache, in fact most programs, the documentation on their site(s) is (are) really really helpful and precise. For any problems encountered, their mailing list(s) is (are) your best bet. Between those two sources, you'll have everything you need. I find manual pages are okay for different tasks; such as, ezjail-admin, openssl or ssh-keygen. Commands as opposed to programs.

I'm new to FreeBSD too. What help me, I installed ezjail, made a few jails and experimented in them. I've installed Apache, MySQL and PHP a handul of times, Postfix and Dovecot too. I tried different configurations in the different installs. Read through all the config files. The repetitive work amounts to practise and over time, experience.

I can't emphasize the official documentation and mailing lists for the respective programs enough though. Duckduckgo is always good too. There are some great guides, you just need to find them.

Now to try to get Wordpress working.

Thanks again.

WordPress is easy:

Code:
# cd /usr/local/www/apache24/data
# fetch http://wordpress.org/latest.tar.gz
# tar -zxvf latest.tar.gz
# cp /wordpress/wp-config-sample.php /wordpress/wp-config.php
# vi wp-config.php
  1. Assuming you've already created the database in MySQL you need to add the database name and MySQL root/admin credentials to the file.
  2. Direct your browser to http://your-domain.com/wordpress/wp-admin/install.php
  3. Enter your desired info (site name, username, password, etc.) into the fields and let the Install Wizard do the rest

If you want help creating the database, let me know.
 
Falen said:
How do you guys memorize all these locations and commands? I have to write down everything I do.

Short answer: Long experience of just doing things and using all kinds of computer systems. I don't really remember (nor do I try to memorize) where all the files for a particular program are located but I can quickly deduce the most obvious location and usually I don't have to make a second guess.
 
wblock@ said:
There is a Wordpress port: www/wordpress. Using ports rather than source makes it much easier to update versions.

There's really no point building WordPress from ports. You update WordPress through your Admin control panel by clicking a button. Ports are often outdated too. The latest version is 3.8 (see: http://www.freshports.org/www/wordpress).

You can also update manually much quicker and easier than ports:

Code:
# cd /usr/local/www/apache24/data/wordpress
# tar -cvf wp-save.tar wp-config.php .htaccess wp-content wp-images && mv wp-save.tar ../
# cd ..
# rm -r wordpress
# fetch http://wordpress.org/latest.tar.gz
# tar -zxvf latest.tar.gz
# mv wp-save.tar wordpress/ && cd wordpress 
# tar -zxvf wp-save.tar

You're better off using source. You get the latest release plus save the time of building from ports for such a simple program; there's only one build option.

ETA: Like I mentioned, official documentation is hard to beat.
  1. Upgrading WordPress: http://codex.wordpress.org/Updating_WordPress
  2. Upgrading WordPress (detailed manual process): http://codex.wordpress.org/Upgrading_WordPress_Extended
 
I just want to chime in with @nanotek. Another reason to use the WordPress interface itself is that you also don't have to worry about any silly requirements for using or changing the permission bits into something potentially dangerous (like giving your webserver write access to website contents).

No such thing here; you simply provide your FTP account and then WordPress can utilize your FTP server to change whatever needs to be changed. When I first discovered that feature I was quite impressed (not too many website projects support that).
 
Last edited by a moderator:
Just wanted to post...
Thanks for your help here guys.
With this, I was able to get my new installation of Apache in FreeBSD10.0 up and running.

Thank you!
 
Back
Top